norseal-api 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64814eeb27a0c2516e032e0549964428f31c7c8a
4
- data.tar.gz: 75650b1e66c29282ec51ea34694a3776caf2fed8
3
+ metadata.gz: e6d2283e948c830885f7df452967acd4e4dcdb58
4
+ data.tar.gz: 0b05ffbffb8a7fbbeabd7bc1107191f3e6bca766
5
5
  SHA512:
6
- metadata.gz: c9de72528d2425e4cff608b1d8fcea0ae44ff0afd6d816db22181388b5fc698eb4b2fb5945958705cef49283afa2a89f427f20d7af684d5da276ce243fd578ec
7
- data.tar.gz: 59b70300d94b0ae3cce80b1179ea33f17bd1880b1f8cdcbd4b47a6f5f3076b0f080c52fbee1ec9b20a2c89c580933dc27dd4af9d8bb605777bbdb805625c56dc
6
+ metadata.gz: 5b91daf7f5656c6a22d6f5a87bfaefda5252b82da9decd3a62167b2d74dd27827b5b729b11d10aee360addc27d75ee5e3e8ac991a6065ca8a09f0e5ab4e45340
7
+ data.tar.gz: f234022869afa962b0831385c510b54ef9565b0b5677156acda39b77ca4399f688804da6deea62a5d77ab23f21c7a67018f9db23f277f695609eb3bca75f539c
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in norseal-api.gemspec
4
4
  gemspec
5
+
6
+ gem "pry"
@@ -7,8 +7,5 @@ require "norseal/api"
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
9
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
10
+ require "pry"
11
+ Pry.start
@@ -7,25 +7,47 @@ module Norseal
7
7
  module Api
8
8
  class ClientNotConfigured < Exception; end
9
9
 
10
+ class MyTokenAuth < Faraday::Middleware
11
+ def initialize(app, options = {})
12
+ @app = app
13
+ @options = options
14
+ end
15
+
16
+ def call(env)
17
+ env[:request_headers]["authorization"] = "Token token=#{@options[:token]}" if @options.include?(:token)
18
+ @app.call(env)
19
+ end
20
+ end
21
+
10
22
  def self.configure(host, api_key, &block)
11
23
  @api = Her::API.new
12
24
 
13
25
  @api.setup :url => "http://#{host}/" do |c|
14
- c.use FaradayMiddleware::EncodeJson
26
+ c.use Norseal::Api::MyTokenAuth, token: api_key
27
+ # c.use FaradayMiddleware::EncodeJson
15
28
  c.use Her::Middleware::AcceptJSON
16
- c.use Her::Middleware::FirstLevelParseJSON
29
+ # c.use Her::Middleware::FirstLevelParseJSON
30
+
31
+ # Response
32
+ c.use Her::Middleware::DefaultParseJSON
33
+
34
+ # Adapter
35
+ c.use Faraday::Adapter::NetHttp
36
+
37
+ c.use Faraday::Request::UrlEncoded
17
38
 
18
- c.authorization :token, api_key
39
+ # c.authorization :token, Token: api_key
19
40
 
20
41
  yield c if block_given?
21
42
 
22
- c.adapter Faraday.default_adapter unless c.builder.handlers.include?(Faraday::Adapter::Test)
43
+ # c.adapter Faraday.default_adapter# unless c.builder.handlers.include?(Faraday::Adapter::Test)
23
44
  end
24
45
 
25
46
  require "norseal/api/resources/collection"
26
47
  require "norseal/api/resources/product"
27
48
  require "norseal/api/resources/question"
28
49
  require "norseal/api/resources/manufacturer"
50
+ require "norseal/api/resources/attribute"
29
51
  end
30
52
 
31
53
  def self.api
@@ -0,0 +1,13 @@
1
+ module Norseal
2
+ module Api
3
+ class Attribute
4
+ include Her::Model
5
+ include Norseal::Api::Model
6
+
7
+ collection_path 'products/:id/attributes'
8
+
9
+ # has_many :questions
10
+ belongs_to :product
11
+ end
12
+ end
13
+ end
@@ -3,7 +3,6 @@ module Norseal
3
3
  class Collection
4
4
  include Her::Model
5
5
  include Norseal::Api::Model
6
-
7
6
  has_many :products
8
7
  end
9
8
  end
@@ -3,8 +3,7 @@ module Norseal
3
3
  class Manufacturer
4
4
  include Her::Model
5
5
  include Norseal::Api::Model
6
-
7
- has_many :products
6
+ has_many :products
8
7
  end
9
8
  end
10
9
  end
@@ -3,10 +3,7 @@ module Norseal
3
3
  class Product
4
4
  include Her::Model
5
5
  include Norseal::Api::Model
6
-
7
- collection_path "collections/:collection_id/products"
8
-
9
- has_many :questions
6
+ belongs_to :manufacturer
10
7
  end
11
8
  end
12
9
  end
@@ -3,8 +3,7 @@ module Norseal
3
3
  class Question
4
4
  include Her::Model
5
5
  include Norseal::Api::Model
6
-
7
- collection_path "collections/:collection_id/products/:product_id/questions"
6
+ belongs_to :product
8
7
  end
9
8
  end
10
9
  end
@@ -1,5 +1,5 @@
1
1
  module Norseal
2
2
  module Api
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norseal-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Barton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: her
@@ -99,6 +99,7 @@ files:
99
99
  - bin/setup
100
100
  - lib/norseal/api.rb
101
101
  - lib/norseal/api/model.rb
102
+ - lib/norseal/api/resources/attribute.rb
102
103
  - lib/norseal/api/resources/collection.rb
103
104
  - lib/norseal/api/resources/manufacturer.rb
104
105
  - lib/norseal/api/resources/product.rb
@@ -125,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  version: '0'
126
127
  requirements: []
127
128
  rubyforge_project:
128
- rubygems_version: 2.4.5
129
+ rubygems_version: 2.4.8
129
130
  signing_key:
130
131
  specification_version: 4
131
132
  summary: Consume the Norseal API.