serrano 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +14 -0
- data/.rubocop_todo.yml +122 -0
- data/.travis.yml +7 -3
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +42 -26
- data/LICENSE +1 -1
- data/README.md +5 -0
- data/Rakefile +25 -18
- data/bin/serrano +96 -98
- data/lib/serrano.rb +112 -85
- data/lib/serrano/cn.rb +6 -8
- data/lib/serrano/cnrequest.rb +41 -27
- data/lib/serrano/error.rb +2 -0
- data/lib/serrano/faraday.rb +15 -14
- data/lib/serrano/filterhandler.rb +13 -15
- data/lib/serrano/filters.rb +72 -70
- data/lib/serrano/helpers/configuration.rb +2 -2
- data/lib/serrano/request.rb +41 -39
- data/lib/serrano/request_cursor.rb +62 -61
- data/lib/serrano/styles.rb +14 -9
- data/lib/serrano/utils.rb +16 -13
- data/lib/serrano/version.rb +3 -1
- data/serrano.gemspec +19 -17
- metadata +77 -52
- data/lib/serrano/constants.rb +0 -36
- data/lib/serrano/cursor_testing.rb +0 -52
data/lib/serrano/styles.rb
CHANGED
@@ -1,23 +1,28 @@
|
|
1
|
-
|
2
|
-
require "multi_json"
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require 'faraday'
|
4
|
+
require 'multi_json'
|
5
|
+
|
6
|
+
def fetch_styles
|
7
|
+
base = 'https://api.github.com/repos/citation-style-language/styles'
|
8
|
+
conn = Faraday.new(url: base) do |f|
|
9
|
+
f.use FaradayMiddleware::RaiseHttpException
|
10
|
+
f.adapter Faraday.default_adapter
|
11
|
+
end
|
7
12
|
args = { per_page: 1 }
|
8
13
|
tt = conn.get 'commits', args
|
9
14
|
commres = MultiJson.load(tt.body)
|
10
15
|
sha = commres[0]['sha']
|
11
|
-
sty = conn.get
|
16
|
+
sty = conn.get 'git/trees/' + sha
|
12
17
|
res = MultiJson.load(sty.body)
|
13
18
|
files = res['tree'].collect { |x| x['path'] }
|
14
|
-
matches = files.collect
|
19
|
+
matches = files.collect do |x|
|
15
20
|
if x.match('csl').nil?
|
16
21
|
nil
|
17
22
|
else
|
18
23
|
x.match('csl').string
|
19
24
|
end
|
20
|
-
|
25
|
+
end
|
21
26
|
csls = matches.compact
|
22
|
-
|
27
|
+
csls.collect { |z| z.gsub('.csl', '') }
|
23
28
|
end
|
data/lib/serrano/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
def make_ua
|
2
4
|
requa = 'Faraday/v' + Faraday::VERSION
|
3
5
|
habua = 'Serrano/v' + Serrano::VERSION
|
@@ -5,29 +7,30 @@ def make_ua
|
|
5
7
|
if Serrano.mailto
|
6
8
|
ua = ua + " (mailto:%s)" % Serrano.mailto
|
7
9
|
end
|
8
|
-
|
10
|
+
# ua += format(' (mailto:%s)', Serrano.mailto) if Serrano.mailto
|
11
|
+
ua
|
9
12
|
end
|
10
13
|
|
11
14
|
def field_query_handler(x)
|
12
|
-
|
13
|
-
|
15
|
+
tmp = x.keep_if { |z| z.match(/query_/) }
|
16
|
+
rename_query_filters(tmp)
|
14
17
|
end
|
15
18
|
|
16
19
|
def rename_query_filters(foo)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
foo = foo.tostrings
|
21
|
+
foo = foo.map { |x, y| [x.to_s.sub('container_title', 'container-title'), y] }.to_h
|
22
|
+
foo = foo.map { |x, y| [x.to_s.sub('query_', 'query.'), y] }.to_h
|
23
|
+
foo
|
21
24
|
end
|
22
25
|
|
23
26
|
class Hash
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
def tostrings
|
28
|
+
Hash[map { |(k, v)| [k.to_s, v] }]
|
29
|
+
end
|
27
30
|
end
|
28
31
|
|
29
32
|
class Hash
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
def tosymbols
|
34
|
+
Hash[map { |(k, v)| [k.to_sym, v] }]
|
35
|
+
end
|
33
36
|
end
|
data/lib/serrano/version.rb
CHANGED
data/serrano.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'serrano/version'
|
5
6
|
|
@@ -8,31 +9,32 @@ Gem::Specification.new do |s|
|
|
8
9
|
s.version = Serrano::VERSION
|
9
10
|
s.platform = Gem::Platform::RUBY
|
10
11
|
s.required_ruby_version = '>= 2.1'
|
11
|
-
s.date = '
|
12
|
-
s.summary =
|
13
|
-
s.description =
|
14
|
-
s.authors =
|
12
|
+
s.date = '2019-08-07'
|
13
|
+
s.summary = 'Crossref Client'
|
14
|
+
s.description = 'Low Level Ruby Client for the Crossref Search API'
|
15
|
+
s.authors = 'Scott Chamberlain'
|
15
16
|
s.email = 'myrmecocystus@gmail.com'
|
16
17
|
s.homepage = 'https://github.com/sckott/serrano'
|
17
18
|
s.licenses = 'MIT'
|
18
19
|
|
19
|
-
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
20
|
-
s.require_paths = [
|
20
|
+
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
s.require_paths = ['lib']
|
21
22
|
|
22
23
|
s.bindir = 'bin'
|
23
24
|
s.executables = ['serrano']
|
24
25
|
|
25
|
-
s.add_development_dependency 'bundler', '~>
|
26
|
-
s.add_development_dependency 'rake', '~> 12.3', '>= 12.3.1'
|
27
|
-
s.add_development_dependency 'test-unit', '~> 3.2', '>= 3.2.7'
|
28
|
-
s.add_development_dependency 'simplecov', '~> 0.16.1'
|
26
|
+
s.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.2'
|
29
27
|
s.add_development_dependency 'codecov', '~> 0.1.10'
|
30
28
|
s.add_development_dependency 'json', '~> 2.1'
|
31
|
-
s.add_development_dependency '
|
32
|
-
s.add_development_dependency '
|
29
|
+
s.add_development_dependency 'rake', '~> 12.3', '>= 12.3.1'
|
30
|
+
s.add_development_dependency 'rubocop', '~> 0.74.0'
|
31
|
+
s.add_development_dependency 'simplecov', '~> 0.17.0'
|
32
|
+
s.add_development_dependency 'test-unit', '~> 3.2', '>= 3.2.7'
|
33
|
+
s.add_development_dependency 'vcr', '~> 5.0'
|
34
|
+
s.add_development_dependency 'webmock', '~> 3.4', '>= 3.4.1'
|
33
35
|
|
34
|
-
s.add_runtime_dependency 'faraday', '~> 0.
|
35
|
-
s.add_runtime_dependency 'faraday_middleware', '
|
36
|
-
s.add_runtime_dependency 'thor', '~> 0.20.0'
|
36
|
+
s.add_runtime_dependency 'faraday', '~> 0.15.0'
|
37
|
+
s.add_runtime_dependency 'faraday_middleware', '>= 0.12.2', '< 0.14.0'
|
37
38
|
s.add_runtime_dependency 'multi_json', '~> 1.13', '>= 1.13.1'
|
39
|
+
s.add_runtime_dependency 'thor', '~> 0.20.0'
|
38
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chamberlain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,192 +16,218 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 2.0.2
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2.0'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 2.0.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: codecov
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 12.3.1
|
39
|
+
version: 0.1.10
|
43
40
|
type: :development
|
44
41
|
prerelease: false
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
46
43
|
requirements:
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
|
46
|
+
version: 0.1.10
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: json
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
51
52
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
53
|
+
version: '2.1'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2.1'
|
53
61
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
62
|
+
name: rake
|
55
63
|
requirement: !ruby/object:Gem::Requirement
|
56
64
|
requirements:
|
57
65
|
- - "~>"
|
58
66
|
- !ruby/object:Gem::Version
|
59
|
-
version: '3
|
67
|
+
version: '12.3'
|
60
68
|
- - ">="
|
61
69
|
- !ruby/object:Gem::Version
|
62
|
-
version: 3.
|
70
|
+
version: 12.3.1
|
63
71
|
type: :development
|
64
72
|
prerelease: false
|
65
73
|
version_requirements: !ruby/object:Gem::Requirement
|
66
74
|
requirements:
|
67
75
|
- - "~>"
|
68
76
|
- !ruby/object:Gem::Version
|
69
|
-
version: '3
|
77
|
+
version: '12.3'
|
70
78
|
- - ">="
|
71
79
|
- !ruby/object:Gem::Version
|
72
|
-
version: 3.
|
80
|
+
version: 12.3.1
|
73
81
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
82
|
+
name: rubocop
|
75
83
|
requirement: !ruby/object:Gem::Requirement
|
76
84
|
requirements:
|
77
85
|
- - "~>"
|
78
86
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.
|
87
|
+
version: 0.74.0
|
80
88
|
type: :development
|
81
89
|
prerelease: false
|
82
90
|
version_requirements: !ruby/object:Gem::Requirement
|
83
91
|
requirements:
|
84
92
|
- - "~>"
|
85
93
|
- !ruby/object:Gem::Version
|
86
|
-
version: 0.
|
94
|
+
version: 0.74.0
|
87
95
|
- !ruby/object:Gem::Dependency
|
88
|
-
name:
|
96
|
+
name: simplecov
|
89
97
|
requirement: !ruby/object:Gem::Requirement
|
90
98
|
requirements:
|
91
99
|
- - "~>"
|
92
100
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.
|
101
|
+
version: 0.17.0
|
94
102
|
type: :development
|
95
103
|
prerelease: false
|
96
104
|
version_requirements: !ruby/object:Gem::Requirement
|
97
105
|
requirements:
|
98
106
|
- - "~>"
|
99
107
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.
|
108
|
+
version: 0.17.0
|
101
109
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
110
|
+
name: test-unit
|
103
111
|
requirement: !ruby/object:Gem::Requirement
|
104
112
|
requirements:
|
105
113
|
- - "~>"
|
106
114
|
- !ruby/object:Gem::Version
|
107
|
-
version: '2
|
115
|
+
version: '3.2'
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 3.2.7
|
108
119
|
type: :development
|
109
120
|
prerelease: false
|
110
121
|
version_requirements: !ruby/object:Gem::Requirement
|
111
122
|
requirements:
|
112
123
|
- - "~>"
|
113
124
|
- !ruby/object:Gem::Version
|
114
|
-
version: '2
|
125
|
+
version: '3.2'
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 3.2.7
|
115
129
|
- !ruby/object:Gem::Dependency
|
116
130
|
name: vcr
|
117
131
|
requirement: !ruby/object:Gem::Requirement
|
118
132
|
requirements:
|
119
133
|
- - "~>"
|
120
134
|
- !ruby/object:Gem::Version
|
121
|
-
version: '
|
135
|
+
version: '5.0'
|
122
136
|
type: :development
|
123
137
|
prerelease: false
|
124
138
|
version_requirements: !ruby/object:Gem::Requirement
|
125
139
|
requirements:
|
126
140
|
- - "~>"
|
127
141
|
- !ruby/object:Gem::Version
|
128
|
-
version: '
|
142
|
+
version: '5.0'
|
129
143
|
- !ruby/object:Gem::Dependency
|
130
144
|
name: webmock
|
131
145
|
requirement: !ruby/object:Gem::Requirement
|
132
146
|
requirements:
|
133
147
|
- - "~>"
|
134
148
|
- !ruby/object:Gem::Version
|
135
|
-
version: '3.
|
149
|
+
version: '3.4'
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.4.1
|
136
153
|
type: :development
|
137
154
|
prerelease: false
|
138
155
|
version_requirements: !ruby/object:Gem::Requirement
|
139
156
|
requirements:
|
140
157
|
- - "~>"
|
141
158
|
- !ruby/object:Gem::Version
|
142
|
-
version: '3.
|
159
|
+
version: '3.4'
|
160
|
+
- - ">="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 3.4.1
|
143
163
|
- !ruby/object:Gem::Dependency
|
144
164
|
name: faraday
|
145
165
|
requirement: !ruby/object:Gem::Requirement
|
146
166
|
requirements:
|
147
167
|
- - "~>"
|
148
168
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0.
|
169
|
+
version: 0.15.0
|
150
170
|
type: :runtime
|
151
171
|
prerelease: false
|
152
172
|
version_requirements: !ruby/object:Gem::Requirement
|
153
173
|
requirements:
|
154
174
|
- - "~>"
|
155
175
|
- !ruby/object:Gem::Version
|
156
|
-
version: 0.
|
176
|
+
version: 0.15.0
|
157
177
|
- !ruby/object:Gem::Dependency
|
158
178
|
name: faraday_middleware
|
159
179
|
requirement: !ruby/object:Gem::Requirement
|
160
180
|
requirements:
|
161
|
-
- - "
|
181
|
+
- - ">="
|
162
182
|
- !ruby/object:Gem::Version
|
163
183
|
version: 0.12.2
|
184
|
+
- - "<"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 0.14.0
|
164
187
|
type: :runtime
|
165
188
|
prerelease: false
|
166
189
|
version_requirements: !ruby/object:Gem::Requirement
|
167
190
|
requirements:
|
168
|
-
- - "
|
191
|
+
- - ">="
|
169
192
|
- !ruby/object:Gem::Version
|
170
193
|
version: 0.12.2
|
194
|
+
- - "<"
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 0.14.0
|
171
197
|
- !ruby/object:Gem::Dependency
|
172
|
-
name:
|
198
|
+
name: multi_json
|
173
199
|
requirement: !ruby/object:Gem::Requirement
|
174
200
|
requirements:
|
175
201
|
- - "~>"
|
176
202
|
- !ruby/object:Gem::Version
|
177
|
-
version:
|
203
|
+
version: '1.13'
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: 1.13.1
|
178
207
|
type: :runtime
|
179
208
|
prerelease: false
|
180
209
|
version_requirements: !ruby/object:Gem::Requirement
|
181
210
|
requirements:
|
182
211
|
- - "~>"
|
183
212
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
213
|
+
version: '1.13'
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: 1.13.1
|
185
217
|
- !ruby/object:Gem::Dependency
|
186
|
-
name:
|
218
|
+
name: thor
|
187
219
|
requirement: !ruby/object:Gem::Requirement
|
188
220
|
requirements:
|
189
221
|
- - "~>"
|
190
222
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: 1.13.1
|
223
|
+
version: 0.20.0
|
195
224
|
type: :runtime
|
196
225
|
prerelease: false
|
197
226
|
version_requirements: !ruby/object:Gem::Requirement
|
198
227
|
requirements:
|
199
228
|
- - "~>"
|
200
229
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
202
|
-
- - ">="
|
203
|
-
- !ruby/object:Gem::Version
|
204
|
-
version: 1.13.1
|
230
|
+
version: 0.20.0
|
205
231
|
description: Low Level Ruby Client for the Crossref Search API
|
206
232
|
email: myrmecocystus@gmail.com
|
207
233
|
executables:
|
@@ -210,6 +236,8 @@ extensions: []
|
|
210
236
|
extra_rdoc_files: []
|
211
237
|
files:
|
212
238
|
- ".gitignore"
|
239
|
+
- ".rubocop.yml"
|
240
|
+
- ".rubocop_todo.yml"
|
213
241
|
- ".travis.yml"
|
214
242
|
- CHANGELOG.md
|
215
243
|
- CODE_OF_CONDUCT.md
|
@@ -222,8 +250,6 @@ files:
|
|
222
250
|
- lib/serrano.rb
|
223
251
|
- lib/serrano/cn.rb
|
224
252
|
- lib/serrano/cnrequest.rb
|
225
|
-
- lib/serrano/constants.rb
|
226
|
-
- lib/serrano/cursor_testing.rb
|
227
253
|
- lib/serrano/error.rb
|
228
254
|
- lib/serrano/faraday.rb
|
229
255
|
- lib/serrano/filterhandler.rb
|
@@ -254,8 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
280
|
- !ruby/object:Gem::Version
|
255
281
|
version: '0'
|
256
282
|
requirements: []
|
257
|
-
|
258
|
-
rubygems_version: 2.7.3
|
283
|
+
rubygems_version: 3.0.4
|
259
284
|
signing_key:
|
260
285
|
specification_version: 4
|
261
286
|
summary: Crossref Client
|