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 CHANGED
@@ -1 +1 @@
1
- 0.1.2
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
- @conn.select(eval("ParsleyStore::#{slave}")).should == "OK"
13
- @conn.select(eval("ParsleyStore::#{local}")).should == "OK"
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(ParsleyStore::LOCAL)
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|
@@ -16,16 +16,16 @@ class ParsleyStore
16
16
  # @slave.select(slave_db)
17
17
  end
18
18
 
19
- def parse(scientific_name, fast = false)
19
+ def parse(scientific_name)
20
20
  stored = @local.get(scientific_name)
21
- return (fast ? Marshal.load(stored) : JSON.load(stored)) if stored
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 = fast ? Marshal.dump(parsed) : parsed.to_json
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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dmitry Mozzherin