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
- #relativize ⇒ Object
- #ruby(*args) ⇒ Object
- #source(*args) ⇒ 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
64 65 66 67 68 69 70 |
# File 'lib/appraisal/appraisal.rb', line 64 def gemfile_path unless gemfile_root.exist? gemfile_root.mkdir end gemfile_root.join("#{clean_name}.gemfile").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 |
# File 'lib/appraisal/appraisal.rb', line 56 def install(job_size = 1) Command.new(check_command + ' || ' + install_command(job_size)).run 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 |
#relativize ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/appraisal/appraisal.rb', line 72 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) ⇒ Object
21 22 23 |
# File 'lib/appraisal/appraisal.rb', line 21 def source(*args) gemfile.source(*args) end |
#update(gems = []) ⇒ Object
60 61 62 |
# File 'lib/appraisal/appraisal.rb', line 60 def update(gems = []) Command.new(update_command(gems)).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].reject {|s| s.empty? }.join("\n\n")) end end |