parsley-store 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/features/parsley-store.feature +0 -1
- data/features/step_definitions/parsley-store_steps.rb +1 -0
- data/lib/parsley-store.rb +9 -5
- metadata +4 -4
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/parsley-store.rb
CHANGED
@@ -8,21 +8,25 @@ class ParsleyStore
|
|
8
8
|
SLAVE = 2
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
@parser = ScientificNameParser.new
|
11
|
+
@parser = ScientificNameParser.new(local_db = LOCAL, slave_db = SLAVE)
|
12
12
|
@local = Redis.new
|
13
|
-
@local.select(
|
13
|
+
@local.select(local_db)
|
14
|
+
# slave replication is not set up yet, so I comment it out
|
15
|
+
# @slave = Redis.new
|
16
|
+
# @slave.select(slave_db)
|
14
17
|
end
|
15
18
|
|
16
|
-
def parse(scientific_name)
|
19
|
+
def parse(scientific_name, fast = false)
|
17
20
|
stored = @local.get(scientific_name)
|
18
|
-
return stored if stored
|
21
|
+
return (fast ? Marshal.load(stored) : JSON.load(stored)) if stored
|
19
22
|
begin
|
20
23
|
parsed = @parser.parse(scientific_name)
|
21
24
|
rescue
|
22
25
|
@parser = ScientificNameParser.new
|
23
26
|
parsed = @parser.parse(scientific_name)
|
24
27
|
end
|
25
|
-
|
28
|
+
serialized = fast ? Marshal.dump(parsed) : parsed.to_json
|
29
|
+
@local.set scientific_name, serialized
|
26
30
|
parsed
|
27
31
|
end
|
28
32
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsley-store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dmitry Mozzherin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-13 00:00:00 -04:00
|
19
19
|
default_executable: parsley-store
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|