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
- #eval_gemfile(*args) ⇒ Object
- #gem(*args) ⇒ Object
- #gemfile_path ⇒ Object
- #gemspec(options = {}) ⇒ Object
- #git(*args, &block) ⇒ Object
- #git_source(*args, &block) ⇒ Object
- #group(*args, &block) ⇒ Object
-
#initialize(name, source_gemfile) ⇒ Appraisal
constructor
A new instance of Appraisal.
- #install(options = {}) ⇒ Object
- #install_if(*args, &block) ⇒ Object
- #path(*args, &block) ⇒ Object
- #platforms(*args, &block) ⇒ Object
- #relative_gemfile_path ⇒ Object
- #relativize ⇒ Object
- #remove_gem(*args) ⇒ Object
- #ruby(*args) ⇒ Object
- #source(*args, &block) ⇒ Object
- #update(gems = [], options = {}) ⇒ Object
- #write_gemfile ⇒ Object
Constructor Details
#initialize(name, source_gemfile) ⇒ Appraisal
Returns a new instance of Appraisal.
20 21 22 23 |
# File 'lib/appraisal/appraisal.rb', line 20 def initialize(name, source_gemfile) @name = name @gemfile = source_gemfile.dup end |
Instance Attribute Details
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
18 19 20 |
# File 'lib/appraisal/appraisal.rb', line 18 def gemfile @gemfile end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/appraisal/appraisal.rb', line 18 def name @name end |
Instance Method Details
#eval_gemfile(*args) ⇒ Object
25 26 27 |
# File 'lib/appraisal/appraisal.rb', line 25 def eval_gemfile(*args) gemfile.eval_gemfile(*args) end |
#gem(*args) ⇒ Object
29 30 31 |
# File 'lib/appraisal/appraisal.rb', line 29 def gem(*args) gemfile.gem(*args) end |
#gemfile_path ⇒ Object
96 97 98 99 100 |
# File 'lib/appraisal/appraisal.rb', line 96 def gemfile_path gemfile_root.mkdir unless gemfile_root.exist? gemfile_root.join(gemfile_name).to_s end |
#gemspec(options = {}) ⇒ Object
65 66 67 |
# File 'lib/appraisal/appraisal.rb', line 65 def gemspec( = {}) gemfile.gemspec() end |
#git(*args, &block) ⇒ Object
45 46 47 |
# File 'lib/appraisal/appraisal.rb', line 45 def git(*args, &block) gemfile.git(*args, &block) end |
#git_source(*args, &block) ⇒ Object
69 70 71 |
# File 'lib/appraisal/appraisal.rb', line 69 def git_source(*args, &block) gemfile.git_source(*args, &block) end |
#group(*args, &block) ⇒ Object
53 54 55 |
# File 'lib/appraisal/appraisal.rb', line 53 def group(*args, &block) gemfile.group(*args, &block) end |
#install(options = {}) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/appraisal/appraisal.rb', line 80 def install( = {}) write_gemfile unless File.exist?(gemfile_path) gem_manager = .delete(:gem_manager) || .delete("gem_manager") || .delete(:"gem-manager") || .delete("gem-manager") manager = GemManager::Factory.create(gemfile_path, project_root, :manager => gem_manager) manager.install() end |
#install_if(*args, &block) ⇒ Object
57 58 59 |
# File 'lib/appraisal/appraisal.rb', line 57 def install_if(*args, &block) gemfile.install_if(*args, &block) end |
#path(*args, &block) ⇒ Object
49 50 51 |
# File 'lib/appraisal/appraisal.rb', line 49 def path(*args, &block) gemfile.path(*args, &block) end |
#platforms(*args, &block) ⇒ Object
61 62 63 |
# File 'lib/appraisal/appraisal.rb', line 61 def platforms(*args, &block) gemfile.platforms(*args, &block) end |
#relative_gemfile_path ⇒ Object
102 103 104 |
# File 'lib/appraisal/appraisal.rb', line 102 def relative_gemfile_path File.join("gemfiles", gemfile_name) end |
#relativize ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/appraisal/appraisal.rb', line 106 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}" )) end end |
#remove_gem(*args) ⇒ Object
33 34 35 |
# File 'lib/appraisal/appraisal.rb', line 33 def remove_gem(*args) gemfile.remove_gem(*args) end |
#ruby(*args) ⇒ Object
41 42 43 |
# File 'lib/appraisal/appraisal.rb', line 41 def ruby(*args) gemfile.ruby(*args) end |
#source(*args, &block) ⇒ Object
37 38 39 |
# File 'lib/appraisal/appraisal.rb', line 37 def source(*args, &block) gemfile.source(*args, &block) end |
#update(gems = [], options = {}) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/appraisal/appraisal.rb', line 88 def update(gems = [], = {}) write_gemfile unless File.exist?(gemfile_path) gem_manager = [:gem_manager] || ["gem_manager"] || [:"gem-manager"] || ["gem-manager"] manager = GemManager::Factory.create(gemfile_path, project_root, :manager => gem_manager) manager.update(gems) end |
#write_gemfile ⇒ Object
73 74 75 76 77 78 |
# File 'lib/appraisal/appraisal.rb', line 73 def write_gemfile content = ::Appraisal::Hooks.run_transform_gemfile(self, gemfile_path, generated_gemfile) File.open(gemfile_path, "w") do |file| file.write(content) end end |