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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e329983c57815e197e683e64cf0a55300ede36bec3ada9a58612d4abd209f02a
4
- data.tar.gz: 25dbce2ee336448219f50ea8e669da1bab787ccdd535f86d59c3aece3798fc71
3
+ metadata.gz: efab429b63ceee803e97a3ab2dab647bc9ad606fcb03df713f52075696403687
4
+ data.tar.gz: e0f90a7ae6ccbe78788b4e4d12afac66ea7f73da84503cff6d8cdb3046ec893f
5
5
  SHA512:
6
- metadata.gz: ffaf70de61b00919b7418125f73e23b34195445de5fcb23d9b32793e30d5d4971ba266e1d8421c76cef6f1e824b6ee87e6235f23a7fb3945f2c5447eea351f8d
7
- data.tar.gz: ab93cece3c5e5661bedcf06812ff28276e192fc54a648b0e97902799cabc333ea5d14d51f67a60ef6b83555aabade56a19b5b664152ca1eef0bc2d4667ba217f
6
+ metadata.gz: f2af2d7a4e358423df3a4452e7091ba1b46c82110a30345ee83db401a14392cff49ab2e253d06562cc0f89011e815a7150ae97d53347d5f96d67dbfd761b9b8b
7
+ data.tar.gz: ec19825f8e798113ef2923cc0945721675f8dc37ab1b0a3cc7aeb3234ce71d4bf9fa6697670d69cc33f730560927cf1e45169b5b67691eb82992054b600cdaff
data/.gitignore CHANGED
@@ -36,3 +36,5 @@ build/
36
36
  cache/
37
37
 
38
38
  lib/serrano/response.rb
39
+
40
+ cursor_testing.rb
@@ -0,0 +1,14 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Naming/FileName:
4
+ Exclude:
5
+ - 'test/test-helper.rb'
6
+
7
+ Metrics/ParameterLists:
8
+ Max: 18
9
+
10
+ # Offense count: 22
11
+ # Configuration parameters: AllowedVariables.
12
+ Lint/UselessAssignment:
13
+ Exclude:
14
+ - 'lib/serrano/filters.rb'
@@ -0,0 +1,122 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-12-18 19:46:09 -0800 using RuboCop version 0.61.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: Include.
11
+ # Include: **/*.gemspec
12
+ Gemspec/RequiredRubyVersion:
13
+ Exclude:
14
+ - 'serrano.gemspec'
15
+
16
+ # Offense count: 32
17
+ Metrics/AbcSize:
18
+ Max: 91
19
+
20
+ # Offense count: 1
21
+ # Configuration parameters: CountComments, ExcludedMethods.
22
+ # ExcludedMethods: refine
23
+ Metrics/BlockLength:
24
+ Max: 28
25
+
26
+ # Offense count: 1
27
+ # Configuration parameters: CountBlocks.
28
+ Metrics/BlockNesting:
29
+ Max: 4
30
+
31
+ # Offense count: 2
32
+ # Configuration parameters: CountComments.
33
+ Metrics/ClassLength:
34
+ Max: 367
35
+
36
+ # Offense count: 5
37
+ Metrics/CyclomaticComplexity:
38
+ Max: 11
39
+
40
+ # Offense count: 20
41
+ # Configuration parameters: CountComments, ExcludedMethods.
42
+ Metrics/MethodLength:
43
+ Max: 54
44
+
45
+ # Offense count: 8
46
+ Metrics/PerceivedComplexity:
47
+ Max: 15
48
+
49
+ # Offense count: 7
50
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
51
+ # AllowedNames: io, id, to, by, on, in, at, ip, db
52
+ Naming/UncommunicativeMethodParamName:
53
+ Exclude:
54
+ - 'lib/serrano/filterhandler.rb'
55
+ - 'lib/serrano/request_cursor.rb'
56
+ - 'lib/serrano/utils.rb'
57
+
58
+ # Offense count: 3
59
+ # Cop supports --auto-correct.
60
+ # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
61
+ # SupportedStyles: assign_to_condition, assign_inside_condition
62
+ Style/ConditionalAssignment:
63
+ Exclude:
64
+ - 'bin/serrano'
65
+
66
+ # Offense count: 6
67
+ Style/Documentation:
68
+ Exclude:
69
+ - 'spec/**/*'
70
+ - 'test/**/*'
71
+ - 'bin/serrano'
72
+ - 'lib/serrano.rb'
73
+ - 'lib/serrano/cn.rb'
74
+ - 'lib/serrano/filters.rb'
75
+ - 'lib/serrano/utils.rb'
76
+
77
+ # Offense count: 1
78
+ # Cop supports --auto-correct.
79
+ # Configuration parameters: EnforcedStyle.
80
+ # SupportedStyles: format, sprintf, percent
81
+ Style/FormatString:
82
+ Exclude:
83
+ - 'lib/serrano/utils.rb'
84
+
85
+ # Offense count: 1
86
+ # Configuration parameters: .
87
+ # SupportedStyles: annotated, template, unannotated
88
+ Style/FormatStringToken:
89
+ EnforcedStyle: unannotated
90
+
91
+ # Offense count: 1
92
+ # Configuration parameters: MinBodyLength.
93
+ Style/GuardClause:
94
+ Exclude:
95
+ - 'lib/serrano/response.rb'
96
+
97
+ # Offense count: 3
98
+ # Cop supports --auto-correct.
99
+ Style/IfUnlessModifier:
100
+ Exclude:
101
+ - 'lib/serrano/cnrequest.rb'
102
+ - 'lib/serrano/utils.rb'
103
+
104
+ # Offense count: 1
105
+ # Cop supports --auto-correct.
106
+ Style/SelfAssignment:
107
+ Exclude:
108
+ - 'lib/serrano/utils.rb'
109
+
110
+ # Offense count: 1
111
+ # Cop supports --auto-correct.
112
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
113
+ # SupportedStyles: single_quotes, double_quotes
114
+ Style/StringLiterals:
115
+ Exclude:
116
+ - 'lib/serrano/utils.rb'
117
+
118
+ # Offense count: 198
119
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
120
+ # URISchemes: http, https
121
+ Metrics/LineLength:
122
+ Max: 525
@@ -1,8 +1,12 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.1.8
5
- - 2.2.4
6
4
  - 2.5.0
5
+ - 2.6.0
6
+ before_install:
7
+ - gem update --system
8
+ - gem install bundler
9
+ - gem --version
7
10
  script:
8
- bundle exec rake test TESTOPTS="-v"
11
+ - bundle exec rake test TESTOPTS="-v"
12
+ - bundle exec rubocop
@@ -1,3 +1,8 @@
1
+ ## 0.5.2 (2019-08-07)
2
+
3
+ * fix url encoding (#51)
4
+ * started using Rubocop; many styling changes (#52)
5
+
1
6
  ## 0.5.0 (2018-04-08)
2
7
 
3
8
  * Updated dependency versions
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
@@ -1,64 +1,80 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- serrano (0.5.0)
5
- faraday (~> 0.14.0)
6
- faraday_middleware (~> 0.12.2)
4
+ serrano (0.5.2)
5
+ faraday (~> 0.15.0)
6
+ faraday_middleware (>= 0.12.2, < 0.14.0)
7
7
  multi_json (~> 1.13, >= 1.13.1)
8
8
  thor (~> 0.20.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- addressable (2.5.2)
13
+ addressable (2.6.0)
14
14
  public_suffix (>= 2.0.2, < 4.0)
15
- codecov (0.1.10)
15
+ ast (2.4.0)
16
+ codecov (0.1.14)
16
17
  json
17
18
  simplecov
18
19
  url
19
20
  crack (0.4.3)
20
21
  safe_yaml (~> 1.0.0)
21
- docile (1.3.0)
22
- faraday (0.14.0)
22
+ docile (1.3.2)
23
+ faraday (0.15.4)
23
24
  multipart-post (>= 1.2, < 3)
24
- faraday_middleware (0.12.2)
25
+ faraday_middleware (0.13.1)
25
26
  faraday (>= 0.7.4, < 1.0)
26
- hashdiff (0.3.7)
27
- json (2.1.0)
27
+ hashdiff (1.0.0)
28
+ jaro_winkler (1.5.3)
29
+ json (2.2.0)
28
30
  multi_json (1.13.1)
29
- multipart-post (2.0.0)
30
- power_assert (1.1.1)
31
- public_suffix (3.0.2)
32
- rake (12.3.1)
33
- safe_yaml (1.0.4)
34
- simplecov (0.16.1)
31
+ multipart-post (2.1.1)
32
+ parallel (1.17.0)
33
+ parser (2.6.3.0)
34
+ ast (~> 2.4.0)
35
+ power_assert (1.1.4)
36
+ public_suffix (3.1.1)
37
+ rainbow (3.0.0)
38
+ rake (12.3.3)
39
+ rubocop (0.74.0)
40
+ jaro_winkler (~> 1.5.1)
41
+ parallel (~> 1.10)
42
+ parser (>= 2.6)
43
+ rainbow (>= 2.2.2, < 4.0)
44
+ ruby-progressbar (~> 1.7)
45
+ unicode-display_width (>= 1.4.0, < 1.7)
46
+ ruby-progressbar (1.10.1)
47
+ safe_yaml (1.0.5)
48
+ simplecov (0.17.0)
35
49
  docile (~> 1.1)
36
50
  json (>= 1.8, < 3)
37
51
  simplecov-html (~> 0.10.0)
38
52
  simplecov-html (0.10.2)
39
- test-unit (3.2.7)
53
+ test-unit (3.3.3)
40
54
  power_assert
41
- thor (0.20.0)
55
+ thor (0.20.3)
56
+ unicode-display_width (1.6.0)
42
57
  url (0.3.2)
43
- vcr (4.0.0)
44
- webmock (3.3.0)
58
+ vcr (5.0.0)
59
+ webmock (3.6.2)
45
60
  addressable (>= 2.3.6)
46
61
  crack (>= 0.3.2)
47
- hashdiff
62
+ hashdiff (>= 0.4.0, < 2.0.0)
48
63
 
49
64
  PLATFORMS
50
65
  ruby
51
66
 
52
67
  DEPENDENCIES
53
- bundler (~> 1.16, >= 1.16.1)
68
+ bundler (~> 2.0, >= 2.0.2)
54
69
  codecov (~> 0.1.10)
55
70
  json (~> 2.1)
56
71
  rake (~> 12.3, >= 12.3.1)
72
+ rubocop (~> 0.74.0)
57
73
  serrano!
58
- simplecov (~> 0.16.1)
74
+ simplecov (~> 0.17.0)
59
75
  test-unit (~> 3.2, >= 3.2.7)
60
- vcr (~> 4.0)
61
- webmock (~> 3.3)
76
+ vcr (~> 5.0)
77
+ webmock (~> 3.4, >= 3.4.1)
62
78
 
63
79
  BUNDLED WITH
64
- 1.16.1
80
+ 2.0.2
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2018 Scott Chamberlain
1
+ Copyright (C) 2019 Scott Chamberlain
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
data/README.md CHANGED
@@ -60,6 +60,11 @@ To get in the polite pool it's a good idea now to include a `mailto` email
60
60
  address. See docs for more information. TLDR: set your email in an env var `CROSSREF_EMAIL`.
61
61
 
62
62
 
63
+ URL Encoding:
64
+
65
+ We do URL encoding of DOIs for you for all methods except `Serrano.citation_count` which doesn't work if you encode DOIs beforehand. We use `ERB::Util.url_encode` to encode.
66
+
67
+
63
68
  ## Install
64
69
 
65
70
  ### Release version
data/Rakefile CHANGED
@@ -1,42 +1,49 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
  require 'rake/testtask'
5
+ require 'rubocop/rake_task'
3
6
 
4
7
  Rake::TestTask.new do |t|
5
- t.libs << "test"
6
- t.test_files = FileList['test/test-*.rb']
8
+ t.libs << 'test'
9
+ t.test_files = FileList['test/test_*.rb']
7
10
  t.verbose = true
8
11
  t.warning = false
9
12
  end
10
13
 
11
- desc "Run tests"
12
- task :default => :test
14
+ desc 'Run tests'
15
+ task default: :test
16
+
17
+ RuboCop::RakeTask.new(:rubocop) do |t|
18
+ t.options = ['--display-cop-names']
19
+ end
13
20
 
14
- desc "Build serrano docs"
21
+ desc 'Build serrano docs'
15
22
  task :docs do
16
- system "yardoc"
23
+ system 'yardoc'
17
24
  end
18
25
 
19
- desc "bundle install"
26
+ desc 'bundle install'
20
27
  task :bundle do
21
- system "bundle install"
28
+ system 'bundle install'
22
29
  end
23
30
 
24
- desc "clean out builds"
31
+ desc 'clean out builds'
25
32
  task :clean do
26
- system "ls | grep [0-9].gem | xargs rm"
33
+ system 'ls | grep [0-9].gem | xargs rm'
27
34
  end
28
35
 
29
- desc "Build serrano"
36
+ desc 'Build serrano'
30
37
  task :build do
31
- system "gem build serrano.gemspec"
38
+ system 'gem build serrano.gemspec'
32
39
  end
33
40
 
34
- desc "Install serrano"
35
- task :install => [:bundle, :build] do
36
- system "gem install serrano-#{Serrano::VERSION}.gem"
41
+ desc 'Install serrano'
42
+ task install: %i[bundle build] do
43
+ system "gem install serrano-#{Serrano::VERSION}.gem"
37
44
  end
38
45
 
39
- desc "Release to Rubygems"
40
- task :release => :build do
46
+ desc 'Release to Rubygems'
47
+ task release: :build do
41
48
  system "gem push serrano-#{Serrano::VERSION}.gem"
42
49
  end
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "thor"
4
- require "serrano"
5
- require "multi_json"
4
+ require 'thor'
5
+ require 'serrano'
6
+ require 'multi_json'
6
7
 
7
8
  class Sr < Thor
8
9
  include Thor::Actions
9
10
  # class_option :json, :type => :boolean, :default => false
10
11
 
11
- desc "works [DOIs]", "Get works by DOIs"
12
+ desc 'works [DOIs]', 'Get works by DOIs'
12
13
  long_desc <<-LONGDESC
13
14
  `serrano works` accepts one or more DOIs to search for works
14
15
 
@@ -47,17 +48,17 @@ class Sr < Thor
47
48
  \x5"http://orcid.org/0000-0003-4087-8021"
48
49
  \x5"http://orcid.org/0000-0002-2076-5452"
49
50
  LONGDESC
50
- option :json, :type => :boolean, :default => false
51
- option :filter, :type => :hash, :default => nil
52
- option :limit, :type => :numeric, :default => nil
53
- def works(ids=nil)
54
- if ids.nil?
55
- out = Serrano.works(filter: options[:filter], limit: options[:limit])
56
- else
57
- out = Serrano.works(ids: ids.split(","), filter: options[:filter])
58
- end
51
+ option :json, type: :boolean, default: false
52
+ option :filter, type: :hash, default: nil
53
+ option :limit, type: :numeric, default: nil
54
+ def works(ids = nil)
55
+ out = if ids.nil?
56
+ Serrano.works(filter: options[:filter], limit: options[:limit])
57
+ else
58
+ Serrano.works(ids: ids.split(','), filter: options[:filter])
59
+ end
59
60
  if !options[:json]
60
- out = out.collect { |x| x['message'].select { |k,v| k[/DOI|type|title/] } }
61
+ out = out.collect { |x| x['message'].select { |k, _v| k[/DOI|type|title/] } }
61
62
  out.each do |x|
62
63
  puts 'DOI: ' + x['DOI'].to_s
63
64
  puts 'type: ' + x['type']
@@ -69,7 +70,7 @@ class Sr < Thor
69
70
  end
70
71
  end
71
72
 
72
- desc "members [member IDs]", "Get members by id"
73
+ desc 'members [member IDs]', 'Get members by id'
73
74
  long_desc <<-LONGDESC
74
75
  `serrano members` accepts one or more Crossref member IDs
75
76
 
@@ -96,26 +97,26 @@ class Sr < Thor
96
97
 
97
98
  24 7 45 31 22 67 72 17 53 75 0 68 12 16 50 79 40 18 40 195
98
99
  LONGDESC
99
- option :json, :type => :boolean, :default => false
100
- option :query, :type => :string, :default => nil
101
- option :limit, :type => :numeric, :default => nil
102
- option :works, :type => :boolean, :default => false
103
- def members(ids=nil)
100
+ option :json, type: :boolean, default: false
101
+ option :query, type: :string, default: nil
102
+ option :limit, type: :numeric, default: nil
103
+ option :works, type: :boolean, default: false
104
+ def members(ids = nil)
104
105
  if ids.nil?
105
106
  out = Serrano.members(query: options[:query], limit: options[:limit],
106
- works: options[:works])
107
+ works: options[:works])
107
108
  else
108
- out = Serrano.members(ids: ids.split(","), query: options[:query], limit: options[:limit],
109
- works: options[:works])
109
+ out = Serrano.members(ids: ids.split(','), query: options[:query], limit: options[:limit],
110
+ works: options[:works])
110
111
  end
111
112
 
112
113
  if !options[:json]
113
114
  if !options[:works]
114
- if out.class == Hash
115
- out = out['message']['items']
116
- else
117
- out = out.collect { |x| x['message'] }
118
- end
115
+ out = if out.class == Hash
116
+ out['message']['items']
117
+ else
118
+ out.collect { |x| x['message'] }
119
+ end
119
120
 
120
121
  # out = out.collect { |x| x['message'].select { |k,v| k[/id|primary-name/] } }
121
122
  out.each do |x|
@@ -131,8 +132,7 @@ class Sr < Thor
131
132
  end
132
133
  end
133
134
 
134
-
135
- desc "prefixes [DOI prefixes]", "Search for prefixes by DOI prefix"
135
+ desc 'prefixes [DOI prefixes]', 'Search for prefixes by DOI prefix'
136
136
  long_desc <<-LONGDESC
137
137
  `serrano prefixes` accepts one or more Crossref member IDs
138
138
 
@@ -162,24 +162,24 @@ class Sr < Thor
162
162
  \x5"Co-Action Publishing"
163
163
  \x5"Oxford University Press (OUP)"
164
164
  LONGDESC
165
- option :json, :type => :boolean, :default => false
166
- option :limit, :type => :numeric, :default => nil
167
- option :works, :type => :boolean, :default => false
168
- def prefixes(ids=nil)
169
- if ids.nil?
170
- out = Serrano.prefixes(limit: options[:limit], works: options[:works])
171
- else
172
- out = Serrano.prefixes(ids: ids.split(","), limit: options[:limit],
173
- works: options[:works])
174
- end
165
+ option :json, type: :boolean, default: false
166
+ option :limit, type: :numeric, default: nil
167
+ option :works, type: :boolean, default: false
168
+ def prefixes(ids = nil)
169
+ out = if ids.nil?
170
+ Serrano.prefixes(limit: options[:limit], works: options[:works])
171
+ else
172
+ Serrano.prefixes(ids: ids.split(','), limit: options[:limit],
173
+ works: options[:works])
174
+ end
175
175
 
176
176
  if !options[:json]
177
177
  if !options[:works]
178
- if out.class == Hash
179
- out = out['message']['items']
180
- else
181
- out = out.collect { |x| x['message'] }
182
- end
178
+ out = if out.class == Hash
179
+ out['message']['items']
180
+ else
181
+ out.collect { |x| x['message'] }
182
+ end
183
183
 
184
184
  out.each do |x|
185
185
  puts 'member: ' + x['member']
@@ -195,7 +195,7 @@ class Sr < Thor
195
195
  end
196
196
  end
197
197
 
198
- desc "funders [funder IDs]", "Search for funders by DOI prefix"
198
+ desc 'funders [funder IDs]', 'Search for funders by DOI prefix'
199
199
  long_desc <<-LONGDESC
200
200
  `serrano funders` accepts one or more Crossref funder IDs
201
201
 
@@ -226,26 +226,26 @@ class Sr < Thor
226
226
 
227
227
  $ serrano funders 10.13039/100000001 --works=true --limit=2
228
228
  LONGDESC
229
- option :json, :type => :boolean, :default => false
230
- option :query, :type => :string, :default => nil
231
- option :limit, :type => :numeric, :default => nil
232
- option :works, :type => :boolean, :default => false
233
- def funders(ids=nil)
229
+ option :json, type: :boolean, default: false
230
+ option :query, type: :string, default: nil
231
+ option :limit, type: :numeric, default: nil
232
+ option :works, type: :boolean, default: false
233
+ def funders(ids = nil)
234
234
  if ids.nil?
235
235
  out = Serrano.funders(query: options[:query], limit: options[:limit],
236
- works: options[:works])
236
+ works: options[:works])
237
237
  else
238
- out = Serrano.funders(ids: ids.split(","), query: options[:query], limit: options[:limit],
239
- works: options[:works])
238
+ out = Serrano.funders(ids: ids.split(','), query: options[:query], limit: options[:limit],
239
+ works: options[:works])
240
240
  end
241
241
 
242
242
  if !options[:json]
243
243
  if !options[:works]
244
- if out.class == Hash
245
- out = out['message']['items']
246
- else
247
- out = out.collect { |x| x['message'] }
248
- end
244
+ out = if out.class == Hash
245
+ out['message']['items']
246
+ else
247
+ out.collect { |x| x['message'] }
248
+ end
249
249
 
250
250
  out.each do |x|
251
251
  puts 'id: ' + x['id']
@@ -261,8 +261,7 @@ class Sr < Thor
261
261
  end
262
262
  end
263
263
 
264
-
265
- desc "journals [journal ISSNs]", "Search for journals by ISSNs"
264
+ desc 'journals [journal ISSNs]', 'Search for journals by ISSNs'
266
265
  long_desc <<-LONGDESC
267
266
  `serrano journals` accepts one or more journal ISSNs
268
267
 
@@ -293,26 +292,26 @@ class Sr < Thor
293
292
 
294
293
  $ serrano journals 2167-8359 --query=ecology --works=true --limit=2
295
294
  LONGDESC
296
- option :json, :type => :boolean, :default => false
297
- option :query, :type => :string, :default => nil
298
- option :limit, :type => :numeric, :default => nil
299
- option :works, :type => :boolean, :default => false
300
- def journals(ids=nil)
295
+ option :json, type: :boolean, default: false
296
+ option :query, type: :string, default: nil
297
+ option :limit, type: :numeric, default: nil
298
+ option :works, type: :boolean, default: false
299
+ def journals(ids = nil)
301
300
  if ids.nil?
302
301
  out = Serrano.journals(query: options[:query], limit: options[:limit],
303
- works: options[:works])
302
+ works: options[:works])
304
303
  else
305
- out = Serrano.journals(ids: ids.split(","), query: options[:query], limit: options[:limit],
306
- works: options[:works])
304
+ out = Serrano.journals(ids: ids.split(','), query: options[:query], limit: options[:limit],
305
+ works: options[:works])
307
306
  end
308
307
 
309
308
  if !options[:json]
310
309
  if !options[:works]
311
- if out.class == Hash
312
- out = out['message']['items']
313
- else
314
- out = out.collect { |x| x['message'] }
315
- end
310
+ out = if out.class == Hash
311
+ out['message']['items']
312
+ else
313
+ out.collect { |x| x['message'] }
314
+ end
316
315
 
317
316
  out.each do |x|
318
317
  puts 'ISSN: ' + x['ISSN'][0]
@@ -328,7 +327,7 @@ class Sr < Thor
328
327
  end
329
328
  end
330
329
 
331
- desc "types [type name]", "Search for types by name"
330
+ desc 'types [type name]', 'Search for types by name'
332
331
  long_desc <<-LONGDESC
333
332
  `serrano types` accepts one or more type names
334
333
 
@@ -359,20 +358,20 @@ class Sr < Thor
359
358
 
360
359
  $ serrano types dissertation --works --limit=2
361
360
  LONGDESC
362
- option :json, :type => :boolean, :default => false
363
- option :works, :type => :boolean, :default => false
364
- option :limit, :type => :numeric, :default => nil
361
+ option :json, type: :boolean, default: false
362
+ option :works, type: :boolean, default: false
363
+ option :limit, type: :numeric, default: nil
365
364
  def types(*ids)
366
365
  out = Serrano.types(ids: ids, limit: options[:limit],
367
- works: options[:works])
366
+ works: options[:works])
368
367
 
369
368
  if !options[:json]
370
369
  if !options[:works]
371
- if out.class == Hash
372
- out = out['message']['items']
373
- else
374
- out = out.collect { |x| x['message'] }
375
- end
370
+ out = if out.class == Hash
371
+ out['message']['items']
372
+ else
373
+ out.collect { |x| x['message'] }
374
+ end
376
375
 
377
376
  out.each do |x|
378
377
  puts 'id: ' + x['id']
@@ -387,7 +386,7 @@ class Sr < Thor
387
386
  end
388
387
  end
389
388
 
390
- desc "licenses", "Search for licenses by name"
389
+ desc 'licenses', 'Search for licenses by name'
391
390
  long_desc <<-LONGDESC
392
391
  `serrano licenses` accepts one or more type names
393
392
 
@@ -416,8 +415,8 @@ class Sr < Thor
416
415
  "National Science Foundation"
417
416
  \x5"U.S. Department of Energy"
418
417
  LONGDESC
419
- option :json, :type => :boolean, :default => false
420
- option :query, :type => :string, :default => nil
418
+ option :json, type: :boolean, default: false
419
+ option :query, type: :string, default: nil
421
420
  def licenses
422
421
  out = Serrano.licenses(query: options[:query])
423
422
  if !options[:json]
@@ -432,7 +431,7 @@ class Sr < Thor
432
431
  end
433
432
  end
434
433
 
435
- desc "contneg", "Content negotiation"
434
+ desc 'contneg', 'Content negotiation'
436
435
  long_desc <<-LONGDESC
437
436
  `serrano contneg` accepts a DOI
438
437
 
@@ -444,15 +443,15 @@ class Sr < Thor
444
443
 
445
444
  Murtaugh PA (2014). In defense of P values . Ecology 95: 611–617.
446
445
  LONGDESC
447
- option :format, :type => :string, :default => "text"
448
- option :style, :type => :string, :default => "apa"
449
- option :locale, :type => :string, :default => "en-US"
446
+ option :format, type: :string, default: 'text'
447
+ option :style, type: :string, default: 'apa'
448
+ option :locale, type: :string, default: 'en-US'
450
449
  def contneg(ids)
451
450
  puts Serrano.content_negotiation(ids: ids, format: options[:format], style:
452
451
  options[:style], locale: options[:locale])
453
452
  end
454
453
 
455
- desc "version", "Get serrano version"
454
+ desc 'version', 'Get serrano version'
456
455
  def version
457
456
  puts Serrano::VERSION
458
457
  end
@@ -460,11 +459,11 @@ class Sr < Thor
460
459
  private
461
460
 
462
461
  def print_works(data)
463
- if data.is_a? Array
464
- data = data[0]['message']['items']
465
- else
466
- data = data.collect { |x| x['message'].select { |k,v| k[/DOI|type|title/] } }
467
- end
462
+ data = if data.is_a? Array
463
+ data[0]['message']['items']
464
+ else
465
+ data.collect { |x| x['message'].select { |k, _v| k[/DOI|type|title/] } }
466
+ end
468
467
  data.each do |x|
469
468
  puts 'DOI: ' + x['DOI']
470
469
  puts 'type: ' + x['type']
@@ -472,7 +471,6 @@ class Sr < Thor
472
471
  puts
473
472
  end
474
473
  end
475
-
476
474
  end
477
475
 
478
476
  Sr.start(ARGV)