Class: Bundix::Source
- Inherits:
-
Struct
- Object
- Struct
- Bundix::Source
- Defined in:
- lib/bundix/source.rb
Instance Attribute Summary collapse
-
#fetcher ⇒ Object
Returns the value of attribute fetcher.
-
#spec ⇒ Object
Returns the value of attribute spec.
Instance Method Summary collapse
Instance Attribute Details
#fetcher ⇒ Object
Returns the value of attribute fetcher
126 127 128 |
# File 'lib/bundix/source.rb', line 126 def fetcher @fetcher end |
#spec ⇒ Object
Returns the value of attribute spec
126 127 128 |
# File 'lib/bundix/source.rb', line 126 def spec @spec end |
Instance Method Details
#convert ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/bundix/source.rb', line 127 def convert case spec.source when Bundler::Source::Rubygems convert_rubygems when Bundler::Source::Git convert_git when Bundler::Source::Path convert_path else pp spec fail 'unkown bundler source' end end |
#convert_git ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/bundix/source.rb', line 160 def convert_git revision = spec.source..fetch('revision') uri = spec.source..fetch('uri') submodules = !!spec.source.submodules output = fetcher.nix_prefetch_git(uri, revision, submodules: submodules) # FIXME: this is a hack, we should separate $stdout/$stderr in the sh call hash = JSON.parse(output[/({[^}]+})\s*\z/m])['sha256'] fail "couldn't fetch hash for #{spec.full_name}" unless hash puts "#{hash} => #{uri}" if $VERBOSE { type: 'git', url: uri.to_s, rev: revision, sha256: hash, fetchSubmodules: submodules } end |
#convert_path ⇒ Object
141 142 143 144 145 146 |
# File 'lib/bundix/source.rb', line 141 def convert_path { type: "path", path: spec.source.path } end |
#convert_rubygems ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/bundix/source.rb', line 148 def convert_rubygems remotes = spec.source.remotes.map{|remote| remote.to_s.sub(/\/+$/, '') } hash = fetcher.fetch_local_hash(spec) remote, hash = fetcher.fetch_remotes_hash(spec, remotes) unless hash fail "couldn't fetch hash for #{spec.full_name}" unless hash puts "#{hash} => #{spec.full_name}.gem" if $VERBOSE { type: 'gem', remotes: (remote ? [remote] : remotes), sha256: hash } end |