noun-project-api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +14 -0
- data/lib/noun-project-api.rb +5 -0
- data/lib/noun-project-api/icon.rb +18 -0
- data/lib/noun-project-api/icons.rb +44 -0
- data/lib/noun-project-api/retriever.rb +16 -0
- data/spec/lib/noun-project-api/icon_spec.rb +81 -0
- data/spec/lib/noun-project-api/icons_spec.rb +128 -0
- data/spec/lib/noun-project-api/retriever_spec.rb +20 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/fakes.rb +300 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d9ab862e12777068635829cbd6886a6738334834
|
4
|
+
data.tar.gz: d728bfa28a6e5be508db1f2f4e11db56d7eb92c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db6b7561514ffaa8ff2e11e80b594357bcdcac60606e4a4d206d8e386cebb52552471b1d2c0d8a20f12c09c822da319990d0abd7a808be1d2141818feca516cf
|
7
|
+
data.tar.gz: aac17875220554f4c77b4ac89033f7c5b031de60d8f7e4398af811fddd9c5022709f2551ca2c4f607c4d32c751a02520fb589f221c81f015b6d7cc4f82a7b400
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
$:.unshift 'lib'
|
5
|
+
|
6
|
+
desc 'Default: run unit tests.'
|
7
|
+
task :default => [:spec]
|
8
|
+
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
|
11
|
+
desc 'Run specs'
|
12
|
+
RSpec::Core::RakeTask.new do |t|
|
13
|
+
t.pattern = './spec/**/*_spec.rb'
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'noun-project-api/retriever'
|
2
|
+
|
3
|
+
module NounProjectApi
|
4
|
+
class Icon < Retriever
|
5
|
+
API_PATH = "/icon/"
|
6
|
+
|
7
|
+
def find(id)
|
8
|
+
raise ArgumentError.new('Missing id/slug') unless id
|
9
|
+
|
10
|
+
result = self.access_token.get("#{API_BASE}#{API_PATH}#{id}")
|
11
|
+
raise ArgumentError.new('Bad request') unless result.code == '200'
|
12
|
+
|
13
|
+
JSON.parse(result.body)
|
14
|
+
end
|
15
|
+
|
16
|
+
alias_method :find_by_slug, :find
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'noun-project-api/retriever'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module NounProjectApi
|
5
|
+
class Icons < Retriever
|
6
|
+
API_PATH = "/icons/"
|
7
|
+
|
8
|
+
def find(term, limit = nil, offset = nil, page = nil)
|
9
|
+
raise ArgumentError.new('Missing search term') unless term
|
10
|
+
|
11
|
+
search = URI::encode(term)
|
12
|
+
|
13
|
+
args = { "limit" => limit, "offset" => offset, "page" => page }.reject { |k, v| v.nil? }
|
14
|
+
if args.size > 0
|
15
|
+
search += '?'
|
16
|
+
args.each { |k, v| search += "#{k}=#{v}&" }
|
17
|
+
end
|
18
|
+
|
19
|
+
result = self.access_token.get("#{API_BASE}#{API_PATH}#{search}")
|
20
|
+
raise ArgumentError.new('Bad request') unless ['200', '404'].include? result.code
|
21
|
+
|
22
|
+
if result.code == '200'
|
23
|
+
JSON.parse(result.body)["icons"]
|
24
|
+
else
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def recent_uploads(limit = nil, offset = nil, page = nil)
|
30
|
+
args = { "limit" => limit, "offset" => offset, "page" => page }.reject { |k, v| v.nil? }
|
31
|
+
if args.size > 0
|
32
|
+
search = '?'
|
33
|
+
args.each { |k, v| search += "#{k}=#{v}&" }
|
34
|
+
else
|
35
|
+
search = ''
|
36
|
+
end
|
37
|
+
|
38
|
+
result = self.access_token.get("#{API_BASE}#{API_PATH}recent_uploads#{search}")
|
39
|
+
raise ArgumentError.new('Bad request') unless result.code == '200'
|
40
|
+
|
41
|
+
JSON.parse(result.body)["recent_uploads"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "oauth"
|
2
|
+
|
3
|
+
module NounProjectApi
|
4
|
+
API_BASE = 'http://api.thenounproject.com'
|
5
|
+
|
6
|
+
class Retriever
|
7
|
+
attr_accessor :token, :secret, :access_token
|
8
|
+
def initialize(token, secret)
|
9
|
+
@token = token
|
10
|
+
@secret = secret
|
11
|
+
raise ArgumentError.new('Missing token or secret') unless @token && @secret
|
12
|
+
|
13
|
+
@access_token = OAuth::AccessToken.new(OAuth::Consumer.new(token, secret))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
RSpec.describe NounProjectApi::Icon do
|
5
|
+
before :each do
|
6
|
+
@icon = NounProjectApi::Icon.new(Faker::Internet.password(16), Faker::Internet.password(16))
|
7
|
+
@valid_hash = JSON.parse(Fakes::Results::ICON_VALID)
|
8
|
+
@valid_response = OpenStruct.new(
|
9
|
+
body: Fakes::Results::ICON_VALID,
|
10
|
+
code: '200'
|
11
|
+
)
|
12
|
+
|
13
|
+
@missing_response = OpenStruct.new(
|
14
|
+
code: '404'
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
context "id" do
|
19
|
+
it 'raises an error when no id is provided' do
|
20
|
+
expect { @icon.find(nil) }.to raise_error(ArgumentError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns a proper result with a correct id' do
|
24
|
+
id = 1
|
25
|
+
expect(@icon.access_token).to receive(
|
26
|
+
:get
|
27
|
+
).with(
|
28
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icon::API_PATH}#{id}"
|
29
|
+
).and_return(
|
30
|
+
@valid_response
|
31
|
+
)
|
32
|
+
|
33
|
+
expect(@icon.find(id)).to eq(@valid_hash)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'raises an error with a missing id' do
|
37
|
+
id = 1
|
38
|
+
expect(@icon.access_token).to receive(
|
39
|
+
:get
|
40
|
+
).with(
|
41
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icon::API_PATH}#{id}"
|
42
|
+
).and_return(
|
43
|
+
@missing_response
|
44
|
+
)
|
45
|
+
|
46
|
+
expect { @icon.find(id) }.to raise_error(ArgumentError)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "slug" do
|
51
|
+
it 'raises an error when no slug is provided' do
|
52
|
+
expect { @icon.find_by_slug(nil) }.to raise_error(ArgumentError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns a proper result with a correct slug' do
|
56
|
+
slug = 'existing_slug'
|
57
|
+
expect(@icon.access_token).to receive(
|
58
|
+
:get
|
59
|
+
).with(
|
60
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icon::API_PATH}#{slug}"
|
61
|
+
).and_return(
|
62
|
+
@valid_response
|
63
|
+
)
|
64
|
+
|
65
|
+
expect(@icon.find_by_slug(slug)).to eq(@valid_hash)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'raises an error with a missing slug' do
|
69
|
+
slug = 'missing_slug'
|
70
|
+
expect(@icon.access_token).to receive(
|
71
|
+
:get
|
72
|
+
).with(
|
73
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icon::API_PATH}#{slug}"
|
74
|
+
).and_return(
|
75
|
+
@missing_response
|
76
|
+
)
|
77
|
+
|
78
|
+
expect { @icon.find_by_slug(slug) }.to raise_error(ArgumentError)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe NounProjectApi::Icons do
|
4
|
+
before :each do
|
5
|
+
@icons = NounProjectApi::Icons.new(Faker::Internet.password(16), Faker::Internet.password(16))
|
6
|
+
end
|
7
|
+
|
8
|
+
context "recent uploads" do
|
9
|
+
it "returns the recent uploads" do
|
10
|
+
valid_hash = JSON.parse(Fakes::Results::ICONS_RECENT_VALID)
|
11
|
+
valid_response = OpenStruct.new(
|
12
|
+
body: Fakes::Results::ICONS_RECENT_VALID,
|
13
|
+
code: '200'
|
14
|
+
)
|
15
|
+
|
16
|
+
expect(@icons.access_token).to receive(
|
17
|
+
:get
|
18
|
+
).with(
|
19
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icons::API_PATH}recent_uploads"
|
20
|
+
).and_return(
|
21
|
+
valid_response
|
22
|
+
)
|
23
|
+
|
24
|
+
expect(@icons.recent_uploads).to eq(valid_hash["recent_uploads"])
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the recent uploads and passes limit when passed" do
|
28
|
+
valid_hash = JSON.parse(Fakes::Results::ICONS_RECENT_VALID)
|
29
|
+
valid_response = OpenStruct.new(
|
30
|
+
body: Fakes::Results::ICONS_RECENT_VALID,
|
31
|
+
code: '200'
|
32
|
+
)
|
33
|
+
|
34
|
+
limit = 10
|
35
|
+
|
36
|
+
expect(@icons.access_token).to receive(
|
37
|
+
:get
|
38
|
+
).with(
|
39
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icons::API_PATH}recent_uploads?limit=#{limit}&"
|
40
|
+
).and_return(
|
41
|
+
valid_response
|
42
|
+
)
|
43
|
+
|
44
|
+
expect(@icons.recent_uploads(limit)).to eq(valid_hash["recent_uploads"])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "Icons search" do
|
49
|
+
it 'raises an error when no phrase is provided' do
|
50
|
+
expect { @icons.find(nil) }.to raise_error(ArgumentError)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'properly URI encodes search patterns' do
|
54
|
+
valid_hash = JSON.parse(Fakes::Results::ICONS_VALID)
|
55
|
+
valid_response = OpenStruct.new(
|
56
|
+
body: Fakes::Results::ICONS_VALID,
|
57
|
+
code: '200'
|
58
|
+
)
|
59
|
+
|
60
|
+
term = 'some search'
|
61
|
+
expect(@icons.access_token).to receive(
|
62
|
+
:get
|
63
|
+
).with(
|
64
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icons::API_PATH}#{URI::encode(term)}"
|
65
|
+
).and_return(
|
66
|
+
valid_response
|
67
|
+
)
|
68
|
+
|
69
|
+
expect(@icons.find(term)).to eq(valid_hash["icons"])
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns a proper result with a correct phrase' do
|
73
|
+
valid_hash = JSON.parse(Fakes::Results::ICONS_VALID)
|
74
|
+
valid_response = OpenStruct.new(
|
75
|
+
body: Fakes::Results::ICONS_VALID,
|
76
|
+
code: '200'
|
77
|
+
)
|
78
|
+
|
79
|
+
term = 'some search'
|
80
|
+
expect(@icons.access_token).to receive(
|
81
|
+
:get
|
82
|
+
).with(
|
83
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icons::API_PATH}#{URI::encode(term)}"
|
84
|
+
).and_return(
|
85
|
+
valid_response
|
86
|
+
)
|
87
|
+
|
88
|
+
expect(@icons.find(term)).to eq(valid_hash["icons"])
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'returns a proper result with a correct phrase and passes along the args' do
|
92
|
+
valid_hash = JSON.parse(Fakes::Results::ICONS_VALID)
|
93
|
+
valid_response = OpenStruct.new(
|
94
|
+
body: Fakes::Results::ICONS_VALID,
|
95
|
+
code: '200'
|
96
|
+
)
|
97
|
+
|
98
|
+
term = 'some search'
|
99
|
+
limit = 10
|
100
|
+
expect(@icons.access_token).to receive(
|
101
|
+
:get
|
102
|
+
).with(
|
103
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icons::API_PATH}#{URI::encode(term)}?limit=#{limit}&"
|
104
|
+
).and_return(
|
105
|
+
valid_response
|
106
|
+
)
|
107
|
+
|
108
|
+
expect(@icons.find(term, limit)).to eq(valid_hash["icons"])
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'returns an empty array for no result' do
|
112
|
+
missing_response = OpenStruct.new(
|
113
|
+
code: '404'
|
114
|
+
)
|
115
|
+
|
116
|
+
term = 'missing search'
|
117
|
+
expect(@icons.access_token).to receive(
|
118
|
+
:get
|
119
|
+
).with(
|
120
|
+
"#{NounProjectApi::API_BASE}#{NounProjectApi::Icons::API_PATH}#{URI::encode(term)}"
|
121
|
+
).and_return(
|
122
|
+
missing_response
|
123
|
+
)
|
124
|
+
|
125
|
+
expect(@icons.find(term)).to eq([])
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe NounProjectApi::Retriever do
|
4
|
+
it 'raises an error when initialized without token' do
|
5
|
+
expect { NounProjectApi::Retriever.new(nil, Faker::Internet.password(16)) }.to raise_error(ArgumentError)
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'raises an error when initialized without secret' do
|
9
|
+
expect { NounProjectApi::Retriever.new(Faker::Internet.password(16), nil) }.to raise_error(ArgumentError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'initializes the values properly' do
|
13
|
+
token = Faker::Internet.password(16)
|
14
|
+
secret = Faker::Internet.password(16)
|
15
|
+
retriever = NounProjectApi::Retriever.new(token, secret)
|
16
|
+
|
17
|
+
expect(retriever.token).to eq(token)
|
18
|
+
expect(retriever.secret).to eq(secret)
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "noun-project-api"
|
6
|
+
require "pry"
|
7
|
+
require "faker"
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
require_relative "support/fakes"
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.disable_monkey_patching!
|
14
|
+
config.formatter = "documentation"
|
15
|
+
config.color = true
|
16
|
+
end
|
@@ -0,0 +1,300 @@
|
|
1
|
+
module Fakes
|
2
|
+
module Results
|
3
|
+
ICON_VALID = '''
|
4
|
+
{
|
5
|
+
"icon": {
|
6
|
+
"term_slug": "beauty-salon",
|
7
|
+
"sponsor": {},
|
8
|
+
"year": 1974,
|
9
|
+
"license_description": "public-domain",
|
10
|
+
"id": "15",
|
11
|
+
"sponsor_campaign_link": null,
|
12
|
+
"icon_url": "https://d31dxqxrdzrtn7.cloudfront.net/svg/15.svg?Expires=1411066387&Signature=MfI5irHrMJDC94agEybPDdOPbriCkWibM-xmarR~g8wtz32oFSvEM9oECXazZfZrRCxixPeGSGxtOhSs~h0FZJeBchgR6tEMyhL7cWi8Phq-Z~cDNXTMy9mXmMWcy6fu0aBF5epiN38Ma3QCTAJhMWQn1pZJ1VOpSrsI4IB7zso_&Key-Pair-Id=APKAI5ZVHAXN65CHVU2Q",
|
13
|
+
"tags": [
|
14
|
+
{
|
15
|
+
"id": "10",
|
16
|
+
"slug": "haircut"
|
17
|
+
}
|
18
|
+
],
|
19
|
+
"collections": [
|
20
|
+
{
|
21
|
+
"permalink": "/edward/collection/aiga",
|
22
|
+
"is_collaborative": "",
|
23
|
+
"description": "",
|
24
|
+
"author": {
|
25
|
+
"permalink": "/edward",
|
26
|
+
"location": "Los Angeles, US",
|
27
|
+
"name": "Edward Boatman"
|
28
|
+
},
|
29
|
+
"date_updated": "2012-09-27 13:27:02",
|
30
|
+
"slug": "aiga",
|
31
|
+
"sponsor_campaign_link": "",
|
32
|
+
"is_featured": "1",
|
33
|
+
"name": "AIGA",
|
34
|
+
"is_store_item": "0",
|
35
|
+
"sponsor": {},
|
36
|
+
"template": "24",
|
37
|
+
"sponsor_id": "",
|
38
|
+
"date_created": "2012-01-27 19:15:26",
|
39
|
+
"author_id": "6",
|
40
|
+
"id": "3",
|
41
|
+
"tags": [],
|
42
|
+
"is_published": "1"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"permalink": "/edward/collection/noun-collection",
|
46
|
+
"is_collaborative": "",
|
47
|
+
"description": "",
|
48
|
+
"author": {
|
49
|
+
"permalink": "/edward",
|
50
|
+
"location": "Los Angeles, US",
|
51
|
+
"name": "Edward Boatman"
|
52
|
+
},
|
53
|
+
"date_updated": "2012-10-16 15:37:06",
|
54
|
+
"slug": "noun-collection",
|
55
|
+
"sponsor_campaign_link": "",
|
56
|
+
"is_featured": "0",
|
57
|
+
"name": "Noun Collection",
|
58
|
+
"is_store_item": "0",
|
59
|
+
"sponsor": {},
|
60
|
+
"template": "24",
|
61
|
+
"sponsor_id": "",
|
62
|
+
"date_created": "2012-01-27 19:15:07",
|
63
|
+
"author_id": "6",
|
64
|
+
"id": "1",
|
65
|
+
"tags": [],
|
66
|
+
"is_published": "0"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"date_uploaded": "",
|
70
|
+
"attribution": "Beauty Salon from The Noun Project",
|
71
|
+
"preview_url_84": "https://d31dxqxrdzrtn7.cloudfront.net/png/15-84.png",
|
72
|
+
"is_active": "1",
|
73
|
+
"permalink": "/term/beauty-salon/15",
|
74
|
+
"uploader": "",
|
75
|
+
"count_purchase": 0,
|
76
|
+
"sponsor_id": "",
|
77
|
+
"uploader_id": "",
|
78
|
+
"count_view": 1.0,
|
79
|
+
"term": "Beauty Salon",
|
80
|
+
"preview_url_42": "https://d31dxqxrdzrtn7.cloudfront.net/png/15-42.png",
|
81
|
+
"preview_url": "https://d31dxqxrdzrtn7.cloudfront.net/png/15-200.png",
|
82
|
+
"count_download": 0,
|
83
|
+
"term_id": 645
|
84
|
+
}
|
85
|
+
}
|
86
|
+
'''
|
87
|
+
|
88
|
+
ICONS_RECENT_VALID = '''
|
89
|
+
{
|
90
|
+
"recent_uploads": [
|
91
|
+
{
|
92
|
+
"term_slug": "mesh-network",
|
93
|
+
"sponsor": {},
|
94
|
+
"year": 2014,
|
95
|
+
"license_description": "public-domain",
|
96
|
+
"id": "74809",
|
97
|
+
"sponsor_campaign_link": null,
|
98
|
+
"icon_url": "https://d30y9cdsu7xlg0.cloudfront.net/icon_uploads/d8483846-e304-4191-9706-d10cf38ffaed.svg?Expires=1411066174&Signature=hc5-Zbi4d6i7kLqW~YF-sEvUzLUJaOdCvRsXN4ltT-OG1bOxmf8xz6Bw9EpCpZ85N5Z~Q6gRMHLMIGq2dgGZSwn75Ug3vsDFQkvsi5BybkyJuP7w7HqA-1jmYMGw8kJR00R9cryCrELmg7-k3qTrr8gqCgu0bH69brFvj87yjvs_&Key-Pair-Id=APKAI5ZVHAXN65CHVU2Q",
|
99
|
+
"date_uploaded": "2014-09-17",
|
100
|
+
"attribution": "Mesh Network by Jake Ingman from The Noun Project",
|
101
|
+
"preview_url_84": "https://d30y9cdsu7xlg0.cloudfront.net/png/74809-84.png",
|
102
|
+
"is_active": "1",
|
103
|
+
"permalink": "/term/mesh-network/74809",
|
104
|
+
"uploader": {
|
105
|
+
"permalink": "/jingman",
|
106
|
+
"location": "",
|
107
|
+
"name": "Jake Ingman"
|
108
|
+
},
|
109
|
+
"count_purchase": 0,
|
110
|
+
"sponsor_id": "",
|
111
|
+
"uploader_id": "60120",
|
112
|
+
"count_view": 4.0,
|
113
|
+
"term": "Mesh Network",
|
114
|
+
"preview_url_42": "https://d30y9cdsu7xlg0.cloudfront.net/png/74809-42.png",
|
115
|
+
"preview_url": "https://d30y9cdsu7xlg0.cloudfront.net/png/74809-200.png",
|
116
|
+
"count_download": 0,
|
117
|
+
"term_id": 3572
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"term": "Hour Glass",
|
121
|
+
"count_view": 147.0,
|
122
|
+
"permalink": "/term/hour-glass/74808",
|
123
|
+
"attribution": "Hour Glass by Thomas Helbig from The Noun Project",
|
124
|
+
"preview_url_42": "https://d30y9cdsu7xlg0.cloudfront.net/png/74808-42.png",
|
125
|
+
"preview_url_84": "https://d30y9cdsu7xlg0.cloudfront.net/png/74808-84.png",
|
126
|
+
"term_id": 1745,
|
127
|
+
"sponsor_campaign_link": null,
|
128
|
+
"is_active": "1",
|
129
|
+
"preview_url": "https://d30y9cdsu7xlg0.cloudfront.net/png/74808-200.png",
|
130
|
+
"count_download": 6.0,
|
131
|
+
"uploader_id": "38412",
|
132
|
+
"year": 2014,
|
133
|
+
"sponsor": {},
|
134
|
+
"uploader": {
|
135
|
+
"permalink": "/dergraph",
|
136
|
+
"location": "Berlin, DE",
|
137
|
+
"name": "Thomas Helbig"
|
138
|
+
},
|
139
|
+
"count_purchase": 0,
|
140
|
+
"sponsor_id": "",
|
141
|
+
"license_description": "creative-commons-attribution",
|
142
|
+
"term_slug": "hour-glass",
|
143
|
+
"id": "74808",
|
144
|
+
"date_uploaded": "2014-09-17"
|
145
|
+
},
|
146
|
+
{
|
147
|
+
"term": "Hour Glass",
|
148
|
+
"count_view": 8.0,
|
149
|
+
"permalink": "/term/hour-glass/74807",
|
150
|
+
"attribution": "Hour Glass by Matthieu Rodrigues from The Noun Project",
|
151
|
+
"preview_url_42": "https://d30y9cdsu7xlg0.cloudfront.net/png/74807-42.png",
|
152
|
+
"preview_url_84": "https://d30y9cdsu7xlg0.cloudfront.net/png/74807-84.png",
|
153
|
+
"term_id": 1745,
|
154
|
+
"sponsor_campaign_link": null,
|
155
|
+
"is_active": "1",
|
156
|
+
"preview_url": "https://d30y9cdsu7xlg0.cloudfront.net/png/74807-200.png",
|
157
|
+
"count_download": 0,
|
158
|
+
"uploader_id": "354457",
|
159
|
+
"year": 2014,
|
160
|
+
"sponsor": {},
|
161
|
+
"uploader": {
|
162
|
+
"permalink": "/mattrodrigues2",
|
163
|
+
"location": "Paris, FR",
|
164
|
+
"name": "Matthieu Rodrigues"
|
165
|
+
},
|
166
|
+
"count_purchase": 0,
|
167
|
+
"sponsor_id": "",
|
168
|
+
"license_description": "creative-commons-attribution",
|
169
|
+
"term_slug": "hour-glass",
|
170
|
+
"id": "74807",
|
171
|
+
"date_uploaded": "2014-09-17"
|
172
|
+
}
|
173
|
+
],
|
174
|
+
"generated_at": "Thu, 18 Sep 2014 18:09:34 GMT"
|
175
|
+
}'''
|
176
|
+
|
177
|
+
ICONS_VALID = '''
|
178
|
+
{
|
179
|
+
"generated_at": "Thu, 18 Sep 2014 17:48:10 GMT",
|
180
|
+
"icons": [
|
181
|
+
{
|
182
|
+
"term_slug": "fish",
|
183
|
+
"sponsor": {},
|
184
|
+
"year": 2012,
|
185
|
+
"license_description": "public-domain",
|
186
|
+
"id": "7770",
|
187
|
+
"sponsor_campaign_link": null,
|
188
|
+
"icon_url": "https://d31dxqxrdzrtn7.cloudfront.net/svg/3377c517-a6a9-477a-a446-cfcba9a4bca1.svg?Expires=1411066090&Signature=b1cvUOL9J2WPI2NK7gSG67as~CE9Abue4t4-i5insZMiVOgpu19xJVCiEdxLaAXs9ntK4BvHIe-KXB9FfkWZbWQ3lJFLq8Wxft0U-8y1Y9oPdU6jzVJhLr9AAtsma~dJLY7Fl3VYKGureUnarcibnl9w1k~kcJvHsv6myAWISAQ_&Key-Pair-Id=APKAI5ZVHAXN65CHVU2Q",
|
189
|
+
"collections": [],
|
190
|
+
"date_uploaded": "2012-11-15",
|
191
|
+
"attribution": "Fish by Tonielle Krisanski from The Noun Project",
|
192
|
+
"preview_url_84": "https://d31dxqxrdzrtn7.cloudfront.net/png/7770-84.png",
|
193
|
+
"is_active": "1",
|
194
|
+
"permalink": "/term/fish/7770",
|
195
|
+
"uploader": {
|
196
|
+
"permalink": "/tonikdesigns",
|
197
|
+
"location": "Melbourne, VIC, AU",
|
198
|
+
"name": "Tonielle Krisanski"
|
199
|
+
},
|
200
|
+
"count_purchase": 0,
|
201
|
+
"sponsor_id": "",
|
202
|
+
"uploader_id": "8916",
|
203
|
+
"count_view": 0,
|
204
|
+
"term": "Fish",
|
205
|
+
"preview_url_42": "https://d31dxqxrdzrtn7.cloudfront.net/png/7770-42.png",
|
206
|
+
"preview_url": "https://d31dxqxrdzrtn7.cloudfront.net/png/7770-200.png",
|
207
|
+
"count_download": 0,
|
208
|
+
"term_id": 857
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"term_slug": "fish",
|
212
|
+
"sponsor": {},
|
213
|
+
"year": 2013,
|
214
|
+
"license_description": "public-domain",
|
215
|
+
"id": "11742",
|
216
|
+
"sponsor_campaign_link": null,
|
217
|
+
"icon_url": "https://d31dxqxrdzrtn7.cloudfront.net/svg/aa552ef8-421c-4e51-86ae-d0a5af88603c.svg?Expires=1411066090&Signature=MINm35kcUBNMwPKdCMhPPuTI04Q0cYKnUqmnhtym-6Dz5ZrgIHmnKcduQDAeQvtWCn3TH6hAWaIVB1ex9-Mr7JtSg6VCaXB0MzLd1o80ASqaYEWq9AYkaVGOPag7qs2SFZkBjQInK9zM-hgfKJuGIGdfi5MWQdBTru9lWmHw90M_&Key-Pair-Id=APKAI5ZVHAXN65CHVU2Q",
|
218
|
+
"collections": [],
|
219
|
+
"date_uploaded": "2013-02-16",
|
220
|
+
"attribution": "Fish by James Keuning from The Noun Project",
|
221
|
+
"preview_url_84": "https://d31dxqxrdzrtn7.cloudfront.net/png/11742-84.png",
|
222
|
+
"is_active": "1",
|
223
|
+
"permalink": "/term/fish/11742",
|
224
|
+
"uploader": {
|
225
|
+
"permalink": "/jmkeuning",
|
226
|
+
"location": "Saint Paul, Minnesota, US",
|
227
|
+
"name": "James Keuning"
|
228
|
+
},
|
229
|
+
"count_purchase": 0,
|
230
|
+
"sponsor_id": "",
|
231
|
+
"uploader_id": "12121",
|
232
|
+
"count_view": 0,
|
233
|
+
"term": "Fish",
|
234
|
+
"preview_url_42": "https://d31dxqxrdzrtn7.cloudfront.net/png/11742-42.png",
|
235
|
+
"preview_url": "https://d31dxqxrdzrtn7.cloudfront.net/png/11742-200.png",
|
236
|
+
"count_download": 0,
|
237
|
+
"term_id": 857
|
238
|
+
},
|
239
|
+
{
|
240
|
+
"term_slug": "fish",
|
241
|
+
"sponsor": {},
|
242
|
+
"year": 2009,
|
243
|
+
"license_description": "public-domain",
|
244
|
+
"id": "12563",
|
245
|
+
"sponsor_campaign_link": null,
|
246
|
+
"icon_url": "https://d31dxqxrdzrtn7.cloudfront.net/svg/a5d6d6a1-5089-4be7-8726-264370be5795.svg?Expires=1411066090&Signature=hw-bWeETFTu~oKm59X8lq4eBGpljjf2S-8W3d5kOM1WAb67iM7nJIaPqjkUpf2L0fXKaGEZWz518MClZtCWlNjZWAM6wFf0hPSdvPIPa3pJ2TSuvaxe9a6m2Rd7kfWGAVuP361WiqCYKDV9KzrjfobD6N0HKBrSLDuEs1v9pJuo_&Key-Pair-Id=APKAI5ZVHAXN65CHVU2Q",
|
247
|
+
"collections": [],
|
248
|
+
"date_uploaded": "2013-03-02",
|
249
|
+
"attribution": "Fish by Jesse Jacob / iBureauet / Information Daily from The Noun Project",
|
250
|
+
"preview_url_84": "https://d31dxqxrdzrtn7.cloudfront.net/png/12563-84.png",
|
251
|
+
"is_active": "1",
|
252
|
+
"permalink": "/term/fish/12563",
|
253
|
+
"uploader": {
|
254
|
+
"permalink": "/Jesse Jacob",
|
255
|
+
"location": "",
|
256
|
+
"name": "Jesse Jacob / iBureauet / Information Daily"
|
257
|
+
},
|
258
|
+
"count_purchase": 0,
|
259
|
+
"sponsor_id": "",
|
260
|
+
"uploader_id": "50959",
|
261
|
+
"count_view": 0,
|
262
|
+
"term": "Fish",
|
263
|
+
"preview_url_42": "https://d31dxqxrdzrtn7.cloudfront.net/png/12563-42.png",
|
264
|
+
"preview_url": "https://d31dxqxrdzrtn7.cloudfront.net/png/12563-200.png",
|
265
|
+
"count_download": 0,
|
266
|
+
"term_id": 857
|
267
|
+
},
|
268
|
+
{
|
269
|
+
"term_slug": "fish",
|
270
|
+
"sponsor": {},
|
271
|
+
"year": 2013,
|
272
|
+
"license_description": "public-domain",
|
273
|
+
"id": "24913",
|
274
|
+
"sponsor_campaign_link": null,
|
275
|
+
"icon_url": "https://d31dxqxrdzrtn7.cloudfront.net/svg/3671fe0b-56db-498f-ba71-5c344379a126.svg?Expires=1411066090&Signature=Tu7hros2kT3wY84Gb-H2QlVQKYvSVwVv9xbl78AB~6pRlR0RUwzeSckeTY4GolBIo2XJigwzXvKo~M-6nfOlqbFfjyWwb0vsCuPI8ay1HOKUZZDJIZDI~dl2xpjbKLJfmOeafa0q1B0a9OEkxJoa81bS4g-83X0mTGCYQM8yLBs_&Key-Pair-Id=APKAI5ZVHAXN65CHVU2Q",
|
276
|
+
"collections": [],
|
277
|
+
"date_uploaded": "2013-10-20",
|
278
|
+
"attribution": "Fish by Teresa S Garner from The Noun Project",
|
279
|
+
"preview_url_84": "https://d31dxqxrdzrtn7.cloudfront.net/png/24913-84.png",
|
280
|
+
"is_active": "1",
|
281
|
+
"permalink": "/term/fish/24913",
|
282
|
+
"uploader": {
|
283
|
+
"permalink": "/sgarner",
|
284
|
+
"location": "US",
|
285
|
+
"name": "Teresa S Garner"
|
286
|
+
},
|
287
|
+
"count_purchase": 0,
|
288
|
+
"sponsor_id": "",
|
289
|
+
"uploader_id": "214620",
|
290
|
+
"count_view": 0,
|
291
|
+
"term": "Fish",
|
292
|
+
"preview_url_42": "https://d31dxqxrdzrtn7.cloudfront.net/png/24913-42.png",
|
293
|
+
"preview_url": "https://d31dxqxrdzrtn7.cloudfront.net/png/24913-200.png",
|
294
|
+
"count_download": 0,
|
295
|
+
"term_id": 857
|
296
|
+
}
|
297
|
+
]
|
298
|
+
}'''
|
299
|
+
end
|
300
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: noun-project-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nadav Shatz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: oauth
|
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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.1.0
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.1'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.1.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: faker
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description: A Gem to expose a wrapping API for The Noun Project API's
|
76
|
+
email: nadav@tailorbrands.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- Rakefile
|
82
|
+
- lib/noun-project-api.rb
|
83
|
+
- lib/noun-project-api/icon.rb
|
84
|
+
- lib/noun-project-api/icons.rb
|
85
|
+
- lib/noun-project-api/retriever.rb
|
86
|
+
- spec/lib/noun-project-api/icon_spec.rb
|
87
|
+
- spec/lib/noun-project-api/icons_spec.rb
|
88
|
+
- spec/lib/noun-project-api/retriever_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/support/fakes.rb
|
91
|
+
homepage: https://github.com/TailorBrands/noun-project-api
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.2.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: An API wrapper for The Noun Project API's
|
115
|
+
test_files:
|
116
|
+
- spec/lib/noun-project-api/icon_spec.rb
|
117
|
+
- spec/lib/noun-project-api/icons_spec.rb
|
118
|
+
- spec/lib/noun-project-api/retriever_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- spec/support/fakes.rb
|