noun-project-api 0.2.2 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +9 -7
  3. data/lib/noun_project_api.rb +38 -0
  4. data/lib/noun_project_api/base_item.rb +30 -0
  5. data/lib/noun_project_api/collection.rb +36 -0
  6. data/lib/noun_project_api/collection_retriever.rb +14 -0
  7. data/lib/{noun-project-api → noun_project_api}/connection.rb +3 -1
  8. data/lib/noun_project_api/errors.rb +14 -0
  9. data/lib/noun_project_api/icon.rb +41 -0
  10. data/lib/noun_project_api/icon_retriever.rb +14 -0
  11. data/lib/noun_project_api/icons_retriever.rb +66 -0
  12. data/lib/noun_project_api/reporter.rb +22 -0
  13. data/lib/noun_project_api/retriever.rb +18 -0
  14. data/spec/lib/noun_project_api/base_item_spec.rb +13 -0
  15. data/spec/lib/noun_project_api/collection_retriever_spec.rb +87 -0
  16. data/spec/lib/noun_project_api/collection_spec.rb +66 -0
  17. data/spec/lib/{noun-project-api → noun_project_api}/icon_retriever_spec.rb +20 -18
  18. data/spec/lib/{noun-project-api → noun_project_api}/icon_spec.rb +21 -19
  19. data/spec/lib/{noun-project-api → noun_project_api}/icons_retriever_spec.rb +27 -25
  20. data/spec/lib/{noun-project-api → noun_project_api}/reporter_spec.rb +24 -24
  21. data/spec/lib/noun_project_api/retriever_spec.rb +22 -0
  22. data/spec/lib/{nount_project_api_spec.rb → noun_project_api_spec.rb} +5 -3
  23. data/spec/spec_helper.rb +3 -4
  24. data/spec/support/fakes.rb +93 -10
  25. metadata +90 -45
  26. data/lib/noun-project-api.rb +0 -30
  27. data/lib/noun-project-api/icon.rb +0 -52
  28. data/lib/noun-project-api/icon_retriever.rb +0 -20
  29. data/lib/noun-project-api/icons_retriever.rb +0 -51
  30. data/lib/noun-project-api/reporter.rb +0 -20
  31. data/lib/noun-project-api/retriever.rb +0 -6
  32. data/spec/lib/noun-project-api/retriever_spec.rb +0 -20
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ RSpec.describe NounProjectApi::Retriever do
6
+ it "raises an error when initialized without token" do
7
+ expect { NounProjectApi::Retriever.new(nil, Faker::Internet.password(min_length: 16)) }.to raise_error(ArgumentError)
8
+ end
9
+
10
+ it "raises an error when initialized without secret" do
11
+ expect { NounProjectApi::Retriever.new(Faker::Internet.password(min_length: 16), nil) }.to raise_error(ArgumentError)
12
+ end
13
+
14
+ it "initializes the values properly" do
15
+ token = Faker::Internet.password(min_length: 16)
16
+ secret = Faker::Internet.password(min_length: 16)
17
+ retriever = NounProjectApi::Retriever.new(token, secret)
18
+
19
+ expect(retriever.token).to eq(token)
20
+ expect(retriever.secret).to eq(secret)
21
+ end
22
+ end
@@ -1,11 +1,13 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
2
4
 
3
5
  RSpec.describe NounProjectApi do
4
- it 'has the correct default' do
6
+ it "has the correct default" do
5
7
  expect(NounProjectApi.configuration.public_domain).to be false
6
8
  end
7
9
 
8
- it 'sets the correct configuration' do
10
+ it "sets the correct configuration" do
9
11
  expect(NounProjectApi.configuration.public_domain).to be false
10
12
 
11
13
  NounProjectApi.configure do |config|
@@ -1,11 +1,10 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
1
+ # frozen_string_literal: true
3
2
 
4
3
  require "bundler/setup"
5
- require "noun-project-api"
4
+ require "noun_project_api"
6
5
  require "pry"
7
6
  require "faker"
8
- require 'json'
7
+ require "json"
9
8
 
10
9
  require_relative "support/fakes"
11
10
 
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fakes
2
4
  module Results
3
- ICON_VALID = '''
5
+ ICON_VALID = ""'
4
6
  {
5
7
  "icon": {
6
8
  "term_slug": "beauty-salon",
@@ -83,9 +85,9 @@ module Fakes
83
85
  "term_id": 645
84
86
  }
85
87
  }
86
- '''
88
+ '""
87
89
 
88
- ICONS_RECENT_VALID = '''
90
+ ICONS_RECENT_VALID = ""'
89
91
  {
90
92
  "recent_uploads": [
91
93
  {
@@ -172,9 +174,9 @@ module Fakes
172
174
  }
173
175
  ],
174
176
  "generated_at": "Thu, 18 Sep 2014 18:09:34 GMT"
175
- }'''
177
+ }'""
176
178
 
177
- ICONS_VALID = '''
179
+ ICONS_VALID = ""'
178
180
  {
179
181
  "generated_at": "Thu, 18 Sep 2014 17:48:10 GMT",
180
182
  "icons": [
@@ -295,18 +297,99 @@ module Fakes
295
297
  "term_id": 857
296
298
  }
297
299
  ]
298
- }'''
300
+ }'""
299
301
 
300
- REPORTED_ONE = '''
302
+ REPORTED_ONE = ""'
301
303
  {
302
304
  "licenses_consumed": 1,
303
305
  "result": "success"
304
- }'''
306
+ }'""
305
307
 
306
- REPORTED_THREE = '''
308
+ REPORTED_THREE = ""'
307
309
  {
308
310
  "licenses_consumed": 1,
309
311
  "result": "success"
310
- }'''
312
+ }'""
313
+
314
+ COLLECTION_VALID = ""'
315
+ {
316
+ "collection": {
317
+ "author": {
318
+ "location": "US",
319
+ "name": "irene hoffman",
320
+ "permalink": "/i",
321
+ "username": "i"
322
+ },
323
+ "author_id": "5562",
324
+ "date_created": "2014-06-27 00:22:22",
325
+ "date_updated": "2014-06-27 00:22:22",
326
+ "description": "",
327
+ "icon_count": "4",
328
+ "id": "321",
329
+ "is_collaborative": "",
330
+ "is_featured": "0",
331
+ "is_published": "1",
332
+ "is_store_item": "0",
333
+ "name": "genetics",
334
+ "permalink": "/i/collection/genetics",
335
+ "slug": "genetics",
336
+ "sponsor": {},
337
+ "sponsor_campaign_link": "",
338
+ "sponsor_id": "",
339
+ "tags": [
340
+ "genetics",
341
+ "chromosome",
342
+ "gene",
343
+ "heredity",
344
+ "genetic code",
345
+ "nucleic acid",
346
+ "RNA",
347
+ "DNA",
348
+ "deoxyribonucleic acid",
349
+ "reproduction",
350
+ "genome",
351
+ "human",
352
+ "chemistry",
353
+ "Allele",
354
+ "Amelogenin",
355
+ "bases",
356
+ "building blocks",
357
+ "cytosine",
358
+ "guanine",
359
+ "thymine",
360
+ "adenine",
361
+ "c",
362
+ "G",
363
+ "T",
364
+ "CGTA",
365
+ "A",
366
+ "biological",
367
+ "cell",
368
+ "CODIS",
369
+ "blueprint of life",
370
+ "life",
371
+ "material",
372
+ "nucleus",
373
+ "inherited",
374
+ "parent",
375
+ "unique",
376
+ "analysis",
377
+ "double helix",
378
+ "helix",
379
+ "forensic",
380
+ "loci",
381
+ "genotype",
382
+ "haplotype",
383
+ "junk DNA",
384
+ "match",
385
+ "nuclear",
386
+ "paternal",
387
+ "sequence",
388
+ "sequencing"
389
+ ],
390
+ "template": "24"
391
+ }
392
+ }
393
+ '""
311
394
  end
312
395
  end
metadata CHANGED
@@ -1,111 +1,154 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noun-project-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Nadav Shatz
7
+ - Tailor Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: oauth
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '0'
33
+ version: '0.5'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0'
40
+ version: '0.5'
27
41
  - !ruby/object:Gem::Dependency
28
- name: rake
42
+ name: faker
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: '2.13'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: '2.13'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '3.1'
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 3.1.0
61
+ version: '0.13'
51
62
  type: :development
52
63
  prerelease: false
53
64
  version_requirements: !ruby/object:Gem::Requirement
54
65
  requirements:
55
66
  - - "~>"
56
67
  - !ruby/object:Gem::Version
57
- version: '3.1'
58
- - - ">="
68
+ version: '0.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
59
74
  - !ruby/object:Gem::Version
60
- version: 3.1.0
75
+ version: '13.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '13.0'
61
83
  - !ruby/object:Gem::Dependency
62
- name: faker
84
+ name: rspec
63
85
  requirement: !ruby/object:Gem::Requirement
64
86
  requirements:
65
87
  - - "~>"
66
88
  - !ruby/object:Gem::Version
67
- version: '0'
89
+ version: '3.9'
68
90
  type: :development
69
91
  prerelease: false
70
92
  version_requirements: !ruby/object:Gem::Requirement
71
93
  requirements:
72
94
  - - "~>"
73
95
  - !ruby/object:Gem::Version
74
- version: '0'
96
+ version: '3.9'
75
97
  - !ruby/object:Gem::Dependency
76
- name: semver
98
+ name: rspec_junit_formatter
77
99
  requirement: !ruby/object:Gem::Requirement
78
100
  requirements:
79
101
  - - "~>"
80
102
  - !ruby/object:Gem::Version
81
- version: '0'
103
+ version: '0.4'
82
104
  type: :development
83
105
  prerelease: false
84
106
  version_requirements: !ruby/object:Gem::Requirement
85
107
  requirements:
86
108
  - - "~>"
87
109
  - !ruby/object:Gem::Version
88
- version: '0'
110
+ version: '0.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.79.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.79.0
89
125
  description: A Gem to expose a wrapping API for The Noun Project API's
90
- email: nadav@tailorbrands.com
126
+ email: sloths@tailorbrands.com
91
127
  executables: []
92
128
  extensions: []
93
129
  extra_rdoc_files: []
94
130
  files:
95
131
  - Rakefile
96
- - lib/noun-project-api.rb
97
- - lib/noun-project-api/connection.rb
98
- - lib/noun-project-api/icon.rb
99
- - lib/noun-project-api/icon_retriever.rb
100
- - lib/noun-project-api/icons_retriever.rb
101
- - lib/noun-project-api/reporter.rb
102
- - lib/noun-project-api/retriever.rb
103
- - spec/lib/noun-project-api/icon_retriever_spec.rb
104
- - spec/lib/noun-project-api/icon_spec.rb
105
- - spec/lib/noun-project-api/icons_retriever_spec.rb
106
- - spec/lib/noun-project-api/reporter_spec.rb
107
- - spec/lib/noun-project-api/retriever_spec.rb
108
- - spec/lib/nount_project_api_spec.rb
132
+ - lib/noun_project_api.rb
133
+ - lib/noun_project_api/base_item.rb
134
+ - lib/noun_project_api/collection.rb
135
+ - lib/noun_project_api/collection_retriever.rb
136
+ - lib/noun_project_api/connection.rb
137
+ - lib/noun_project_api/errors.rb
138
+ - lib/noun_project_api/icon.rb
139
+ - lib/noun_project_api/icon_retriever.rb
140
+ - lib/noun_project_api/icons_retriever.rb
141
+ - lib/noun_project_api/reporter.rb
142
+ - lib/noun_project_api/retriever.rb
143
+ - spec/lib/noun_project_api/base_item_spec.rb
144
+ - spec/lib/noun_project_api/collection_retriever_spec.rb
145
+ - spec/lib/noun_project_api/collection_spec.rb
146
+ - spec/lib/noun_project_api/icon_retriever_spec.rb
147
+ - spec/lib/noun_project_api/icon_spec.rb
148
+ - spec/lib/noun_project_api/icons_retriever_spec.rb
149
+ - spec/lib/noun_project_api/reporter_spec.rb
150
+ - spec/lib/noun_project_api/retriever_spec.rb
151
+ - spec/lib/noun_project_api_spec.rb
109
152
  - spec/spec_helper.rb
110
153
  - spec/support/fakes.rb
111
154
  homepage: https://github.com/TailorBrands/noun-project-api
@@ -127,17 +170,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
170
  - !ruby/object:Gem::Version
128
171
  version: '0'
129
172
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.4.5
173
+ rubygems_version: 3.1.2
132
174
  signing_key:
133
175
  specification_version: 4
134
176
  summary: An API wrapper for The Noun Project API's
135
177
  test_files:
136
- - spec/lib/noun-project-api/icon_retriever_spec.rb
137
- - spec/lib/noun-project-api/icon_spec.rb
138
- - spec/lib/noun-project-api/icons_retriever_spec.rb
139
- - spec/lib/noun-project-api/reporter_spec.rb
140
- - spec/lib/noun-project-api/retriever_spec.rb
141
- - spec/lib/nount_project_api_spec.rb
142
- - spec/spec_helper.rb
143
178
  - spec/support/fakes.rb
179
+ - spec/lib/noun_project_api/reporter_spec.rb
180
+ - spec/lib/noun_project_api/collection_retriever_spec.rb
181
+ - spec/lib/noun_project_api/collection_spec.rb
182
+ - spec/lib/noun_project_api/base_item_spec.rb
183
+ - spec/lib/noun_project_api/icon_retriever_spec.rb
184
+ - spec/lib/noun_project_api/retriever_spec.rb
185
+ - spec/lib/noun_project_api/icons_retriever_spec.rb
186
+ - spec/lib/noun_project_api/icon_spec.rb
187
+ - spec/lib/noun_project_api_spec.rb
188
+ - spec/spec_helper.rb
@@ -1,30 +0,0 @@
1
- require 'oauth'
2
- require 'json'
3
- require 'noun-project-api/connection'
4
- require 'noun-project-api/icon_retriever'
5
- require 'noun-project-api/reporter'
6
- require 'noun-project-api/icons_retriever'
7
- require 'noun-project-api/icon'
8
-
9
- # Top level name space for the entire Gem.
10
- module NounProjectApi
11
- API_BASE = 'http://api.thenounproject.com'
12
-
13
- def self.configuration
14
- @configuration ||= Configuration.new
15
- end
16
-
17
- def self.configure
18
- self.configuration ||= Configuration.new
19
- yield(configuration) if block_given?
20
- end
21
-
22
- # Main configuration class.
23
- class Configuration
24
- attr_accessor :public_domain
25
-
26
- def initialize
27
- @public_domain = false
28
- end
29
- end
30
- end
@@ -1,52 +0,0 @@
1
- module NounProjectApi
2
- # A single Icon as an abstracted ruby object.
3
- class Icon
4
- PREVIEW_SIZE_200 = 200
5
- PREVIEW_SIZE_42 = 42
6
- PREVIEW_SIZE_84 = 84
7
-
8
- PUBLIC_DOMAIN_LICENSE = 'public-domain'
9
-
10
- attr_accessor :original_hash
11
-
12
- def initialize(origin)
13
- origin = JSON.parse(origin) if origin.is_a? String
14
- origin = origin.delete('icon') if origin.key? 'icon'
15
-
16
- @original_hash = origin
17
- end
18
-
19
- def id
20
- original_hash['id'].to_i
21
- end
22
-
23
- def public_domain?
24
- original_hash['license_description'] == PUBLIC_DOMAIN_LICENSE
25
- end
26
-
27
- def svg_url
28
- original_hash['icon_url']
29
- end
30
-
31
- def preview_url(size = PREVIEW_SIZE_200)
32
- if size == PREVIEW_SIZE_200
33
- original_hash['preview_url']
34
- else
35
- original_hash["preview_url_#{size}"]
36
- end
37
- end
38
-
39
- def to_hash
40
- {
41
- id: id,
42
- preview_url_200: preview_url(PREVIEW_SIZE_200),
43
- preview_url_84: preview_url(PREVIEW_SIZE_84),
44
- preview_url_42: preview_url(PREVIEW_SIZE_42)
45
- }
46
- end
47
-
48
- def to_json
49
- JSON.dump(to_hash)
50
- end
51
- end
52
- end