Class: Appraisal::Appraisal
- Inherits:
-
Object
- Object
- Appraisal::Appraisal
- Defined in:
- lib/appraisal/appraisal.rb
Overview
Represents one appraisal and its dependencies
Instance Attribute Summary collapse
-
#gemfile ⇒ Object
readonly
Returns the value of attribute gemfile.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #gem(*args) ⇒ Object
- #gemfile_path ⇒ Object
- #gemspec(options = {}) ⇒ Object
- #git(*args, &block) ⇒ Object
- #group(*args, &block) ⇒ Object
-
#initialize(name, source_gemfile) ⇒ Appraisal
constructor
A new instance of Appraisal.
- #install(job_size = 1) ⇒ Object
- #path(*args, &block) ⇒ Object
- #platforms(*args, &block) ⇒ Object
- #relative_gemfile_path ⇒ Object
- #relativize ⇒ Object
- #ruby(*args) ⇒ Object
- #source(*args, &block) ⇒ Object
- #update(gems = []) ⇒ Object
- #write_gemfile ⇒ Object
Constructor Details
#initialize(name, source_gemfile) ⇒ Appraisal
Returns a new instance of Appraisal.
12 13 14 15 |
# File 'lib/appraisal/appraisal.rb', line 12 def initialize(name, source_gemfile) @name = name @gemfile = source_gemfile.dup end |
Instance Attribute Details
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
10 11 12 |
# File 'lib/appraisal/appraisal.rb', line 10 def gemfile @gemfile end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/appraisal/appraisal.rb', line 10 def name @name end |
Instance Method Details
#gem(*args) ⇒ Object
17 18 19 |
# File 'lib/appraisal/appraisal.rb', line 17 def gem(*args) gemfile.gem(*args) end |
#gemfile_path ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/appraisal/appraisal.rb', line 76 def gemfile_path unless gemfile_root.exist? gemfile_root.mkdir end gemfile_root.join(gemfile_name).to_s end |
#gemspec(options = {}) ⇒ Object
45 46 47 |
# File 'lib/appraisal/appraisal.rb', line 45 def gemspec( = {}) gemfile.gemspec() end |
#git(*args, &block) ⇒ Object
29 30 31 |
# File 'lib/appraisal/appraisal.rb', line 29 def git(*args, &block) gemfile.git(*args, &block) end |
#group(*args, &block) ⇒ Object
37 38 39 |
# File 'lib/appraisal/appraisal.rb', line 37 def group(*args, &block) gemfile.group(*args, &block) end |
#install(job_size = 1) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/appraisal/appraisal.rb', line 56 def install(job_size = 1) command = [ check_command, "||", install_command(job_size) ].flatten.join(" ") if Bundler.settings[:path] env = { 'BUNDLE_DISABLE_SHARED_GEMS' => '1' } Command.new(command, :env => env).run else Command.new(command).run end end |
#path(*args, &block) ⇒ Object
33 34 35 |
# File 'lib/appraisal/appraisal.rb', line 33 def path(*args, &block) gemfile.path(*args, &block) end |
#platforms(*args, &block) ⇒ Object
41 42 43 |
# File 'lib/appraisal/appraisal.rb', line 41 def platforms(*args, &block) gemfile.platforms(*args, &block) end |
#relative_gemfile_path ⇒ Object
84 85 86 |
# File 'lib/appraisal/appraisal.rb', line 84 def relative_gemfile_path ::File.join("gemfiles", gemfile_name) end |
#relativize ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/appraisal/appraisal.rb', line 88 def relativize current_directory = Pathname.new(Dir.pwd) relative_path = current_directory.relative_path_from(gemfile_root).cleanpath lockfile_content = ::File.read(lockfile_path) ::File.open(lockfile_path, 'w') do |file| file.write lockfile_content.gsub(/#{current_directory}/, relative_path.to_s) end end |
#ruby(*args) ⇒ Object
25 26 27 |
# File 'lib/appraisal/appraisal.rb', line 25 def ruby(*args) gemfile.ruby(*args) end |
#source(*args, &block) ⇒ Object
21 22 23 |
# File 'lib/appraisal/appraisal.rb', line 21 def source(*args, &block) gemfile.source(*args, &block) end |
#update(gems = []) ⇒ Object
71 72 73 74 |
# File 'lib/appraisal/appraisal.rb', line 71 def update(gems = []) command, env = update_command(gems) Command.new(command, :env => env).run end |
#write_gemfile ⇒ Object
49 50 51 52 53 54 |
# File 'lib/appraisal/appraisal.rb', line 49 def write_gemfile ::File.open(gemfile_path, "w") do |file| signature = "# This file was generated by Appraisal" file.puts([signature, gemfile.to_s].join("\n\n")) end end |