nix 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nix/gem-nix-command.rb +21 -14
- data/lib/nix/version.rb +1 -1
- metadata +4 -4
data/lib/nix/gem-nix-command.rb
CHANGED
@@ -48,38 +48,45 @@ class Gem::Specification
|
|
48
48
|
desc
|
49
49
|
end
|
50
50
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
def src_url
|
52
|
+
"http://production.cf.rubygems.org/gems/#{full_name}.gem"
|
53
|
+
end
|
54
|
+
|
55
|
+
@@sha256_cache = {} unless self.class_variable_defined?(:@@sha256_cache)
|
56
|
+
def sha256
|
57
|
+
cache_file = "#{ENV['HOME']}/.gem/nix-sha256.cache"
|
58
|
+
if @@sha256_cache.empty?
|
59
|
+
if FileTest.exists?(cache_file)
|
60
|
+
File.open(cache_file,'r') do |f|
|
61
|
+
@@sha256_cache = Marshal.load(f)
|
62
|
+
end
|
63
|
+
end
|
57
64
|
end
|
58
65
|
|
59
|
-
|
66
|
+
unless @@sha256_cache.key?(src_url)
|
60
67
|
tmp="/tmp/ruby-gems-nix-tmp-file"
|
61
|
-
system("nix-prefetch-url #{
|
68
|
+
system("nix-prefetch-url #{src_url.gsub(/([:= `$;])/,'\\\\\1')} > #{tmp} 2>/dev/null")
|
62
69
|
if $? == 0
|
63
70
|
file = File.new(tmp)
|
64
|
-
hash = file.readlines().first().
|
71
|
+
hash = file.readlines().first().chomp
|
65
72
|
file.close()
|
66
73
|
File.delete(tmp)
|
67
|
-
|
74
|
+
@@sha256_cache[src_url] = hash
|
68
75
|
else
|
69
|
-
|
76
|
+
@@sha256_cache[src_url] = "no hash"
|
70
77
|
end
|
71
78
|
|
72
|
-
File.open(
|
79
|
+
File.open(cache_file, "w+") do |f| Marshal.dump(@@sha256_cache, f) end
|
73
80
|
end
|
74
81
|
|
75
|
-
return
|
82
|
+
return @@sha256_cache[src_url]
|
76
83
|
end
|
77
84
|
|
78
85
|
def nix_derivation
|
79
86
|
{
|
80
87
|
:name => full_name,
|
81
88
|
:basename => nix_name(:short),
|
82
|
-
:sha256 =>
|
89
|
+
:sha256 => sha256,
|
83
90
|
:meta => nix_meta
|
84
91
|
}
|
85
92
|
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: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
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-17 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|