How to use lib_dir method of Project Package

Best Rr_ruby code snippet using Project.lib_dir

Rakefile

Source:Rakefile Github

copy

Full Screen

1#$LOAD_PATH.unshift ".lib"2ANT_HOME = '/usr/local/ant'3@project_name = 'ProjetStp'4@lib_dir = 'lib'5# Ruby stuff6@ruby_script_dir = 'src/main/ruby'7@ruby_test_dir = 'src/test/ruby'8@ruby_bin_dir = 'bin'9# Java stuff10@mainclass = 'org.stp.Utils.log4jExample'11@java_src_dir = 'src/main/java'12@java_build_dir = 'build'13@classes_dir = "#{@java_build_dir}" #/classes"14@jar_file = "#{@lib_dir}/#{@project_name}.jar"15@test_jar_file = "#{@java_build_dir}/#{@project_name}Test.jar"16@java_test_dir = 'src/test/java'17@test_report_dir = 'build/report'18@test_report_html = 'build/report/html'19JRUBY_COMPLETE = "vendor/jruby-complete-9.1.12.0.jar"20jars = FileList["#{@lib_dir}/**/*.jar"].join(':')21GEM_PATH="vendor/bundle/jruby/2.3.0"22#JRUBY = "java -classpath .:#{JRUBY_COMPLETE} org.jruby.Main "23LOCALGEMS = "GEM_HOME=#{GEM_PATH} GEM_PATH=#{GEM_PATH} "24JRUBY = "/usr/local/jruby/bin/jruby --ng "25# ----- Ant-based tasks26require 'ant'27namespace :ant do28 lib_dir = @lib_dir29 classes_dir = @classes_dir30 java_src_dir = @java_src_dir31 java_test_dir = @java_test_dir32 jar_file = @jar_file33 java_test_dir = @java_test_dir34 test_report_dir = @test_report_dir35 desc "Compile the code using Ant"36 task :compileall => "clean" do37 ant.mkdir :dir => classes_dir38 compile(@java_src_dir)39 compile(@java_test_dir)40 end41 def compile(src)42 puts "Compiling java from #{src} to #{@classes_dir}"43 ant.javac :srcdir => src , :destdir => @classes_dir do44 classpath do45 fileset :dir => @lib_dir, :includes => "**/*.jar"46 end47 end48 end49 desc "Create a jar file of the compiled code using Ant"50 task :jar => "ant:compileall" do51 puts "Creating #{jar_file}"52 ant.delete :file => jar_file #, :verbose => true53 ant.jar :destfile => jar_file, :basedir => classes_dir54 end55 task :java_test => "ant:compileall" do56 puts "begin_tests"57 ant.mkdir :dir => test_report_dir58 ant.junit :fork => "yes", :forkmode => "once", :printsummary => "yes",59 :haltonfailure => "no", :failureproperty => "tests.failed" do60 classpath do61 fileset :dir => lib_dir, :includes => "**/*.jar"62 pathelement :location => classes_dir63 end64 formatter :type => "xml"65 batchtest :todir => test_report_dir do66 fileset :dir => java_test_dir, :includes => '**/*Test.java'67 end68 end69 if ant.project.getProperty("tests.failed")70 report71 puts "FAILURE: One or more tests failed. \nPlease check the test report in <<#{test_report_html}>> for more info."72 end73 puts "end tests"74 end75 def report76 ant.junitreport :todir => test_report_dir do77 fileset :dir => test_report_dir, :includes => "TEST-*.xml"78 report :format => "frames", :todir => test_report_html79 end80 end81 #task :make_war => :make_jars do82 # ant.mkdir :dir => DIST_DIR83 # ant.war :warfile => "#{DIST_DIR}/#{PROJECT_NAME}.war", :webxml => "src/main/webapp/WEB-INF/web.xml" do84 # fileset :dir => "src/main/webapp", :excludes => "**/web.xml"85 # lib :dir => COMPILE_DIR, :excludes => "*-tests.jar"86 # classes :dir => "src/main/resources"87 # lib :dir => RUNTIME_LIB_DIR88 # end89 # puts90 #end91 #92 #task :run_jetty => [:clean, :make_jars] do93 # ant.java :classname => "example.jetty.WebServer", :fork => 'yes', :failonerror => 'yes' do94 # classpath :location => "src/main/resources"95 # classpath :refid => "classpath"96 # end97 #end98end99# ------ Project setup100namespace :setup do101 desc "1-Install bundler"102 task :bundler do103 sh %!#{JRUBY} -S gem install -i vendor/gem_home --no-rdoc --no-ri bundler!104 end105 desc "2-Install the gems"106 task :gems do107 sh %!#{JRUBY} -S bundle install --path=vendor/bundle --binstubs !108 end109 desc "3-Package gems"110 task :pack do111 sh %!#{LOCALGEMS} #{JRUBY} -S bundle package!112 end113end #setup114# ------ Ruby testing all files *_Test.rb115require 'rake/testtask'116Rake::TestTask.new do |task|117 task.libs << [@ruby_script_dir, @lib_dir]118 task.test_files = FileList["#{@ruby_test_dir}/Test_*.rb"]119 task.verbose = false120end121# ----- Ruby tasks122namespace :ruby do123 task :run do124 arg = "#{@ruby_bin_dir}/application_bootstrap"125 libs = "#{@ruby_script_dir}:#{@ruby_bin_dir}:#{@lib_dir}"126 JRUBY_OPTS = "-I #{libs} #{arg}"127# sh %!#{JRUBY} --help!128 sh %!#{LOCALGEMS} #{JRUBY} -I #{libs} #{arg} 8!129 end130end131# ----- Rake tasks132task :report => ["ant:report"]133task :run_jar do134 jars = FileList["#{@lib_dir}/**/*.jar"].join(':')135 sh "java -classpath #{jars}:#{@jar_file} #{@mainclass}"136end137task :java_test => ["ant:java_test"]138task :run_mainclass => ["ant:compileall"] do139 jars = FileList["#{@lib_dir}/**/*.jar"].join(':')140 sh "java -classpath .:#{jars}:#{@java_build_dir} #{@mainclass}"141end142# Clean143require 'rake/clean'144 CLEAN << @java_build_dir145task :default => "ruby:run"...

Full Screen

Full Screen

test_measures_osw.rb

Source:test_measures_osw.rb Github

copy

Full Screen

...10 project_dir = "project_testing"11 num_samples = 112 parent_dir = File.absolute_path(File.join(File.dirname(__FILE__), "test_measures_osw"))13 buildstock_csv = create_buildstock_csv(project_dir, num_samples)14 lib_dir = create_lib_folder(parent_dir, project_dir, buildstock_csv)15 weather_dir = create_weather_folder(parent_dir, project_dir)16 measures_osw_dir = File.join(parent_dir, "measures_osw")17 Dir.mkdir(measures_osw_dir) unless File.exist?(measures_osw_dir)18 (1..num_samples).to_a.each do |building_id|19 Dir["#{parent_dir}/build_existing_model.osw"].each do |osw|20 change_building_id(osw, building_id)21 run_and_check(osw, parent_dir, measures_osw_dir, building_id)22 end23 end24 Dir["#{parent_dir}/build_existing_model.osw"].each do |osw|25 change_building_id(osw, 1)26 end27 FileUtils.rm_rf(lib_dir) if File.exist?(lib_dir)28 FileUtils.rm_rf(weather_dir) if File.exist?(weather_dir)29 FileUtils.rm_rf(File.join(parent_dir, "run"))30 FileUtils.rm_rf(File.join(parent_dir, "reports"))31 end32 def run_and_check(in_osw, parent_dir, measures_osw_dir, building_id)33 # Create measures.osw34 cli_path = OpenStudio.getOpenStudioCLI35 command = "cd #{parent_dir} && \"#{cli_path}\" --no-ssl run -w #{in_osw}"36 system(command)37 # Check output file exists38 out_osw = File.join(parent_dir, "out.osw")39 new_out_osw = File.join(measures_osw_dir, "#{building_id}.osw")40 FileUtils.mv(out_osw, new_out_osw)41 assert(File.exists?(new_out_osw))42 # Check workflow was successful43 data_hash = JSON.parse(File.read(new_out_osw))44 assert_equal(data_hash["completed_status"], "Success")45 end46 def create_buildstock_csv(project_dir, num_samples)47 outfile = File.join("..", "test", "test_measures_osw", "buildstock.csv")48 r = RunSampling.new49 r.run(project_dir, num_samples, outfile)50 return outfile51 end52 def create_lib_folder(parent_dir, project_dir, buildstock_csv)53 lib_dir = File.join(parent_dir, "..", "..", "lib") # at top level54 resources_dir = File.join(parent_dir, "..", "..", "resources")55 housing_characteristics_dir = File.join(parent_dir, "..", "..", project_dir, "housing_characteristics")56 Dir.mkdir(lib_dir) unless File.exist?(lib_dir)57 FileUtils.cp_r(resources_dir, lib_dir)58 FileUtils.cp_r(housing_characteristics_dir, lib_dir)59 FileUtils.cp(File.join(resources_dir, buildstock_csv), File.join(lib_dir, "housing_characteristics"))60 return lib_dir61 end62 def create_weather_folder(parent_dir, project_dir)63 src = File.join(parent_dir, "..", "..", "resources", "measures", "HPXMLtoOpenStudio", "weather", project_dir)64 des = File.join(parent_dir, "..", "..", "weather")65 FileUtils.cp_r(src, des)66 return des67 end68 def change_building_id(osw, building_id)69 json = JSON.parse(File.read(osw), symbolize_names: true)70 json[:steps].each do |measure|71 next if measure[:measure_dir_name] != "BuildExistingModel"72 measure[:arguments][:building_id] = "#{building_id}"73 end74 File.open(osw, "w") do |f|...

Full Screen

Full Screen

split.rake

Source:split.rake Github

copy

Full Screen

...53end54task :create_interface => :create_frontend do55 dir = "#{PROJECT_NAME}_interface"56 app_dir = "#{dir}/app"57 lib_dir = "#{dir}/lib"58 do_in_parent_dir do59 mkdir dir unless Dir.exists?(dir)60 mkdir app_dir unless Dir.exists?(app_dir)61 move "#{FRONTEND_DIR}/app/commands", app_dir62 move "#{FRONTEND_DIR}/app/events", app_dir63 move "#{FRONTEND_DIR}/app/validations", app_dir64 mkdir lib_dir unless Dir.exists?(lib_dir)65 temp_dir = "#{lib_dir}/#{PROJECT_NAME}"66 mkdir temp_dir unless Dir.exists?(temp_dir)67 move "#{FRONTEND_DIR}/lib/#{PROJECT_NAME}/domain.rb", temp_dir68 move "#{FRONTEND_DIR}/lib/#{PROJECT_NAME}.rb", "#{lib_dir}/#{dir}.rb"69 #todo: delete first line in this file70 #todo: gemfile and gemspec71 end72end73task :create_frontend => :environment do74 FRONTEND_DIR = "#{PROJECT_NAME}_frontend"75 app_dir = "#{FRONTEND_DIR}/app"76 lib_dir = "#{FRONTEND_DIR}/lib"77 do_in_parent_dir do78 mkdir FRONTEND_DIR unless Dir.exists?(FRONTEND_DIR)79 cp_r "#{PROJECT_NAME}/.", FRONTEND_DIR80 cp_r "#{FRONTEND_DIR}/lib/#{PROJECT_NAME}.rb", "#{lib_dir}/#{FRONTEND_DIR}.rb"81 #todo: delete line 2, 5 and 6 in this file82 end83end84desc 'split this'85task :split => [:create_projection, :create_domain, :create_interface] do86 puts 'done'87end

Full Screen

Full Screen

lib_dir

Using AI Code Generation

copy

Full Screen

1 File.dirname(__FILE__) + '/lib'2 File.dirname(__FILE__) + '/lib'3Project.send(:include, Project::LibDir)4Project.send(:include, Project::LibDir)5 File.dirname(__FILE__) + '/lib'6 File.dirname(__FILE__) + '/lib'7 File.dirname(__FILE__) + '/lib'8 File.dirname(__FILE__) + '/lib'9Project.send(:include, Project::LibDir)10 File.dirname(__FILE__) + '/lib'11 File.dirname(__FILE__) + '/lib'12Project.send(:include, Project::LibDir)13 File.dirname(__FILE__) + '/lib'14 File.dirname(__FILE__) + '/lib'

Full Screen

Full Screen

lib_dir

Using AI Code Generation

copy

Full Screen

1project = Project.new('Project ABC', 'I am a project', 'John Doe')2 def initialize(name, description, owner)3project = Project.new('Project ABC', 'I am a project', 'John Doe')4 def initialize(name, description, owner)

Full Screen

Full Screen

lib_dir

Using AI Code Generation

copy

Full Screen

1require File.join(Project.new.lib_dir, '2.rb')2require File.join(Project.new.lib_dir, '3.rb')3require File.join(Project.new.lib_dir, '4.rb')4require File.join(Project.new.lib_dir, '5.rb')5require File.join(Project.new.lib_dir, '6.rb')6require File.join(Project.new.lib_dir, '7.rb')7require File.join(Project.new.lib_dir, '8.rb')8require File.join(Project.new.lib_dir, '9.rb')

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful