quintype 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: fefb62987388a3665a201c7b5516bb4b16207319
4
- data.tar.gz: f2f0d1d2a058b4f884b9fd9848bc836d31022bdb
3
+ metadata.gz: d430c0d8abbab2960aa1b5302a8fb06068ef03dd
4
+ data.tar.gz: 46cadbb1a5dfcdca2fca6032d8aaea70fde60de1
5
5
  SHA512:
6
- metadata.gz: 6c1d743109ee6717b5d3ba473c93601387d0ff9f3b91085cdef31c81b0f9e8a5eda044b3defd55450b1d278a726c56656c2bf62c358927a51b7eb76e6c70b590
7
- data.tar.gz: 676ec05fe4c62ca5a8ac93e1a54de6c9cd721ee1496b514f1c4cb8dd7056d53c843f864a1dcd8853d0eee0a03afa27e2dab138f66ef32f6b14cc3c13dd7f6151
6
+ metadata.gz: 8fe5cc697c68488f7aa93e30e79fa4ef53c19040a95f9e9515b25082f926f8c9a41b2e1fd439f5cefa3ca142e373ae2e4b0108a8719da7ce87b67e46ba53bf61
7
+ data.tar.gz: 85d933e2a591e28ff9c64aea227b98493af327a44129544096bdd5e83c02a482064f75f9e2c93c3991836563bdbbe5f878fcba699ccd9e38cfbc69501bbdc967
data/.gitignore CHANGED
@@ -14,3 +14,5 @@
14
14
  .DS_Store
15
15
  .sass-cache/
16
16
  .byebug_history
17
+
18
+ /.idea/
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- quintype (0.0.0)
4
+ quintype (0.0.3)
5
5
  activesupport (~> 4.2)
6
6
  faraday (~> 0.9)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (4.2.5.1)
11
+ activesupport (4.2.7.1)
12
12
  i18n (~> 0.7)
13
13
  json (~> 1.7, >= 1.7.7)
14
14
  minitest (~> 5.1)
@@ -26,7 +26,7 @@ GEM
26
26
  i18n (0.7.0)
27
27
  json (1.8.3)
28
28
  method_source (0.8.2)
29
- minitest (5.8.4)
29
+ minitest (5.9.0)
30
30
  multipart-post (2.0.0)
31
31
  pry (0.10.3)
32
32
  coderay (~> 1.1.0)
@@ -66,3 +66,6 @@ DEPENDENCIES
66
66
  rspec (~> 3.4)
67
67
  vcr
68
68
  webmock
69
+
70
+ BUNDLED WITH
71
+ 1.11.2
@@ -27,10 +27,18 @@ class API
27
27
  _get("config")
28
28
  end
29
29
 
30
+ def sections
31
+ _get("sections")
32
+ end
33
+
30
34
  def story(story_id)
31
35
  _get("stories/#{story_id}")
32
36
  end
33
37
 
38
+ def tag_by_name(tag_name)
39
+ _get("tag/#{tag_name}")
40
+ end
41
+
34
42
  def story_by_slug(slug, params = {})
35
43
  _get("stories-by-slug", params.merge({ slug: slug }))
36
44
  end
@@ -127,8 +135,12 @@ class API
127
135
  _post("unsubscribe", { options: options })
128
136
  end
129
137
 
130
- def save_member_metadata(metadata)
131
- _post("member/metadata", { metadata: metadata })
138
+ def save_member_metadata(metadata, session_cookie)
139
+ _post("member/metadata", { metadata: metadata }, session_cookie)
140
+ end
141
+
142
+ def get_member_metadata(session_cookie)
143
+ _get("member/metadata", {}, { auth_token: session_cookie})
132
144
  end
133
145
 
134
146
  def check_email(email)
@@ -197,8 +209,12 @@ class API
197
209
  end
198
210
  end
199
211
 
200
- def _get(url_path, *args)
201
- response = @@conn.get(@@api_base + url_path, *args)
212
+ def _get(url_path, params={}, args={})
213
+ response = @@conn.get(@@api_base + url_path, params) do |request|
214
+ request.headers['Content-Type'] = 'application/json'
215
+ request.headers['X-QT-AUTH'] = args[:auth_token] if args[:auth_token]
216
+ end
217
+
202
218
  return nil if response.status >= 400
203
219
 
204
220
  if response.body.present?
@@ -0,0 +1,32 @@
1
+ class API
2
+ class Tag
3
+ attr_reader :tag
4
+ class << self
5
+
6
+ def wrap_all(tags)
7
+ tags ||= []
8
+ tags.is_a?(Array) ?
9
+ tags.map {|t| wrap(t)} :
10
+ wrap(tags)
11
+ end
12
+
13
+ def wrap(tag)
14
+ new(tag) if tag
15
+ end
16
+
17
+ def find_by_name(name)
18
+ if tag = API.tag_by_name(name)
19
+ wrap(tag)
20
+ end
21
+ end
22
+ end
23
+
24
+ def initialize(tag)
25
+ @tag = tag
26
+ end
27
+
28
+ def to_h(config={})
29
+ tag
30
+ end
31
+ end
32
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'quintype'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.date = '2016-02-19'
5
5
  s.summary = "quintype!"
6
6
  s.platform = Gem::Platform::RUBY
@@ -0,0 +1,26 @@
1
+ require_relative '../../lib/quintype/api/tag'
2
+
3
+ describe API::Tag do
4
+ describe '#find_by_name' , :vcr => { cassette_name: "api_tag_find" } do
5
+ it 'finds the tag by name' do
6
+ tag = described_class.find_by_name("bloomberg")
7
+ expect(tag.to_h).to_not be_empty
8
+ end
9
+ end
10
+
11
+
12
+ describe '#to_h' do
13
+ it 'has tag', :vcr => { cassette_name: "api_tag_find" } do
14
+ tag = described_class.find_by_name("bloomberg")
15
+ expect(tag.to_h.keys).to include("tag")
16
+ end
17
+
18
+ it 'serializes tag' , :vcr => { cassette_name: "api_tag_find" } do
19
+ tag = described_class.find_by_name("bloomberg")
20
+ expect(tag.to_h["tag"].keys).to include("name", "meta_description")
21
+ end
22
+ end
23
+ end
24
+
25
+
26
+
@@ -0,0 +1,34 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8001/api/tag/bloomberg
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Access-Control-Allow-Origin:
22
+ - "*"
23
+ Content-Type:
24
+ - application/json
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Server:
28
+ - Jetty(9.3.7.v20160115)
29
+ body:
30
+ encoding: ASCII-8BIT
31
+ string: '{"tag": {"id": 12345, "name": "bloomberg", "meta-description": "publisher"}}'
32
+ http_version:
33
+ recorded_at: Fri, 22 Apr 2016 03:29:52 GMT
34
+ recorded_with: VCR 3.0.1
@@ -54,8 +54,8 @@ RSpec.configure do |config|
54
54
  mocks.verify_partial_doubles = true
55
55
  end
56
56
 
57
- # The settings below are suggested to provide a good initial experience
58
- # with RSpec, but feel free to customize to your heart's content.
57
+ # The settings below are suggested to provide a good initial experience
58
+ # with RSpec, but feel free to customize to your heart's content.
59
59
  =begin
60
60
  # These two settings work together to allow you to limit a spec run
61
61
  # to individual examples or groups you care about by tagging them with
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quintype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -54,11 +54,13 @@ files:
54
54
  - lib/quintype/api/stack.rb
55
55
  - lib/quintype/api/story.rb
56
56
  - lib/quintype/api/story/reading_time.rb
57
+ - lib/quintype/api/tag.rb
57
58
  - lib/quintype/api/url.rb
58
59
  - lib/quintype/engine.rb
59
60
  - quintype.gemspec
60
61
  - spec/api/stack_spec.rb
61
62
  - spec/api/story_spec.rb
63
+ - spec/api/tag_spec.rb
62
64
  - spec/fixtures/vcr_cassettes/api_stack_all.yml
63
65
  - spec/fixtures/vcr_cassettes/api_stack_stories_with_params.yml
64
66
  - spec/fixtures/vcr_cassettes/api_stack_with_stories.yml
@@ -70,6 +72,7 @@ files:
70
72
  - spec/fixtures/vcr_cassettes/api_story_find_by_stacks_and_sections.yml
71
73
  - spec/fixtures/vcr_cassettes/api_story_find_config.yml
72
74
  - spec/fixtures/vcr_cassettes/api_story_find_in_bulk.yml
75
+ - spec/fixtures/vcr_cassettes/api_tag_find.yml
73
76
  - spec/spec_helper.rb
74
77
  - spec/unit/api_spec.rb
75
78
  homepage: http://rubygems.org/gems/quintype
@@ -92,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
95
  version: '0'
93
96
  requirements: []
94
97
  rubyforge_project:
95
- rubygems_version: 2.5.1
98
+ rubygems_version: 2.2.2
96
99
  signing_key:
97
100
  specification_version: 4
98
101
  summary: quintype!