nearfine-catalogs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 52bd1cf96292b95bb9305f1f2fc631fb792dce08
4
+ data.tar.gz: a638cea799586d59cdf780ebab36054633daef57
5
+ SHA512:
6
+ metadata.gz: a5541fe290d1d458664d6c4f959ce5f034f6a1504518d3967b52872945f86ebfadbfffb59708ac721495c0635cc435eaede35401068dcc6dadb4429cf48d8128
7
+ data.tar.gz: f3518c5da9407e31157b8c5426b481e4687e8816ee5ed271efc48f0427744899443d77ffb78e786ed862a0f4c946b05b43b56b0a829f12538b9cbfabee59564f
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2014 Hakan Ensari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/lib/catalog.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'virtus'
2
+ require 'doorkeeper'
3
+ require 'marketplace'
4
+
5
+ class Catalog
6
+ include Virtus.model
7
+
8
+ attribute :aws_access_key_id, String
9
+ attribute :aws_secret_key, String
10
+ attribute :merchant_id, String
11
+ attribute :marketplace, Marketplace
12
+
13
+ class << self
14
+ extend Forwardable
15
+ include Enumerable
16
+
17
+ def_delegator :@data, :each
18
+ alias :all :to_a
19
+ end
20
+
21
+ @data = Doorkeeper.fetch_data.map { |hsh| new(hsh) }
22
+ end
data/lib/doorkeeper.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'forwardable'
2
+ require 'json'
3
+ require 'excon'
4
+ require 'signature'
5
+
6
+ module Doorkeeper
7
+ extend self
8
+
9
+ def fetch_data
10
+ res = Excon.post(host, query: params)
11
+ JSON.load(res.body)
12
+ end
13
+
14
+ private
15
+
16
+ def params
17
+ request = Signature::Request.new('POST', '/', {})
18
+ token = Signature::Token.new(auth_key, auth_secret)
19
+
20
+ request.sign(token)
21
+ end
22
+
23
+ def host
24
+ ENV['DOORKEEPER_HOST'] or raise RuntimeError
25
+ end
26
+
27
+ def auth_key
28
+ ENV['DOORKEEPER_AUTH_KEY'] or raise RuntimeError
29
+ end
30
+
31
+ def auth_secret
32
+ ENV['DOORKEEPER_AUTH_SECRET'] or raise RuntimeError
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ require 'virtus'
2
+
3
+ class Marketplace
4
+ include Virtus.model
5
+
6
+ attribute :id, String
7
+ attribute :country_code, String
8
+ attribute :currency_code, String
9
+ attribute :language_code, String
10
+ attribute :hostname, String
11
+ end
@@ -0,0 +1 @@
1
+ require 'catalog'
data/test/helper.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
@@ -0,0 +1,10 @@
1
+ require_relative 'helper'
2
+ require 'catalog'
3
+
4
+ class TestCatalog < Minitest::Test
5
+ def test_returns_all
6
+ catalogs = Catalog.all
7
+ refute_empty catalogs
8
+ catalogs.each { |catalog| assert_kind_of Catalog, catalog }
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'helper'
2
+ require 'doorkeeper'
3
+
4
+ class TestDoorkeeper < Minitest::Test
5
+ def test_fetches_data
6
+ Excon.stub({}, { body: %q([{"foo":"bar"}]) })
7
+ refute_empty Doorkeeper.fetch_data
8
+ Excon.stubs.clear
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nearfine-catalogs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paper Cavalier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: excon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.31.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.31.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: signature
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: virtus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - LICENSE
90
+ - lib/catalog.rb
91
+ - lib/doorkeeper.rb
92
+ - lib/marketplace.rb
93
+ - lib/nearfine-catalogs.rb
94
+ - test/helper.rb
95
+ - test/test_catalog.rb
96
+ - test/test_doorkeeper.rb
97
+ homepage:
98
+ licenses: []
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.2.0
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Provides Nearfine catalogs
120
+ test_files:
121
+ - test/helper.rb
122
+ - test/test_catalog.rb
123
+ - test/test_doorkeeper.rb