exedb 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/exedb/version.rb +1 -1
- data/lib/exedb.rb +19 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b90d8a0eccdf874db978cd3490ff651214838103
|
4
|
+
data.tar.gz: 48d5871d5cc81292a24b946878949dc69ac21037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecafa6e021bf8974b3e8c2dc9327a4d08b742c018ce269728a452c19ebe9478776fce2088771fc438a76075525ed8e80eb9a701a59c9c76879a31eb350c55a9a
|
7
|
+
data.tar.gz: ea42ddfbebadf99450215d2eb085edca4afff791c3f8482e848f3e7d5768d2e60c2ebc885abb806079c50724a3b970d87554f9e00c8bb31c659eaa9c43e8d07b
|
data/lib/exedb/version.rb
CHANGED
data/lib/exedb.rb
CHANGED
@@ -42,7 +42,13 @@ class Exedb
|
|
42
42
|
# will be started
|
43
43
|
def update
|
44
44
|
@content=''
|
45
|
-
|
45
|
+
|
46
|
+
# create file if needed
|
47
|
+
unless File.file?(@path)
|
48
|
+
File.open(@path,File::RDWR|File::CREAT,0644){|f|}
|
49
|
+
end
|
50
|
+
|
51
|
+
File.open(@path, "r+:UTF-8") { |file|
|
46
52
|
if file.flock(File::LOCK_EX|File::LOCK_NB)
|
47
53
|
begin
|
48
54
|
IO.popen(@update_method){|pipe|
|
@@ -58,20 +64,22 @@ class Exedb
|
|
58
64
|
end
|
59
65
|
}
|
60
66
|
@code=$?.exitstatus
|
61
|
-
#warn "UPDATED: #{@content}/#{@code}"
|
62
67
|
rescue
|
63
68
|
@content=''
|
64
69
|
@code=-1
|
65
70
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
71
|
+
if @alltransform
|
72
|
+
@content=@alltransform.call(@content,@code)
|
73
|
+
file.seek(0,IO::SEEK_SET)
|
74
|
+
file.write @content
|
75
|
+
file.truncate(@content.size)
|
76
|
+
file.flush
|
77
|
+
end
|
69
78
|
File.open("#{@path}.code",File::RDWR|File::CREAT, 0644){|code_file|
|
70
79
|
code_file.puts @code
|
71
80
|
}
|
72
81
|
file.flock(File::LOCK_UN)
|
73
82
|
else
|
74
|
-
warn "CANNOT LOCK"
|
75
83
|
read_cache
|
76
84
|
end
|
77
85
|
@update_time=Time.now
|
@@ -206,13 +214,17 @@ protected
|
|
206
214
|
end
|
207
215
|
|
208
216
|
def generate_key u
|
209
|
-
|
217
|
+
f=u.tr('^qwertyuiopasdfghjklzxcvbnm_-','')
|
218
|
+
d=Digest::SHA256.hexdigest(u)
|
219
|
+
return f[0,60]+'..'+f[-60,60]+d if f.size>128
|
220
|
+
return f+d
|
210
221
|
end
|
211
222
|
|
212
223
|
def read_cache
|
213
224
|
File.open(@path, File::RDONLY) { |file|
|
214
225
|
file.flock(File::LOCK_EX)
|
215
226
|
@content=file.read
|
227
|
+
warn "CACHE READ: #{@content}"
|
216
228
|
File.open("#{@path}.code", File::RDONLY) { |code_file|
|
217
229
|
c=code_file.gets
|
218
230
|
c =~ /([0-9-]+)/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exedb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Zhumatiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|