anystyle-parser 0.4.1 → 0.4.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c9fa55f1ed5e371c241610ef5d77ae1f9696131
4
- data.tar.gz: 7e6e3d024694dc1e8947bca12a9eb248f356c3cd
3
+ metadata.gz: 8666703d3ea27d897c399e81b827f3f72e076219
4
+ data.tar.gz: f4e2e995daa62706f96743e4345f253e3d3d5695
5
5
  SHA512:
6
- metadata.gz: c6ab99a896fbe1cbc5e7ab2a9ab729c289a052ff1b98a7e870ace9260519ea9500284a05e89acf8752548a7972bf629529fb17e2e967bb4d87f75a36615638ad
7
- data.tar.gz: 4f75412d5bfd364e492ffc6c83b2e77d4853d75359f5824fc556daa658138db46c3aa391600f03d247c15b272088ba300eb354cafeac57e6e1f088885930334f
6
+ metadata.gz: 12fde4b9f68e8b408f40db60cd036beac0eaefd52cd10c84a2a58b494c5ed64d9dc5fa3896d50ea140e5ddea3dcf8ad8f92bde9b9d6c1d70b4dc993ceb3a051d
7
+ data.tar.gz: fe229c1f242ecb9dd6d77823985abc4b80fe04947d3f3da0f87de63a8478cde03c80649fcd6ae6d71482d5a2caaac589849efe5ccb5770feee7fe2125f9f0523
data/Gemfile CHANGED
@@ -30,6 +30,7 @@ end
30
30
  group :redis do
31
31
  gem 'redis'
32
32
  gem 'hiredis'
33
+ gem 'redis-namespace'
33
34
  end
34
35
 
35
36
  group :kyoto do
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.4.2 / 2014-03-08
2
+ ==================
3
+ * Add redis-namespace support
4
+
1
5
  0.4.1 / 2014-03-03
2
6
  ==================
3
7
  * Normalizer tweaks
data/README.md CHANGED
@@ -39,10 +39,9 @@ Dictionary's options:
39
39
 
40
40
  Starting with version 0.1.0, Anystyle-Parser also supports
41
41
  [Redis](http://redis.io); to use Redis as the data store you need to install
42
- the `redis` gem (and, optionally, the `hiredis` gem).
42
+ the `redis` and `redis-namespace` gems (optionally, the `hiredis` gem).
43
43
 
44
- $ [sudo] gem install hiredis
45
- $ [sudo] gem install redis
44
+ $ [sudo] gem install redis redis-namespace
46
45
 
47
46
  To see which data store modes are available in you current environment,
48
47
  check the output of `Dictionary.modes`:
@@ -52,14 +51,14 @@ check the output of `Dictionary.modes`:
52
51
 
53
52
  To select one of the available modes, use the dictionary instance options:
54
53
 
55
- > Anystyle::Parser::Dictionary.instance.options[:mode]
54
+ > Anystyle.dictionary.options[:mode]
56
55
  => :kyoto
57
56
 
58
57
  To use [Redis](http://redis.io) you also need to set the host or unix socket
59
58
  where your redis server is available. For example:
60
59
 
61
- Anystyle::Parser::Dictionary.instance.options[:mode] = :redis
62
- Anystyle::Parser::Dictionary.instance.options[:host] = 'localhost'
60
+ Anystyle.dictionary.options[:mode] = :redis
61
+ Anystyle.dictionary.options[:host] = 'localhost'
63
62
 
64
63
  When the data store is opened using redis-mode and the data store is empty,
65
64
  the feature dictionary will be imported automatically. If you want to import
@@ -64,6 +64,9 @@ module Anystyle
64
64
  begin
65
65
  require 'redis'
66
66
  @modes.push :redis
67
+
68
+ require 'redis/namespace'
69
+
67
70
  rescue LoadError
68
71
  # info 'no redis support detected'
69
72
  end
@@ -79,6 +82,7 @@ module Anystyle
79
82
  :mode => @modes[0],
80
83
  :source => File.expand_path('../support/dict.txt.gz', __FILE__),
81
84
  :cabinet => File.expand_path('../support/dict.kch', __FILE__),
85
+ :namespace => 'anystyle',
82
86
  :port => 6379
83
87
  }.freeze
84
88
 
@@ -93,6 +97,10 @@ module Anystyle
93
97
  @options = Dictionary.defaults.dup
94
98
  end
95
99
 
100
+ def config(&block)
101
+ block[options]
102
+ end
103
+
96
104
  def [](key)
97
105
  db[key.to_s].to_i
98
106
  end
@@ -112,11 +120,6 @@ module Anystyle
112
120
  populate
113
121
  close
114
122
 
115
- when :redis
116
- @db ||= Redis.new(options)
117
- populate
118
- close
119
-
120
123
  else
121
124
  # nothing
122
125
  end
@@ -130,7 +133,7 @@ module Anystyle
130
133
  def open
131
134
  case options[:mode]
132
135
  when :kyoto
133
- at_exit { ::Anystyle::Parser::Dictionary.instance.close }
136
+ at_exit { Anystyle.dictionary.close }
134
137
 
135
138
  create unless File.exists?(path)
136
139
 
@@ -140,10 +143,14 @@ module Anystyle
140
143
  end
141
144
 
142
145
  when :redis
143
- at_exit { ::Anystyle::Parser::Dictionary.instance.close }
146
+ at_exit { Anystyle.dictionary.close }
144
147
  @db = Redis.new(options)
145
148
 
146
- populate if @db.dbsize.zero?
149
+ if options[:namespace] && defined?(Redis::Namespace)
150
+ @db = Redis::Namespace.new options[:namespace], :redis => @db
151
+ end
152
+
153
+ populate unless populated?
147
154
 
148
155
  else
149
156
  @db = Hash.new(0)
@@ -153,7 +160,7 @@ module Anystyle
153
160
  @db
154
161
  end
155
162
 
156
- def open?; !!@db; end
163
+ def open?() !!@db end
157
164
 
158
165
  def close
159
166
  case
@@ -177,6 +184,10 @@ module Anystyle
177
184
  end
178
185
  end
179
186
 
187
+ def populated?
188
+ !!self['__created_at']
189
+ end
190
+
180
191
  private
181
192
 
182
193
  def db
@@ -219,6 +230,7 @@ module Anystyle
219
230
  end
220
231
  end
221
232
 
233
+ self['__created_at'] = Time.now.to_s
222
234
  end
223
235
 
224
236
  end
@@ -8,6 +8,10 @@ module Anystyle
8
8
  Parser::Parser.instance
9
9
  end
10
10
 
11
+ def self.dictionary
12
+ Parser::Dictionary.instance
13
+ end
14
+
11
15
  module Parser
12
16
 
13
17
  def self.instance
@@ -1,5 +1,5 @@
1
1
  module Anystyle
2
2
  module Parser
3
- VERSION = '0.4.1'.freeze
3
+ VERSION = '0.4.2'.freeze
4
4
  end
5
5
  end
@@ -5,6 +5,7 @@ require 'bibtex'
5
5
  require 'wapiti'
6
6
  require 'namae'
7
7
 
8
+ require 'anystyle/parser/version'
8
9
  require 'anystyle/parser/errors'
9
10
 
10
11
  require 'anystyle/parser/dictionary'
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anystyle-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvester Keil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-03 00:00:00.000000000 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bibtex-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: wapiti
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: namae
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.8'
55
55
  description: A sophisticated parser for academic reference lists and bibliographies
@@ -96,27 +96,27 @@ licenses:
96
96
  metadata: {}
97
97
  post_install_message:
98
98
  rdoc_options:
99
- - --line-numbers
100
- - --inline-source
101
- - --title
102
- - '"Anystyle Parser"'
103
- - --main
99
+ - "--line-numbers"
100
+ - "--inline-source"
101
+ - "--title"
102
+ - "\"Anystyle Parser\""
103
+ - "--main"
104
104
  - README.md
105
105
  require_paths:
106
106
  - lib
107
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: 1.9.3
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - '>='
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.0.14
119
+ rubygems_version: 2.2.2
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Smart and fast academic bibliography parser.