Class: Spitball
- Inherits:
-
Object
- Object
- Spitball
- Includes:
- ClientCommon, Digest
- Defined in:
- lib/spitball.rb,
lib/spitball/version.rb
Defined Under Namespace
Modules: ClientCommon, Digest, Repo Classes: BundleCreationFailure, ClientError, FileLock, Remote, ServerFailure
Constant Summary collapse
- PROTOCOL_VERSION =
'1'
- PROTOCOL_HEADER =
"X-Spitball-Protocol"
- WITHOUT_HEADER =
"X-Spitball-Without"
- VERSION =
'0.7.0'
Instance Attribute Summary collapse
-
#gemfile ⇒ Object
readonly
Returns the value of attribute gemfile.
-
#gemfile_lock ⇒ Object
readonly
Returns the value of attribute gemfile_lock.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#without ⇒ Object
readonly
Returns the value of attribute without.
Class Method Summary collapse
Instance Method Summary collapse
- #cache!(sync = true) ⇒ Object
- #cached? ⇒ Boolean
-
#initialize(gemfile, gemfile_lock, options = {}) ⇒ Spitball
constructor
A new instance of Spitball.
Methods included from ClientCommon
Methods included from Digest
Constructor Details
#initialize(gemfile, gemfile_lock, options = {}) ⇒ Spitball
Returns a new instance of Spitball.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/spitball.rb', line 33 def initialize(gemfile, gemfile_lock, = {}) Spitball::Repo.make_cache_dirs @gemfile = gemfile @gemfile_lock = gemfile_lock @options = @without = [:without].is_a?(Enumerable) ? [:without].map(&:to_sym) : ([:without] ? [[:without].to_sym] : []) @parsed_lockfile, @dsl = Bundler::FakeLockfileParser.new(gemfile_lock), Bundler::FakeDsl.new(gemfile) raise "You need to run bundle install before you can use spitball" unless (@parsed_lockfile.dependencies.map{|d| d.name}.uniq.sort == @dsl.__gem_names.uniq.sort) @groups_to_install = @dsl.__groups.keys - @without end |
Instance Attribute Details
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
31 32 33 |
# File 'lib/spitball.rb', line 31 def gemfile @gemfile end |
#gemfile_lock ⇒ Object (readonly)
Returns the value of attribute gemfile_lock.
31 32 33 |
# File 'lib/spitball.rb', line 31 def gemfile_lock @gemfile_lock end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
31 32 33 |
# File 'lib/spitball.rb', line 31 def @options end |
#without ⇒ Object (readonly)
Returns the value of attribute without.
31 32 33 |
# File 'lib/spitball.rb', line 31 def without @without end |
Class Method Details
.gem_cmd ⇒ Object
20 21 22 |
# File 'lib/spitball.rb', line 20 def self.gem_cmd ENV['GEM_CMD'] || 'gem' end |
Instance Method Details
#cache!(sync = true) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/spitball.rb', line 48 def cache!(sync = true) return if cached? lock = Spitball::FileLock.new(bundle_path('lock')) if lock.acquire_lock begin create_bundle ensure lock.release_lock end elsif sync sleep 0.1 until cached? end end |
#cached? ⇒ Boolean
44 45 46 |
# File 'lib/spitball.rb', line 44 def cached? File.exist? tarball_path end |