Class: Prebundler::GemRef
- Inherits:
-
Object
- Object
- Prebundler::GemRef
- Defined in:
- lib/prebundler/gem_ref.rb
Direct Known Subclasses
Constant Summary collapse
- REF_TYPES =
[PathGemRef, GitGemRef]
- DEFAULT_SOURCE =
'https://rubygems.org'
Instance Attribute Summary collapse
-
#bundle_path ⇒ Object
readonly
Returns the value of attribute bundle_path.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#spec ⇒ Object
Returns the value of attribute spec.
Class Method Summary collapse
Instance Method Summary collapse
- #add_to_tar(tar_file) ⇒ Object
- #executables ⇒ Object
- #extension_dir ⇒ Object
- #gemspec_file ⇒ Object
- #gemspecs ⇒ Object
- #id ⇒ Object
-
#initialize(name, bundle_path, options = {}) ⇒ GemRef
constructor
A new instance of GemRef.
- #install ⇒ Object
- #install_dir ⇒ Object
- #install_from_tar(tar_file) ⇒ Object
- #install_path ⇒ Object
- #installable? ⇒ Boolean
- #relative_extension_dir ⇒ Object
- #relative_gem_dir ⇒ Object
- #relative_gemspec_files ⇒ Object
- #source ⇒ Object
- #spec_path ⇒ Object
- #storable? ⇒ Boolean
- #tar_file ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(name, bundle_path, options = {}) ⇒ GemRef
Returns a new instance of GemRef.
19 20 21 22 23 24 25 |
# File 'lib/prebundler/gem_ref.rb', line 19 def initialize(name, bundle_path, = {}) @name = name @bundle_path = bundle_path @groups = Set.new([:groups]) @source = [:source] @dependencies = [:dependencies] end |
Instance Attribute Details
#bundle_path ⇒ Object (readonly)
Returns the value of attribute bundle_path.
16 17 18 |
# File 'lib/prebundler/gem_ref.rb', line 16 def bundle_path @bundle_path end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
17 18 19 |
# File 'lib/prebundler/gem_ref.rb', line 17 def dependencies @dependencies end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
16 17 18 |
# File 'lib/prebundler/gem_ref.rb', line 16 def groups @groups end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/prebundler/gem_ref.rb', line 16 def name @name end |
#spec ⇒ Object
Returns the value of attribute spec.
17 18 19 |
# File 'lib/prebundler/gem_ref.rb', line 17 def spec @spec end |
Class Method Details
.create(name, bundle_path, options = {}) ⇒ Object
10 11 12 13 |
# File 'lib/prebundler/gem_ref.rb', line 10 def create(name, bundle_path, = {}) ref_type = REF_TYPES.find { |rt| rt.accepts?() } || self ref_type.new(name, bundle_path, ) end |
Instance Method Details
#add_to_tar(tar_file) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/prebundler/gem_ref.rb', line 53 def add_to_tar(tar_file) tar_flags = File.exist?(tar_file) ? '-rf' : '-cf' system "tar -C #{bundle_path} #{tar_flags} #{tar_file} #{relative_gem_dir}" relative_gemspec_files.each do |relative_gemspec_file| system "tar -C #{bundle_path} -rf #{tar_file} #{relative_gemspec_file}" end if File.directory?(extension_dir) system "tar -C #{bundle_path} -rf #{tar_file} #{relative_extension_dir}" end executables.each do |executable| system "tar -C #{bundle_path} -rf #{tar_file} #{File.join('bin', executable)}" end end |
#executables ⇒ Object
71 72 73 |
# File 'lib/prebundler/gem_ref.rb', line 71 def executables gemspecs.flat_map(&:executables) end |
#extension_dir ⇒ Object
101 102 103 |
# File 'lib/prebundler/gem_ref.rb', line 101 def extension_dir File.join(bundle_path, relative_extension_dir) end |
#gemspec_file ⇒ Object
121 122 123 |
# File 'lib/prebundler/gem_ref.rb', line 121 def gemspec_file "#{id}.gemspec" end |
#gemspecs ⇒ Object
75 76 77 78 79 |
# File 'lib/prebundler/gem_ref.rb', line 75 def gemspecs @gemspecs ||= relative_gemspec_files.map do |relative_gemspec_file| Bundler.load_gemspec(File.join(bundle_path, relative_gemspec_file)) end end |
#id ⇒ Object
35 36 37 |
# File 'lib/prebundler/gem_ref.rb', line 35 def id "#{name}-#{version}" end |
#install ⇒ Object
43 44 45 46 |
# File 'lib/prebundler/gem_ref.rb', line 43 def install system({ "GEM_HOME" => bundle_path }, "gem install -N --ignore-dependencies --source #{source} #{name} -v #{version}") $?.exitstatus end |
#install_dir ⇒ Object
97 98 99 |
# File 'lib/prebundler/gem_ref.rb', line 97 def install_dir File.join(install_path, id) end |
#install_from_tar(tar_file) ⇒ Object
48 49 50 51 |
# File 'lib/prebundler/gem_ref.rb', line 48 def install_from_tar(tar_file) system "tar -C #{bundle_path} -xf #{tar_file}" $?.exitstatus == 0 end |
#install_path ⇒ Object
89 90 91 |
# File 'lib/prebundler/gem_ref.rb', line 89 def install_path File.join(bundle_path, 'gems') end |
#installable? ⇒ Boolean
81 82 83 |
# File 'lib/prebundler/gem_ref.rb', line 81 def installable? true end |
#relative_extension_dir ⇒ Object
105 106 107 |
# File 'lib/prebundler/gem_ref.rb', line 105 def relative_extension_dir File.join('extensions', Bundler.local_platform.to_s, Gem.extension_api_version.to_s, id) end |
#relative_gem_dir ⇒ Object
109 110 111 |
# File 'lib/prebundler/gem_ref.rb', line 109 def relative_gem_dir File.join('gems', id) end |
#relative_gemspec_files ⇒ Object
113 114 115 |
# File 'lib/prebundler/gem_ref.rb', line 113 def relative_gemspec_files [File.join('specifications', gemspec_file)] end |
#source ⇒ Object
31 32 33 |
# File 'lib/prebundler/gem_ref.rb', line 31 def source @source ||= DEFAULT_SOURCE end |
#spec_path ⇒ Object
93 94 95 |
# File 'lib/prebundler/gem_ref.rb', line 93 def spec_path File.join(bundle_path, 'specifications') end |
#storable? ⇒ Boolean
85 86 87 |
# File 'lib/prebundler/gem_ref.rb', line 85 def storable? true end |
#tar_file ⇒ Object
117 118 119 |
# File 'lib/prebundler/gem_ref.rb', line 117 def tar_file File.join(Bundler.local_platform.to_s, Gem.extension_api_version.to_s, "#{id}.tar") end |
#version ⇒ Object
39 40 41 |
# File 'lib/prebundler/gem_ref.rb', line 39 def version spec.version.to_s end |