Class: Prebundler::GitGemRef
- Inherits:
-
GemRef
- Object
- GemRef
- Prebundler::GitGemRef
show all
- Defined in:
- lib/prebundler/git_gem_ref.rb
Constant Summary
Constants inherited
from GemRef
Prebundler::GemRef::DEFAULT_SOURCE, Prebundler::GemRef::REF_TYPES
Instance Attribute Summary collapse
Attributes inherited from GemRef
#bundle_path, #dependencies, #groups, #name, #spec
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from GemRef
#add_to_tar, create, #executables, #extension_dir, #gemspec_file, #id, #install_dir, #install_from_tar, #relative_extension_dir, #relative_gem_dir, #relative_gemspec_files, #spec_path, #tar_file
Constructor Details
#initialize(name, bundle_path, options = {}) ⇒ GitGemRef
15
16
17
18
|
# File 'lib/prebundler/git_gem_ref.rb', line 15
def initialize(name, bundle_path, options = {})
super
@strategy = options.include?(:git) ? :git : :github
end
|
Instance Attribute Details
#strategy ⇒ Object
Returns the value of attribute strategy.
13
14
15
|
# File 'lib/prebundler/git_gem_ref.rb', line 13
def strategy
@strategy
end
|
Class Method Details
.accepts?(options) ⇒ Boolean
8
9
10
|
# File 'lib/prebundler/git_gem_ref.rb', line 8
def accepts?(options)
options.include?(:git) || options.include?(:github)
end
|
Instance Method Details
#cache_dir ⇒ Object
56
57
58
|
# File 'lib/prebundler/git_gem_ref.rb', line 56
def cache_dir
File.join(cache_path, "#{name}-#{uri_hash}")
end
|
#cache_path ⇒ Object
52
53
54
|
# File 'lib/prebundler/git_gem_ref.rb', line 52
def cache_path
File.join(bundle_path, 'cache', 'bundler', 'git')
end
|
#gemspecs ⇒ Object
70
71
72
73
74
|
# File 'lib/prebundler/git_gem_ref.rb', line 70
def gemspecs
@gemspecs ||= gemspec_files.map do |gemspec_file|
Bundler.load_gemspec(gemspec_file)
end
end
|
#install ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/prebundler/git_gem_ref.rb', line 20
def install
FileUtils.mkdir_p(spec_path)
FileUtils.mkdir_p(install_path)
FileUtils.mkdir_p(cache_path)
return if File.exist?(cache_dir) || File.exist?(install_dir)
system "git clone #{uri} \"#{cache_dir}\" --bare --no-hardlinks --quiet"
return $? if $?.exitstatus != 0
system "git clone --no-checkout --quiet \"#{cache_dir}\" \"#{install_dir}\""
return $? if $?.exitstatus != 0
Dir.chdir(install_dir) { system "git reset --hard --quiet #{revision}" }
serialize_gemspecs
copy_gemspecs
$?
end
|
#install_path ⇒ Object
48
49
50
|
# File 'lib/prebundler/git_gem_ref.rb', line 48
def install_path
File.join(bundle_path, 'bundler', 'gems')
end
|
#installable? ⇒ Boolean
40
41
42
|
# File 'lib/prebundler/git_gem_ref.rb', line 40
def installable?
true
end
|
#revision ⇒ Object
66
67
68
|
# File 'lib/prebundler/git_gem_ref.rb', line 66
def revision
spec.source.revision
end
|
#storable? ⇒ Boolean
44
45
46
|
# File 'lib/prebundler/git_gem_ref.rb', line 44
def storable?
false
end
|
#uri ⇒ Object
Also known as:
source
60
61
62
|
# File 'lib/prebundler/git_gem_ref.rb', line 60
def uri
spec.source.uri
end
|
#version ⇒ Object
36
37
38
|
# File 'lib/prebundler/git_gem_ref.rb', line 36
def version
revision[0...12]
end
|