How to use root_dir method of Project Package

Best Rr_ruby code snippet using Project.root_dir

scaffold.rb

Source:scaffold.rb Github

copy

Full Screen

2require 'fileutils'3module GLI4 module Commands5 class Scaffold #:nodoc:6 def self.create_scaffold(root_dir,7 create_test_dir,8 create_ext_dir,9 project_name,10 commands,11 force=false,12 dry_run=false,13 create_rvmrc=false)14 dirs = [File.join(root_dir,project_name,'lib')]15 dirs << File.join(root_dir,project_name,'bin')16 dirs << File.join(root_dir,project_name,'test') if create_test_dir17 dirs << File.join(root_dir,project_name,'ext') if create_ext_dir18 if mkdirs(dirs,force,dry_run)19 mk_binfile(root_dir,create_ext_dir,force,dry_run,project_name,commands)20 mk_readme(root_dir,dry_run,project_name)21 mk_gemspec(root_dir,dry_run,project_name)22 mk_rakefile(root_dir,dry_run,project_name,create_test_dir)23 mk_lib_files(root_dir,dry_run,project_name)24 if create_rvmrc25 rvmrc = File.join(root_dir,project_name,".rvmrc")26 File.open(rvmrc,'w') do |file|27 file.puts "rvm use #{ENV['rvm_ruby_string']}@#{project_name} --create"28 end29 puts "Created #{rvmrc}"30 end31 end32 end33 def self.mk_readme(root_dir,dry_run,project_name)34 return if dry_run35 File.open("#{root_dir}/#{project_name}/README.rdoc",'w') do |file|36 file << "= #{project_name}\n\n"37 file << "Describe your project here\n\n"38 file << ":include:#{project_name}.rdoc\n\n"39 end40 puts "Created #{root_dir}/#{project_name}/README.rdoc"41 File.open("#{root_dir}/#{project_name}/#{project_name}.rdoc",'w') do |file|42 file << "= #{project_name}\n\n"43 file << "Generate this with\n #{project_name} rdoc\nAfter you have described your command line interface"44 end45 puts "Created #{root_dir}/#{project_name}/#{project_name}.rdoc"46 end47 def self.mk_gemspec(root_dir,dry_run,project_name)48 return if dry_run49 File.open("#{root_dir}/#{project_name}/#{project_name}.gemspec",'w') do |file|50 file.puts <<EOS51# Ensure we require the local version and not one we might have installed already52require File.join([File.dirname(__FILE__),'lib','#{project_name}','version.rb'])53spec = Gem::Specification.new do |s| 54 s.name = '#{project_name}'55 s.version = #{project_name_as_module_name(project_name)}::VERSION56 s.author = 'Your Name Here'57 s.email = 'your@email.address.com'58 s.homepage = 'http://your.website.com'59 s.platform = Gem::Platform::RUBY60 s.summary = 'A description of your project'61 s.files = `git ls-files`.split("\n")62 s.require_paths << 'lib'63 s.has_rdoc = true64 s.extra_rdoc_files = ['README.rdoc','#{project_name}.rdoc']65 s.rdoc_options << '--title' << '#{project_name}' << '--main' << 'README.rdoc' << '-ri'66 s.bindir = 'bin'67 s.executables << '#{project_name}'68 s.add_development_dependency('rake')69 s.add_development_dependency('rdoc')70 s.add_development_dependency('aruba')71 s.add_runtime_dependency('gli','#{GLI::VERSION}')72end73EOS74 end75 puts "Created #{root_dir}/#{project_name}/#{project_name}.gemspec"76 end77 def self.project_name_as_module_name(project_name)78 project_name.split(/[_-]/).map { |part| part[0..0].upcase + part[1..-1] }.join('')79 end80 def self.mk_lib_files(root_dir,dry_run,project_name)81 return if dry_run82 FileUtils.mkdir("#{root_dir}/#{project_name}/lib/#{project_name}")83 File.open("#{root_dir}/#{project_name}/lib/#{project_name}/version.rb",'w') do |file|84 file.puts <<EOS85module #{project_name_as_module_name(project_name)}86 VERSION = '0.0.1'87end88EOS89 end90 puts "Created #{root_dir}/#{project_name}/lib/#{project_name}/version.rb"91 File.open("#{root_dir}/#{project_name}/lib/#{project_name}.rb",'w') do |file|92 file.puts <<EOS93require '#{project_name}/version.rb'94# Add requires for other files you add to your project here, so95# you just need to require this one file in your bin file96EOS97 end98 puts "Created #{root_dir}/#{project_name}/lib/#{project_name}.rb"99 end100 def self.mk_rakefile(root_dir,dry_run,project_name,create_test_dir)101 return if dry_run102 File.open("#{root_dir}/#{project_name}/Rakefile",'w') do |file|103 file.puts <<EOS104require 'rake/clean'105require 'rubygems'106require 'rubygems/package_task'107require 'rdoc/task'108EOS109 if create_test_dir110 file.puts <<EOS111require 'cucumber'112require 'cucumber/rake/task'113EOS114 end115 file.puts <<EOS116Rake::RDocTask.new do |rd|117 rd.main = "README.rdoc"118 rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")119 rd.title = 'Your application title'120end121spec = eval(File.read('#{project_name}.gemspec'))122Gem::PackageTask.new(spec) do |pkg|123end124EOS125 if create_test_dir126 file.puts <<EOS127CUKE_RESULTS = 'results.html'128CLEAN << CUKE_RESULTS129desc 'Run features'130Cucumber::Rake::Task.new(:features) do |t|131 opts = "features --format html -o \#{CUKE_RESULTS} --format progress -x"132 opts += " --tags \#{ENV['TAGS']}" if ENV['TAGS']133 t.cucumber_opts = opts134 t.fork = false135end136desc 'Run features tagged as work-in-progress (@wip)'137Cucumber::Rake::Task.new('features:wip') do |t|138 tag_opts = ' --tags ~@pending'139 tag_opts = ' --tags @wip'140 t.cucumber_opts = "features --format html -o \#{CUKE_RESULTS} --format pretty -x -s\#{tag_opts}"141 t.fork = false142end143task :cucumber => :features144task 'cucumber:wip' => 'features:wip'145task :wip => 'features:wip'146EOS147 end148 if create_test_dir149 file.puts <<EOS150require 'rake/testtask'151Rake::TestTask.new do |t|152 t.libs << "test"153 t.test_files = FileList['test/*_test.rb']154end155task :default => [:test,:features]156EOS157 File.open("#{root_dir}/#{project_name}/test/default_test.rb",'w') do |test_file|158 test_file.puts <<EOS159require 'test_helper'160class DefaultTest < Test::Unit::TestCase161 def setup162 end163 def teardown164 end165 def test_the_truth166 assert true167 end168end169EOS170 end171 puts "Created #{root_dir}/#{project_name}/test/default_test.rb"172 File.open("#{root_dir}/#{project_name}/test/test_helper.rb",'w') do |test_file|173 test_file.puts <<EOS174require 'test/unit'175# Add test libraries you want to use here, e.g. mocha176class Test::Unit::TestCase177 # Add global extensions to the test case class here178 179end180EOS181 end182 puts "Created #{root_dir}/#{project_name}/test/test_helper.rb"183 else184 file.puts "task :default => :package\n"185 end186 end187 puts "Created #{root_dir}/#{project_name}/Rakefile"188 File.open("#{root_dir}/#{project_name}/Gemfile",'w') do |bundler_file|189 bundler_file.puts "source 'https://rubygems.org'"190 bundler_file.puts "gemspec"191 end192 puts "Created #{root_dir}/#{project_name}/Gemfile"193 if create_test_dir194 features_dir = File.join(root_dir,project_name,'features')195 FileUtils.mkdir features_dir196 FileUtils.mkdir File.join(features_dir,"step_definitions")197 FileUtils.mkdir File.join(features_dir,"support")198 File.open(File.join(features_dir,"#{project_name}.feature"),'w') do |file|199 file.puts <<EOS200Feature: My bootstrapped app kinda works201 In order to get going on coding my awesome app202 I want to have aruba and cucumber setup203 So I don't have to do it myself204 Scenario: App just runs205 When I get help for "#{project_name}"206 Then the exit status should be 0207EOS208 end209 File.open(File.join(features_dir,"step_definitions","#{project_name}_steps.rb"),'w') do |file|210 file.puts <<EOS211When /^I get help for "([^"]*)"$/ do |app_name|212 @app_name = app_name213 step %(I run `\#{app_name} help`)214end215# Add more step definitions here216EOS217 end218 File.open(File.join(features_dir,"support","env.rb"),'w') do |file|219 file.puts <<EOS220require 'aruba/cucumber'221ENV['PATH'] = "\#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}\#{File::PATH_SEPARATOR}\#{ENV['PATH']}"222LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')223Before do224 # Using "announce" causes massive warnings on 1.9.2225 @puts = true226 @original_rubylib = ENV['RUBYLIB']227 ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s228end229After do230 ENV['RUBYLIB'] = @original_rubylib231end232EOS233 end234 puts "Created #{features_dir}"235 end236 end237 def self.mk_binfile(root_dir,create_ext_dir,force,dry_run,project_name,commands)238 bin_file = File.join(root_dir,project_name,'bin',project_name)239 if !File.exist?(bin_file) || force240 if !dry_run241 File.open(bin_file,'w') do |file|242 file.chmod(0755)243 file.puts '#!/usr/bin/env ruby'244 file.puts <<EOS245require 'gli'246begin # XXX: Remove this begin/rescue before distributing your app247require '#{project_name}'248rescue LoadError249 STDERR.puts "In development, you need to use `bundle exec bin/#{project_name}` to run your app"250 STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"251 STDERR.puts "Feel free to remove this message from bin/#{project_name} now"252 exit 64...

Full Screen

Full Screen

project_transfer_spec.rb

Source:project_transfer_spec.rb Github

copy

Full Screen

1# frozen_string_literal: true2require 'spec_helper'3RSpec.describe Gitlab::ProjectTransfer do4 before do5 @root_dir = File.join(Rails.root, "public", "uploads")6 @project_transfer = described_class.new7 allow(@project_transfer).to receive(:root_dir).and_return(@root_dir)8 @project_path_was = "test_project_was"9 @project_path = "test_project"10 @namespace_path_was = "test_namespace_was"11 @namespace_path = "test_namespace"12 end13 after do14 FileUtils.rm_rf([15 File.join(@root_dir, @namespace_path),16 File.join(@root_dir, @namespace_path_was)17 ])18 end19 describe '#move_project' do20 it "moves project upload to another namespace" do21 path_to_be_moved = File.join(@root_dir, @namespace_path_was, @project_path)22 expected_path = File.join(@root_dir, @namespace_path, @project_path)23 FileUtils.mkdir_p(path_to_be_moved)24 @project_transfer.move_project(@project_path, @namespace_path_was, @namespace_path)25 expect(Dir.exist?(expected_path)).to be_truthy26 end27 end28 describe '#move_namespace' do29 context 'when moving namespace from root into another namespace' do30 it "moves namespace projects' upload" do31 child_namespace = 'test_child_namespace'32 path_to_be_moved = File.join(@root_dir, child_namespace, @project_path)33 expected_path = File.join(@root_dir, @namespace_path, child_namespace, @project_path)34 FileUtils.mkdir_p(path_to_be_moved)35 @project_transfer.move_namespace(child_namespace, nil, @namespace_path)36 expect(Dir.exist?(expected_path)).to be_truthy37 end38 end39 context 'when moving namespace from one parent to another' do40 it "moves namespace projects' upload" do41 child_namespace = 'test_child_namespace'42 path_to_be_moved = File.join(@root_dir, @namespace_path_was, child_namespace, @project_path)43 expected_path = File.join(@root_dir, @namespace_path, child_namespace, @project_path)44 FileUtils.mkdir_p(path_to_be_moved)45 @project_transfer.move_namespace(child_namespace, @namespace_path_was, @namespace_path)46 expect(Dir.exist?(expected_path)).to be_truthy47 end48 end49 context 'when moving namespace from having a parent to root' do50 it "moves namespace projects' upload" do51 child_namespace = 'test_child_namespace'52 path_to_be_moved = File.join(@root_dir, @namespace_path_was, child_namespace, @project_path)53 expected_path = File.join(@root_dir, child_namespace, @project_path)54 FileUtils.mkdir_p(path_to_be_moved)55 @project_transfer.move_namespace(child_namespace, @namespace_path_was, nil)56 expect(Dir.exist?(expected_path)).to be_truthy57 end58 end59 end60 describe '#rename_project' do61 it "renames project" do62 path_to_be_moved = File.join(@root_dir, @namespace_path, @project_path_was)63 expected_path = File.join(@root_dir, @namespace_path, @project_path)64 FileUtils.mkdir_p(path_to_be_moved)65 @project_transfer.rename_project(@project_path_was, @project_path, @namespace_path)66 expect(Dir.exist?(expected_path)).to be_truthy67 end68 end69 describe '#rename_namespace' do70 it "renames namespace" do71 path_to_be_moved = File.join(@root_dir, @namespace_path_was, @project_path)72 expected_path = File.join(@root_dir, @namespace_path, @project_path)73 FileUtils.mkdir_p(path_to_be_moved)74 @project_transfer.rename_namespace(@namespace_path_was, @namespace_path)75 expect(Dir.exist?(expected_path)).to be_truthy76 end77 end78end...

Full Screen

Full Screen

uploads_transfer_spec.rb

Source:uploads_transfer_spec.rb Github

copy

Full Screen

1require 'spec_helper'2describe Gitlab::UploadsTransfer, lib: true do3 before do4 @root_dir = File.join(Rails.root, "public", "uploads")5 @upload_transfer = Gitlab::UploadsTransfer.new6 @project_path_was = "test_project_was"7 @project_path = "test_project"8 @namespace_path_was = "test_namespace_was"9 @namespace_path = "test_namespace"10 end11 after do12 FileUtils.rm_rf([13 File.join(@root_dir, @namespace_path),14 File.join(@root_dir, @namespace_path_was)15 ])16 end17 describe '#move_project' do18 it "moves project upload to another namespace" do19 FileUtils.mkdir_p(File.join(@root_dir, @namespace_path_was, @project_path))20 @upload_transfer.move_project(@project_path, @namespace_path_was, @namespace_path)21 expected_path = File.join(@root_dir, @namespace_path, @project_path)22 expect(Dir.exist?(expected_path)).to be_truthy23 end24 end25 describe '#rename_project' do26 it "renames project" do27 FileUtils.mkdir_p(File.join(@root_dir, @namespace_path, @project_path_was))28 @upload_transfer.rename_project(@project_path_was, @project_path, @namespace_path)29 expected_path = File.join(@root_dir, @namespace_path, @project_path)30 expect(Dir.exist?(expected_path)).to be_truthy31 end32 end33 describe '#rename_namespace' do34 it "renames namespace" do35 FileUtils.mkdir_p(File.join(@root_dir, @namespace_path_was, @project_path))36 @upload_transfer.rename_namespace(@namespace_path_was, @namespace_path)37 expected_path = File.join(@root_dir, @namespace_path, @project_path)38 expect(Dir.exist?(expected_path)).to be_truthy39 end40 end41end

Full Screen

Full Screen

root_dir

Using AI Code Generation

copy

Full Screen

1puts Project.new("Project 1").root_dir2 def initialize(name)3 File.dirname(__FILE__)

Full Screen

Full Screen

root_dir

Using AI Code Generation

copy

Full Screen

1project1 = Project.new("Project ABC", 5000, 3000)2project1 = Project.new("Project ABC", 5000, 3000)3 def initialize(name, description, owner)4 def add_tasks(task)5 @tasks.push(task)6project1 = Project.new("Project 1", "description 1", "John Doe")7project2 = Project.new("Project 2", "description 2", "Jane Doe")8project1.add_tasks("task1")9project1.add_tasks("task2")10project1.add_tasks("task3")11project1 = Project.new("Project ABC", 5000, 3000)12 def initialize(name, description, owner)13 def add_tasks(task)14 @tasks.push(task)

Full Screen

Full Screen

root_dir

Using AI Code Generation

copy

Full Screen

1project1 = Project.new("Project ABC", 1000, 5000)2 def initialize(name, funding, target)3 File.dirname(__FILE__)4$LOAD_PATH.unshift(".")5project1 = Project.new("Project ABC", 1000, 5000)

Full Screen

Full Screen

root_dir

Using AI Code Generation

copy

Full Screen

1require File.join(Project.root_dir, 'lib', 'other.rb')2require File.join(Project.root_dir, 'lib', 'other.rb')3require File.join(Project.root_dir, 'lib', 'other.rb')4require File.join(Project.root_dir, 'lib', 'other.rb')5require File.join(Project.root_dir, 'lib', 'other.rb')6require File.join(Project.root_dir, 'lib', 'other.rb')7require File.join(Project.root_dir, 'lib', 'other.rb')8require File.join(Project.root_dir, 'lib', 'other.rb')9require File.join(Project.root_dir, 'lib', 'other.rb')

Full Screen

Full Screen

root_dir

Using AI Code Generation

copy

Full Screen

1 Pathname.new(__FILE__).realpath.parent.parent2puts Project.new.root_dir.join('lib', 'project.rb').to_s3 Pathname.new(__FILE__).dirname.dirname4puts Project.new.root_dir.join('lib', 'project.rb').to_s5 Pathname.new(__FILE__).dirname.parent6puts Project.new.root_dir.join('lib', 'project.rb').to_s7 Pathname.new(__FILE__).dirname.parent.parent8puts Project.new.root_dir.join('lib', 'project.rb').to_s9 Pathname.new(__FILE__).dirname.dirname.dirname10puts Project.new.root_dir.join('lib', 'project.rb').to_s

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