noun-project-api 2.0.1 → 3.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: bbb311ca73f82163024bcb0df6be86691aa3a330a92633e1a4aa88d6f205f572
4
- data.tar.gz: 5ca5acd613a7182f320cf4b70fd5f4d3a4a255ce5f3a8673df71a6cb39cc97c0
3
+ metadata.gz: dc6c2457656761dd7e1bed16e52f00c5558a4f632a354f3fa7c626b90664b09b
4
+ data.tar.gz: 184f196a2a7d1da39cc8988d0f7384374220a12a66cb495c06d52a53a3ee74ae
5
5
  SHA512:
6
- metadata.gz: c6c535dc993850089e01b5fd9e3bfa586d89844abd033f5f09ea29f2bf4626a39405d1506a64ee5e89de71ece597811bfa3e37a5b8ed3c64ca194e9e03298bb8
7
- data.tar.gz: c312621d5e9be931e6634af8f9869754b67360bd53abdf4720f395c7ad2b13a54656db7f60414f893ce087dae7bf20ff37e99b26caab8f4dc714446d5bdf7fc4
6
+ metadata.gz: cf73f5f81a56f940567d2bff8b9dbeb0631d9e7f32f973bf5a29a2f541356420e5651a3c2d48705cd6823890a18d9f71ca2b45c4ad709fe80fad72c8ae41e473
7
+ data.tar.gz: ae830b9869b6b10dea4b2287d511f7274692b6875776074d9c46eb5a706f0f63e984088eccb07b938087bbe943904ef4cc68762b74eee195db6c883985245bcf
@@ -1,4 +1,5 @@
1
1
  require "oauth"
2
+ require "active_support"
2
3
  require "json"
3
4
  require "noun-project-api/errors"
4
5
  require "noun-project-api/connection"
@@ -24,10 +25,11 @@ module NounProjectApi
24
25
 
25
26
  # Main configuration class.
26
27
  class Configuration
27
- attr_accessor :public_domain
28
+ attr_accessor :public_domain, :cache
28
29
 
29
30
  def initialize
30
31
  @public_domain = false
32
+ @cache = ActiveSupport::Cache::NullStore.new
31
33
  end
32
34
  end
33
35
  end
@@ -11,25 +11,29 @@ module NounProjectApi
11
11
  # * offset - offset the results
12
12
  # * page - page number
13
13
  def find(term, limit = nil, offset = nil, page = nil)
14
- raise ArgumentError.new("Missing search term") unless term
14
+ cache_key = Digest::MD5.hexdigest("#{term}+#{limit}+#{offset}+#{page}")
15
15
 
16
- search = OAuth::Helper.escape(term)
17
- search += "?limit_to_public_domain=#{NounProjectApi.configuration.public_domain ? 1 : 0}"
16
+ NounProjectApi.configuration.cache.fetch(cache_key) do
17
+ raise ArgumentError.new("Missing search term") unless term
18
18
 
19
- args = {
20
- "limit" => limit,
21
- "offset" => offset,
22
- "page" => page
23
- }.reject { |_, v| v.nil? }
24
- args.each { |k, v| search += "&#{k}=#{v}" } if args.size > 0
19
+ search = OAuth::Helper.escape(term)
20
+ search += "?limit_to_public_domain=#{NounProjectApi.configuration.public_domain ? 1 : 0}"
25
21
 
26
- result = access_token.get("#{API_BASE}#{API_PATH}#{search}")
27
- raise ServiceError.new(result.code, result.body) unless %w(200 404).include? result.code
22
+ args = {
23
+ "limit" => limit,
24
+ "offset" => offset,
25
+ "page" => page
26
+ }.reject { |_, v| v.nil? }
27
+ args.each { |k, v| search += "&#{k}=#{v}" } if args.size > 0
28
28
 
29
- if result.code == "200"
30
- JSON.parse(result.body)["icons"].map { |icon| Icon.new(icon) }
31
- else
32
- []
29
+ result = access_token.get("#{API_BASE}#{API_PATH}#{search}")
30
+ raise ServiceError.new(result.code, result.body) unless %w(200 404).include? result.code
31
+
32
+ if result.code == "200"
33
+ JSON.parse(result.body)["icons"].map { |icon| Icon.new(icon) }
34
+ else
35
+ []
36
+ end
33
37
  end
34
38
  end
35
39
 
@@ -3,7 +3,7 @@ require "ostruct"
3
3
 
4
4
  RSpec.describe NounProjectApi::CollectionRetriever do
5
5
  before :each do
6
- @collection = NounProjectApi::CollectionRetriever.new(Faker::Internet.password(16), Faker::Internet.password(16))
6
+ @collection = NounProjectApi::CollectionRetriever.new(Faker::Internet.password(min_length: 16), Faker::Internet.password(min_length: 16))
7
7
  @valid_hash = JSON.parse(Fakes::Results::COLLECTION_VALID)
8
8
  @valid_response = OpenStruct.new(
9
9
  body: Fakes::Results::COLLECTION_VALID,
@@ -3,7 +3,7 @@ require "ostruct"
3
3
 
4
4
  RSpec.describe NounProjectApi::IconRetriever do
5
5
  before :each do
6
- @icon = NounProjectApi::IconRetriever.new(Faker::Internet.password(16), Faker::Internet.password(16))
6
+ @icon = NounProjectApi::IconRetriever.new(Faker::Internet.password(min_length: 16), Faker::Internet.password(min_length: 16))
7
7
  @valid_hash = JSON.parse(Fakes::Results::ICON_VALID)
8
8
  @valid_response = OpenStruct.new(
9
9
  body: Fakes::Results::ICON_VALID,
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe NounProjectApi::IconsRetriever do
4
4
  before :each do
5
- @icons = NounProjectApi::IconsRetriever.new(Faker::Internet.password(16), Faker::Internet.password(16))
5
+ @icons = NounProjectApi::IconsRetriever.new(Faker::Internet.password(min_length: 16), Faker::Internet.password(min_length: 16))
6
6
  end
7
7
 
8
8
  context "recent uploads" do
@@ -2,16 +2,16 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe NounProjectApi::Reporter do
4
4
  it "raises an error when initialized without token" do
5
- expect { NounProjectApi::Reporter.new(nil, Faker::Internet.password(16)) }.to raise_error(ArgumentError)
5
+ expect { NounProjectApi::Reporter.new(nil, Faker::Internet.password(min_length: 16)) }.to raise_error(ArgumentError)
6
6
  end
7
7
 
8
8
  it "raises an error when initialized without secret" do
9
- expect { NounProjectApi::Reporter.new(Faker::Internet.password(16), nil) }.to raise_error(ArgumentError)
9
+ expect { NounProjectApi::Reporter.new(Faker::Internet.password(min_length: 16), nil) }.to raise_error(ArgumentError)
10
10
  end
11
11
 
12
12
  it "initializes the values properly" do
13
- token = Faker::Internet.password(16)
14
- secret = Faker::Internet.password(16)
13
+ token = Faker::Internet.password(min_length: 16)
14
+ secret = Faker::Internet.password(min_length: 16)
15
15
  reporter = NounProjectApi::Reporter.new(token, secret)
16
16
 
17
17
  expect(reporter.token).to eq(token)
@@ -20,8 +20,8 @@ RSpec.describe NounProjectApi::Reporter do
20
20
 
21
21
  context "reports ids usage" do
22
22
  before :each do
23
- token = Faker::Internet.password(16)
24
- secret = Faker::Internet.password(16)
23
+ token = Faker::Internet.password(min_length: 16)
24
+ secret = Faker::Internet.password(min_length: 16)
25
25
  @reporter = NounProjectApi::Reporter.new(token, secret)
26
26
  end
27
27
 
@@ -2,16 +2,16 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe NounProjectApi::Retriever do
4
4
  it "raises an error when initialized without token" do
5
- expect { NounProjectApi::Retriever.new(nil, Faker::Internet.password(16)) }.to raise_error(ArgumentError)
5
+ expect { NounProjectApi::Retriever.new(nil, Faker::Internet.password(min_length: 16)) }.to raise_error(ArgumentError)
6
6
  end
7
7
 
8
8
  it "raises an error when initialized without secret" do
9
- expect { NounProjectApi::Retriever.new(Faker::Internet.password(16), nil) }.to raise_error(ArgumentError)
9
+ expect { NounProjectApi::Retriever.new(Faker::Internet.password(min_length: 16), nil) }.to raise_error(ArgumentError)
10
10
  end
11
11
 
12
12
  it "initializes the values properly" do
13
- token = Faker::Internet.password(16)
14
- secret = Faker::Internet.password(16)
13
+ token = Faker::Internet.password(min_length: 16)
14
+ secret = Faker::Internet.password(min_length: 16)
15
15
  retriever = NounProjectApi::Retriever.new(token, secret)
16
16
 
17
17
  expect(retriever.token).to eq(token)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noun-project-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nadav Shatz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-06 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth
@@ -24,48 +24,62 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '12.3'
47
+ version: '13.0'
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: '12.3'
54
+ version: '13.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '3.8'
61
+ version: '3.9'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '3.8'
68
+ version: '3.9'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: faker
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '1.9'
75
+ version: '2.13'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '1.9'
82
+ version: '2.13'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: semver
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +114,14 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '0.11'
117
+ version: '0.13'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '0.11'
124
+ version: '0.13'
111
125
  description: A Gem to expose a wrapping API for The Noun Project API's
112
126
  email: nadav@tailorbrands.com
113
127
  executables: []
@@ -141,7 +155,7 @@ homepage: https://github.com/TailorBrands/noun-project-api
141
155
  licenses:
142
156
  - MIT
143
157
  metadata: {}
144
- post_install_message:
158
+ post_install_message:
145
159
  rdoc_options: []
146
160
  require_paths:
147
161
  - lib
@@ -156,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
170
  - !ruby/object:Gem::Version
157
171
  version: '0'
158
172
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.7.6
161
- signing_key:
173
+ rubygems_version: 3.1.2
174
+ signing_key:
162
175
  specification_version: 4
163
176
  summary: An API wrapper for The Noun Project API's
164
177
  test_files: