nix 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nix/gem-nix-command.rb +26 -24
- data/lib/nix/version.rb +1 -1
- metadata +4 -4
data/lib/nix/gem-nix-command.rb
CHANGED
@@ -55,12 +55,8 @@ class Gem::Specification
|
|
55
55
|
@@sha256_cache = {} unless self.class_variable_defined?(:@@sha256_cache)
|
56
56
|
def sha256
|
57
57
|
cache_file = "#{ENV['HOME']}/.gem/nix-sha256.cache"
|
58
|
-
if @@sha256_cache.empty?
|
59
|
-
|
60
|
-
File.open(cache_file,'r') do |f|
|
61
|
-
@@sha256_cache = Marshal.load(f)
|
62
|
-
end
|
63
|
-
end
|
58
|
+
if @@sha256_cache.empty? and FileTest.exists?(cache_file)
|
59
|
+
File.open(cache_file,'r') { |f| @@sha256_cache = Marshal.load(f) }
|
64
60
|
end
|
65
61
|
|
66
62
|
unless @@sha256_cache.key?(src_url)
|
@@ -107,7 +103,7 @@ class Gem::Commands::NixCommand < Gem::Command
|
|
107
103
|
@seen = {}
|
108
104
|
|
109
105
|
# args to dep informations
|
110
|
-
args.
|
106
|
+
args.each { |arg|
|
111
107
|
if arg =~ /(.+)-?(.*)?/ then
|
112
108
|
gem_name = $1
|
113
109
|
version = $2.empty? ? Gem::Requirement.default : Gem::Version.new($2)
|
@@ -115,12 +111,10 @@ class Gem::Commands::NixCommand < Gem::Command
|
|
115
111
|
raise Gem::CommandLineError, "couldn't parse arg. expected: name or name-version"
|
116
112
|
end
|
117
113
|
|
118
|
-
warn "adding #{gem_name}\n"
|
119
|
-
|
120
114
|
adddep(Gem::Dependency.new gem_name, version)
|
121
115
|
}
|
122
116
|
|
123
|
-
|
117
|
+
say " total: #{@gems_with_deps.length}" if Gem.configuration.really_verbose
|
124
118
|
|
125
119
|
print <<-EOF
|
126
120
|
# WARNING: automatically generated file
|
@@ -160,6 +154,7 @@ g: # Get dependencies from patched gems
|
|
160
154
|
# helper funtions ================
|
161
155
|
|
162
156
|
def adddep(dep)
|
157
|
+
say "adding dep #{dep.name}." if Gem.configuration.really_verbose
|
163
158
|
gem = find_gem_with_source(dep)
|
164
159
|
raise Gem::CommandLineError, "couldn't find #{dep}" if gem.nil?
|
165
160
|
full_name = gem[0].full_name
|
@@ -170,12 +165,10 @@ g: # Get dependencies from patched gems
|
|
170
165
|
# development deps can't be found. Some are old. Thus only add rutime dependencies
|
171
166
|
deps = gem[0].dependencies.find_all { |d| d.type == :runtime }
|
172
167
|
|
173
|
-
|
168
|
+
say " total deps of #{full_name}: #{deps.length}" if Gem.configuration.really_verbose
|
174
169
|
|
175
|
-
dep_specs = []
|
176
170
|
# recurse while collecting deps
|
177
|
-
deps.
|
178
|
-
|
171
|
+
dep_specs = deps.map { |dep| adddep(dep) }
|
179
172
|
|
180
173
|
@gems_with_deps[full_name] = [
|
181
174
|
gem[0], # spec
|
@@ -186,18 +179,27 @@ g: # Get dependencies from patched gems
|
|
186
179
|
end
|
187
180
|
|
188
181
|
|
189
|
-
# copied from
|
182
|
+
# copied from various rubygems sources, added caching to speedup subsequent executions
|
183
|
+
# TODO: develop a patch to rubygems sources that will increase speed for all users
|
190
184
|
def find_gem_with_source(dep)
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
185
|
+
if @specs_by_name.nil? or @specs_by_name.empty?
|
186
|
+
@specs_by_name = { }
|
187
|
+
f = Gem::SpecFetcher.fetcher
|
188
|
+
f.list(true, @prerelease).map do |source_uri, specs|
|
189
|
+
specs.each do |spec_name, version, spec_platform|
|
190
|
+
if Gem::Platform.match(spec_platform)
|
191
|
+
@specs_by_name[spec_name] = [] unless @specs_by_name.key?(spec_name)
|
192
|
+
@specs_by_name[spec_name].push([version, spec_platform, source_uri])
|
193
|
+
end
|
194
|
+
end
|
197
195
|
end
|
196
|
+
end
|
197
|
+
|
198
|
+
found = @specs_by_name[dep.name].select do |version, spec_platform, source_uri|
|
199
|
+
dep.match?(dep.name, version)
|
200
|
+
end
|
198
201
|
|
199
|
-
|
200
|
-
|
201
|
-
found.reverse[0]
|
202
|
+
latest = found.sort { |a, b| a.first <=> b.first }.last
|
203
|
+
[Gem::SpecFetcher.fetcher.fetch_spec([dep.name, latest.first, latest[1]], latest.last), latest.last.to_s]
|
202
204
|
end
|
203
205
|
end
|
data/lib/nix/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Yury G. Kudryashov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-18 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|