noun-project-api 3.1.4 → 4.0.0

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: f43cae5a5e16a45628ad844b61e15211f7902041afc2a1b1369b8cc86c06503b
4
- data.tar.gz: 2ff960d4e37127d4866539de095839efad0cd2e8fcebea0121bcb735a68e0d44
3
+ metadata.gz: a54ae4b1729039cd83078fb3539983ddcaab4a917ec5d0b24a72f83cd4a53e24
4
+ data.tar.gz: 03f70103a7b43842c63bb75a84f59103c1b13ae429daf2e8e04bf9f2b0d6dd43
5
5
  SHA512:
6
- metadata.gz: d4fb060b8c726a202549af2f0394f5d4cb781cccf7bcc70ffb13ae635eb68a848096bbe2702ec41a5eac3545e5edc8dce7c2c358d288cc597596799dcfe22a10
7
- data.tar.gz: f205f52af9969a615bc4a72683ef461a3db852699c73aa229ed8fed729aa56c0ebd6ece29d33f355015421fc5a4439e768e3c60fe7b7f0d99e6c23e88385b484
6
+ metadata.gz: 9a466dc9016b91a523ce7828bd3708264c84ade3130f32771a37581cd5686ad6673de50089d92d24977bd07b257c23f189cd5d1b2857155315a8d38ac1a25305
7
+ data.tar.gz: da1ab9bf4ebfa2fd397e846d7a2d21a3ec70b1399d5b985f0c5f88a6d653b7961c22febff08a4588f508bd107c850428bbac617c23e3e482a7a200ddca9445cd
@@ -4,6 +4,7 @@ module NounProjectApi
4
4
  # A basis to Items returned by the noun project.
5
5
  class BaseItem
6
6
  attr_accessor :original_hash
7
+
7
8
  ITEM_NAME = nil
8
9
 
9
10
  def initialize(origin)
@@ -25,10 +25,10 @@ module NounProjectApi
25
25
 
26
26
  def to_hash
27
27
  {
28
- id: id,
29
- author_id: author_id,
30
- author_name: author_name,
31
- icon_count: icon_count,
28
+ id:,
29
+ author_id:,
30
+ author_name:,
31
+ icon_count:,
32
32
  published: published?
33
33
  }
34
34
  end
@@ -31,7 +31,7 @@ module NounProjectApi
31
31
 
32
32
  def to_hash
33
33
  {
34
- id: id,
34
+ id:,
35
35
  preview_url_200: preview_url(PREVIEW_SIZE_200),
36
36
  preview_url_84: preview_url(PREVIEW_SIZE_84),
37
37
  preview_url_42: preview_url(PREVIEW_SIZE_42)
@@ -19,17 +19,14 @@ module NounProjectApi
19
19
  NounProjectApi.configuration.cache.fetch(cache_key, expires_in: cache_ttl) do
20
20
  raise ArgumentError, "Missing search term" unless term
21
21
 
22
- search = OAuth::Helper.escape(term)
23
- search += "?limit_to_public_domain=#{NounProjectApi.configuration.public_domain ? 1 : 0}"
24
-
25
22
  args = {
26
- "limit" => limit,
27
- "offset" => offset,
28
- "page" => page
29
- }.reject { |_, v| v.nil? }
30
- args.each { |k, v| search += "&#{k}=#{v}" } unless args.empty?
23
+ limit_to_public_domain: NounProjectApi.configuration.public_domain ? 1 : 0,
24
+ limit:,
25
+ offset:,
26
+ page:
27
+ }.compact
31
28
 
32
- result = access_token.get("#{API_BASE}#{API_PATH}#{search}")
29
+ result = access_token.get("#{API_BASE}#{API_PATH}#{OAuth::Helper.escape(term)}?#{args.to_query}")
33
30
  raise ServiceError.new(result.code, result.body) unless ["200", "404"].include? result.code
34
31
 
35
32
  if result.code == "200"
@@ -46,18 +43,12 @@ module NounProjectApi
46
43
  # * page - page number
47
44
  def recent_uploads(limit = nil, offset = nil, page = nil)
48
45
  args = {
49
- "limit" => limit,
50
- "offset" => offset,
51
- "page" => page
52
- }.reject { |_, v| v.nil? }
53
- if !args.empty?
54
- search = "?"
55
- args.each { |k, v| search += "#{k}=#{v}&" }
56
- else
57
- search = ""
58
- end
46
+ limit:,
47
+ offset:,
48
+ page:
49
+ }.compact
59
50
 
60
- result = access_token.get("#{API_BASE}#{API_PATH}recent_uploads#{search}")
51
+ result = access_token.get("#{API_BASE}#{API_PATH}recent_uploads?#{args.to_query}")
61
52
  raise ServiceError.new(result.code, result.body) unless result.code == "200"
62
53
 
63
54
  JSON.parse(result.body, symbolize_names: true)[:recent_uploads].map { |icon| Icon.new(icon) }
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "oauth"
4
- require "active_support"
4
+ require "active_support/all"
5
5
  require "json"
6
6
  require "noun_project_api/errors"
7
7
  require "noun_project_api/connection"
@@ -18,7 +18,7 @@ RSpec.describe NounProjectApi::IconsRetriever do
18
18
  expect(@icons.access_token).to receive(
19
19
  :get
20
20
  ).with(
21
- "#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}recent_uploads"
21
+ "#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}recent_uploads?"
22
22
  ).and_return(
23
23
  valid_response
24
24
  )
@@ -41,7 +41,7 @@ RSpec.describe NounProjectApi::IconsRetriever do
41
41
  expect(@icons.access_token).to receive(
42
42
  :get
43
43
  ).with(
44
- "#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}recent_uploads?limit=#{limit}&"
44
+ "#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}recent_uploads?limit=#{limit}"
45
45
  ).and_return(
46
46
  valid_response
47
47
  )
@@ -141,7 +141,7 @@ RSpec.describe NounProjectApi::IconsRetriever do
141
141
  expect(@icons.access_token).to receive(
142
142
  :get
143
143
  ).with(
144
- "#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper.escape(term)}?limit_to_public_domain=0&limit=#{limit}"
144
+ "#{NounProjectApi::API_BASE}#{NounProjectApi::IconsRetriever::API_PATH}#{OAuth::Helper.escape(term)}?limit=#{limit}&limit_to_public_domain=0"
145
145
  ).and_return(
146
146
  valid_response
147
147
  )
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "bundler/setup"
4
4
  require "noun_project_api"
5
- require "pry"
6
5
  require "faker"
7
6
  require "json"
8
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noun-project-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tailor Engineering
@@ -30,42 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.5'
33
+ version: '1.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
- version: '0.5'
40
+ version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faker
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.13'
47
+ version: '3.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.13'
55
- - !ruby/object:Gem::Dependency
56
- name: pry
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.13'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.13'
54
+ version: '3.1'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,42 +72,28 @@ dependencies:
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '3.9'
75
+ version: '3.12'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '3.9'
82
+ version: '3.12'
97
83
  - !ruby/object:Gem::Dependency
98
- name: rspec_junit_formatter
84
+ name: rubocop
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0.4'
89
+ version: '1'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - "~>"
109
95
  - !ruby/object:Gem::Version
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
96
+ version: '1'
125
97
  description: A Gem to expose a wrapping API for The Noun Project API's
126
98
  email: sloths@tailorbrands.com
127
99
  executables: []
@@ -163,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
135
  requirements:
164
136
  - - ">="
165
137
  - !ruby/object:Gem::Version
166
- version: '0'
138
+ version: '3.2'
167
139
  required_rubygems_version: !ruby/object:Gem::Requirement
168
140
  requirements:
169
141
  - - ">="