parsley-store 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/features/step_definitions/parsley-store_steps.rb +6 -4
- data/lib/parsley-store.rb +3 -3
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -9,17 +9,19 @@ Given /^Redis server is running locally$/ do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Then /^I get "([^"]*)" and "([^"]*)" databases connection$/ do |local, slave|
|
12
|
-
@
|
13
|
-
@
|
12
|
+
@local_db = 10
|
13
|
+
@slave_db = 11
|
14
|
+
@conn.select(@slave_db).should == "OK"
|
15
|
+
@conn.select(@local_db).should == "OK"
|
14
16
|
lambda { @conn.select(200) }.should raise_error
|
15
17
|
end
|
16
18
|
|
17
19
|
Given /^a clean local database$/ do
|
18
20
|
@conn = Redis.new
|
19
|
-
@conn.select(
|
21
|
+
@conn.select(@local_db)
|
20
22
|
@conn.flushdb
|
21
23
|
@conn.dbsize.should == 0
|
22
|
-
@parser = ParsleyStore.new
|
24
|
+
@parser = ParsleyStore.new(@local_db, @slave_db)
|
23
25
|
end
|
24
26
|
|
25
27
|
When /^I parse a name "([^"]*)" two times$/ do |name|
|
data/lib/parsley-store.rb
CHANGED
@@ -16,16 +16,16 @@ class ParsleyStore
|
|
16
16
|
# @slave.select(slave_db)
|
17
17
|
end
|
18
18
|
|
19
|
-
def parse(scientific_name
|
19
|
+
def parse(scientific_name)
|
20
20
|
stored = @local.get(scientific_name)
|
21
|
-
return
|
21
|
+
return JSON.parse(stored, :symbolize_names => true) if stored
|
22
22
|
begin
|
23
23
|
parsed = @parser.parse(scientific_name)
|
24
24
|
rescue
|
25
25
|
@parser = ScientificNameParser.new
|
26
26
|
parsed = @parser.parse(scientific_name)
|
27
27
|
end
|
28
|
-
serialized =
|
28
|
+
serialized = parsed.to_json
|
29
29
|
@local.set scientific_name, serialized
|
30
30
|
parsed
|
31
31
|
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: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dmitry Mozzherin
|