Class: Appraisal::Appraisal
- Inherits:
-
Object
- Object
- Appraisal::Appraisal
- Defined in:
- lib/appraisal/appraisal.rb
Overview
Represents one appraisal and its dependencies
Constant Summary collapse
- DEFAULT_INSTALL_OPTIONS =
{ "jobs" => 1 }.freeze
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
- #git_source(*args, &block) ⇒ Object
- #group(*args, &block) ⇒ Object
-
#initialize(name, source_gemfile) ⇒ Appraisal
constructor
A new instance of Appraisal.
- #install(options = {}) ⇒ 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 = []) ⇒ Object
- #write_gemfile ⇒ Object
Constructor Details
#initialize(name, source_gemfile) ⇒ Appraisal
Returns a new instance of Appraisal.
14 15 16 17 |
# File 'lib/appraisal/appraisal.rb', line 14 def initialize(name, source_gemfile) @name = name @gemfile = source_gemfile.dup end |
Instance Attribute Details
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
12 13 14 |
# File 'lib/appraisal/appraisal.rb', line 12 def gemfile @gemfile end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/appraisal/appraisal.rb', line 12 def name @name end |
Instance Method Details
#gem(*args) ⇒ Object
19 20 21 |
# File 'lib/appraisal/appraisal.rb', line 19 def gem(*args) gemfile.gem(*args) end |
#gemfile_path ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/appraisal/appraisal.rb', line 87 def gemfile_path unless gemfile_root.exist? gemfile_root.mkdir end gemfile_root.join(gemfile_name).to_s end |
#gemspec(options = {}) ⇒ Object
51 52 53 |
# File 'lib/appraisal/appraisal.rb', line 51 def gemspec( = {}) gemfile.gemspec() end |
#git(*args, &block) ⇒ Object
35 36 37 |
# File 'lib/appraisal/appraisal.rb', line 35 def git(*args, &block) gemfile.git(*args, &block) end |
#git_source(*args, &block) ⇒ Object
55 56 57 |
# File 'lib/appraisal/appraisal.rb', line 55 def git_source(*args, &block) gemfile.git_source(*args, &block) end |
#group(*args, &block) ⇒ Object
43 44 45 |
# File 'lib/appraisal/appraisal.rb', line 43 def group(*args, &block) gemfile.group(*args, &block) end |
#install(options = {}) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/appraisal/appraisal.rb', line 66 def install( = {}) commands = [install_command().join(" ")] if ["without"].nil? || ["without"].empty? commands.unshift(check_command.join(" ")) end command = commands.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
39 40 41 |
# File 'lib/appraisal/appraisal.rb', line 39 def path(*args, &block) gemfile.path(*args, &block) end |
#platforms(*args, &block) ⇒ Object
47 48 49 |
# File 'lib/appraisal/appraisal.rb', line 47 def platforms(*args, &block) gemfile.platforms(*args, &block) end |
#relative_gemfile_path ⇒ Object
95 96 97 |
# File 'lib/appraisal/appraisal.rb', line 95 def relative_gemfile_path File.join("gemfiles", gemfile_name) end |
#relativize ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'lib/appraisal/appraisal.rb', line 99 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 |
#remove_gem(*args) ⇒ Object
23 24 25 |
# File 'lib/appraisal/appraisal.rb', line 23 def remove_gem(*args) gemfile.remove_gem(*args) end |
#ruby(*args) ⇒ Object
31 32 33 |
# File 'lib/appraisal/appraisal.rb', line 31 def ruby(*args) gemfile.ruby(*args) end |
#source(*args, &block) ⇒ Object
27 28 29 |
# File 'lib/appraisal/appraisal.rb', line 27 def source(*args, &block) gemfile.source(*args, &block) end |
#update(gems = []) ⇒ Object
83 84 85 |
# File 'lib/appraisal/appraisal.rb', line 83 def update(gems = []) Command.new(update_command(gems), :gemfile => gemfile_path).run end |
#write_gemfile ⇒ Object
59 60 61 62 63 64 |
# File 'lib/appraisal/appraisal.rb', line 59 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 |