wowzer 0.0.2 → 0.0.4

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.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ spec/internal/db/*.sqlite
6
+ spec/internal/config/database.yml
7
+ spec/internal/log/*
data/Gemfile CHANGED
@@ -7,4 +7,6 @@ group :development do
7
7
  gem 'rspec'
8
8
  gem 'rspec-rails'
9
9
  gem 'sqlite3'
10
+ gem 'webmock'
11
+ gem 'vcr'
10
12
  end
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wowzer (0.0.1)
4
+ wowzer (0.0.3)
5
5
  activerecord (~> 3.0)
6
6
  activesupport
7
- frenetic
7
+ hyperclient
8
8
  i18n
9
9
 
10
10
  GEM
@@ -43,19 +43,19 @@ GEM
43
43
  combustion (0.3.2)
44
44
  rails (>= 3.0.0)
45
45
  thor (>= 0.14.6)
46
+ crack (0.3.2)
46
47
  diff-lcs (1.1.3)
47
48
  erubis (2.7.0)
48
49
  faraday (0.8.7)
49
50
  multipart-post (~> 1.1)
50
51
  faraday_middleware (0.9.0)
51
52
  faraday (>= 0.7.4, < 0.9)
52
- frenetic (0.0.12)
53
- activesupport (>= 2)
54
- addressable (~> 2.2)
55
- faraday (~> 0.8.1)
56
- faraday_middleware (~> 0.9.0)
57
- rack-cache (~> 1.1)
58
53
  hike (1.2.1)
54
+ hyperclient (0.3.0)
55
+ faraday (~> 0.8)
56
+ faraday_middleware (~> 0.9)
57
+ net-http-digest_auth (~> 1.2)
58
+ uri_template (~> 0.5)
59
59
  i18n (0.6.1)
60
60
  journey (1.0.4)
61
61
  json (1.7.5)
@@ -66,6 +66,7 @@ GEM
66
66
  mime-types (1.19)
67
67
  multi_json (1.3.7)
68
68
  multipart-post (1.2.0)
69
+ net-http-digest_auth (1.2.1)
69
70
  polyglot (0.3.3)
70
71
  rack (1.4.1)
71
72
  rack-cache (1.2)
@@ -119,6 +120,11 @@ GEM
119
120
  polyglot
120
121
  polyglot (>= 0.3.1)
121
122
  tzinfo (0.3.35)
123
+ uri_template (0.5.2)
124
+ vcr (2.4.0)
125
+ webmock (1.11.0)
126
+ addressable (>= 2.2.7)
127
+ crack (>= 0.3.2)
122
128
 
123
129
  PLATFORMS
124
130
  ruby
@@ -128,4 +134,6 @@ DEPENDENCIES
128
134
  rspec
129
135
  rspec-rails
130
136
  sqlite3
137
+ vcr
138
+ webmock
131
139
  wowzer!
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://foo:bar@api.wowzerapp.com/hypermedia/interviews/5154134c572fc07efc002341
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Faraday v0.8.7
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 28 Mar 2013 11:11:28 GMT
25
+ Server:
26
+ - Apache/2.2.17 (Ubuntu)
27
+ Strict-Transport-Security:
28
+ - max-age=31536000
29
+ X-Ua-Compatible:
30
+ - IE=Edge,chrome=1
31
+ Etag:
32
+ - ! '"a91ebae499c9a63d521ef734c4ec4a03"'
33
+ Cache-Control:
34
+ - must-revalidate, private, max-age=0
35
+ X-Rack-Cache:
36
+ - miss
37
+ Set-Cookie:
38
+ - _novia_secure_session=c32db251d17a6b2f857d4efb93efa393; domain=wowzerapp.com;
39
+ path=/; HttpOnly; secure
40
+ Status:
41
+ - '200'
42
+ Content-Length:
43
+ - '603'
44
+ Content-Type:
45
+ - application/json; charset=utf-8
46
+ body:
47
+ encoding: US-ASCII
48
+ string: ! '{"id":"5154134c572fc07efc002341","title":"Tutor Application Interview","date_sent":"2013-03-28T10:15:00+00:00","status":"active","description":"Welcome
49
+ to the online interview to become a tutor with Teach Me 2!","open_for_new_applications":true,"_links":{"self":{"href":"https://api.wowzerapp.com/hypermedia/interviews/5154134c572fc07efc002341"},"wowzer:applications":{"href":"https://api.wowzerapp.com/hypermedia/interviews/5154134c572fc07efc002341/applications"},"wowzer:applications:bulk":{"href":"https://api.wowzerapp.com/hypermedia/interviews/5154134c572fc07efc002341/applications/bulk_create"}}}'
50
+ http_version: !!null
51
+ recorded_at: Thu, 28 Mar 2013 11:11:17 GMT
52
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,101 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://foo:bar@api.wowzerapp.com/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
+ - application/json
12
+ Accept:
13
+ - application/json
14
+ User-Agent:
15
+ - Faraday v0.8.7
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Date:
24
+ - Thu, 28 Mar 2013 10:22:20 GMT
25
+ Server:
26
+ - Apache/2.2.17 (Ubuntu)
27
+ Strict-Transport-Security:
28
+ - max-age=31536000
29
+ X-Ua-Compatible:
30
+ - IE=Edge,chrome=1
31
+ Etag:
32
+ - ! '"3c8cad57a3f3b92deec5b055735843aa"'
33
+ Cache-Control:
34
+ - must-revalidate, private, max-age=0
35
+ X-Rack-Cache:
36
+ - miss
37
+ Set-Cookie:
38
+ - _novia_secure_session=e124547c76b9699520918121784668e2; domain=wowzerapp.com;
39
+ path=/; HttpOnly; secure
40
+ Status:
41
+ - '200'
42
+ Content-Length:
43
+ - '520'
44
+ Content-Type:
45
+ - application/json; charset=utf-8
46
+ body:
47
+ encoding: US-ASCII
48
+ string: ! '{"_links":{"self":{"href":"https://api.wowzerapp.com"},"curie":{"name":"wowzer","templated":true,"href":"https://api.wowzerapp.com/docs/wowzer:{rel}"},"wowzer:interviews":{"href":"https://api.wowzerapp.com/hypermedia/interviews"},"wowzer:candidate":{"templated":true,"href":"https://api.wowzerapp.com/hypermedia/candidates{/id}"},"wowzer:application":{"templated":true,"href":"https://api.wowzerapp.com/hypermedia/applications{/id}"},"wowzer:notifications":{"href":"https://api.wowzerapp.com/hypermedia/notifications"}}}'
49
+ http_version: !!null
50
+ recorded_at: Thu, 28 Mar 2013 10:19:46 GMT
51
+ - request:
52
+ method: get
53
+ uri: https://foo:bar@api.wowzerapp.com/hypermedia/interviews
54
+ body:
55
+ encoding: US-ASCII
56
+ string: ''
57
+ headers:
58
+ Content-Type:
59
+ - application/json
60
+ Accept:
61
+ - application/json
62
+ User-Agent:
63
+ - Faraday v0.8.7
64
+ Accept-Encoding:
65
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Date:
72
+ - Thu, 28 Mar 2013 10:22:21 GMT
73
+ Server:
74
+ - Apache/2.2.17 (Ubuntu)
75
+ Strict-Transport-Security:
76
+ - max-age=31536000
77
+ X-Ua-Compatible:
78
+ - IE=Edge,chrome=1
79
+ Etag:
80
+ - ! '"897c6677b54287f4633c4c42fcdf80e2"'
81
+ Cache-Control:
82
+ - must-revalidate, private, max-age=0
83
+ X-Rack-Cache:
84
+ - miss
85
+ Set-Cookie:
86
+ - _novia_secure_session=323916ee0e3440acec1dda172876d045; domain=wowzerapp.com;
87
+ path=/; HttpOnly; secure
88
+ Status:
89
+ - '200'
90
+ Content-Length:
91
+ - '1345'
92
+ Content-Type:
93
+ - application/json; charset=utf-8
94
+ body:
95
+ encoding: US-ASCII
96
+ string: ! '{"count":2,"_links":{"self":{"href":"https://api.wowzerapp.com/hypermedia/interviews"},"wowzer:interview":{"templated":true,"href":"https://api.wowzerapp.com/hypermedia/interviews{/id}"}},"_embedded":{"wowzer:interview":[{"id":"5154134c572fc07efc002341","title":"Tutor
97
+ Application Interview","date_sent":"2013-03-28T10:15:00+00:00","status":"active","description":"Welcome
98
+ to the online interview to become a tutor with Teach Me 2!","open_for_new_applications":true,"_links":{"self":{"href":"https://api.wowzerapp.com/hypermedia/interviews/5154134c572fc07efc002341"},"wowzer:applications":{"href":"https://api.wowzerapp.com/hypermedia/interviews/5154134c572fc07efc002341/applications"},"wowzer:applications:bulk":{"href":"https://api.wowzerapp.com/hypermedia/interviews/5154134c572fc07efc002341/applications/bulk_create"}}},{"id":"51519ba8f4484b4bae000153","title":"Test","date_sent":"2013-03-26T13:03:13+00:00","status":"active","description":"Test","open_for_new_applications":true,"_links":{"self":{"href":"https://api.wowzerapp.com/hypermedia/interviews/51519ba8f4484b4bae000153"},"wowzer:applications":{"href":"https://api.wowzerapp.com/hypermedia/interviews/51519ba8f4484b4bae000153/applications"},"wowzer:applications:bulk":{"href":"https://api.wowzerapp.com/hypermedia/interviews/51519ba8f4484b4bae000153/applications/bulk_create"}}}]}}'
99
+ http_version: !!null
100
+ recorded_at: Thu, 28 Mar 2013 10:19:47 GMT
101
+ recorded_with: VCR 2.4.0
@@ -1,5 +1,26 @@
1
1
  module Wowzer
2
- class Application < Frenetic::Resource
3
- api_client Client
2
+ class Application
3
+
4
+ attr_accessor :attributes
5
+
6
+ def initialize(attributes)
7
+ self.attributes = attributes
8
+ end
9
+
10
+ def self.all
11
+ client.links['wowzer:interviews'].embedded['wowzer:interview'].map do |interview|
12
+ new(interview.attributes)
13
+ end
14
+ end
15
+
16
+ def self.find(id)
17
+ response = client.links['wowzer:interviews'].links['wowzer:interview'].expand(id: id).get
18
+ new(response.body)
19
+ end
20
+
21
+ def self.client
22
+ @@client ||= Client.new
23
+ end
24
+
4
25
  end
5
26
  end
data/lib/wowzer/client.rb CHANGED
@@ -1,16 +1,40 @@
1
1
  module Wowzer
2
2
 
3
3
  class Client
4
+ include Hyperclient
4
5
 
5
- MyAPI = ::Frenetic.new(
6
- 'url' => API_ENDPOINT,
7
- 'app_id' => APP_ID,
8
- 'api_key' => API_KEY,
9
- 'headers' => {
10
- 'accept' => 'application/hal+json',
11
- 'content-type' => 'application/json'
12
- }
13
- )
6
+ attr_accessor :api
7
+
8
+ def connect
9
+ api_endpoint = @api_endpoint
10
+ app_id = @app_id
11
+ api_key = @api_key
12
+
13
+ self.api ||= Hyperclient.new(api_endpoint).tap do |api|
14
+ api.basic_auth(app_id, api_key)
15
+ api.headers.merge({'accept' => 'application/hal+json', 'content-type' => 'application/json'})
16
+ end
17
+ end
18
+
19
+ def method_missing(method, *args, &block)
20
+ if api.respond_to?(method)
21
+ api.send(method, *args, &block)
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def app_id(app_id)
28
+ @app_id = app_id
29
+ end
30
+
31
+ def api_key(api_key)
32
+ @api_key = api_key
33
+ end
34
+
35
+ def api_endpoint(api_endpoint)
36
+ @api_endpoint = api_endpoint
37
+ end
14
38
 
15
39
  end
16
40
 
@@ -1,5 +1,26 @@
1
1
  module Wowzer
2
- class Interview < Frenetic::Resource
3
- api_client Client
2
+ class Interview
3
+
4
+ attr_accessor :attributes
5
+
6
+ def initialize(attributes)
7
+ self.attributes = attributes
8
+ end
9
+
10
+ def self.all
11
+ client.links['wowzer:interviews'].embedded['wowzer:interview'].map do |interview|
12
+ new(interview.attributes)
13
+ end
14
+ end
15
+
16
+ def self.find(id)
17
+ response = client.links['wowzer:interviews'].links['wowzer:interview'].expand(id: id).get
18
+ new(response.body)
19
+ end
20
+
21
+ def self.client
22
+ Wowzer::client
23
+ end
24
+
4
25
  end
5
26
  end
@@ -1,3 +1,3 @@
1
1
  module Wowzer
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/wowzer.rb CHANGED
@@ -1,13 +1,22 @@
1
1
  require "active_record"
2
- require "frenetic"
2
+ require "hyperclient"
3
3
 
4
4
  module Wowzer
5
5
 
6
- APP_ID = nil
7
- API_KEY = nil
8
- API_ENDPOINT = 'https://api.wowzerapp.com'
6
+ def self.client(&block)
7
+ @@client ||= Client.new
8
+
9
+ if block_given?
10
+ @@client.instance_eval(&block)
11
+ @@client.connect
12
+ end
13
+
14
+ @@client
15
+ end
9
16
 
10
17
  end
11
18
 
12
19
  require 'wowzer/version'
13
- require 'wowzer/client'
20
+ require 'wowzer/client'
21
+ require 'wowzer/interview'
22
+ #require 'wowzer/application'
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/wowzer_test.sqlite
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/wowzer_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,3 @@
1
+ ActiveRecord::Schema.define do
2
+
3
+ end
Binary file
File without changes
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wowzer::Interview do
4
+
5
+ it "should fetch all interviews" do
6
+ interviews = nil
7
+
8
+ VCR.use_cassette('interviews') do
9
+ interviews = Wowzer::Interview.all
10
+ end
11
+
12
+ interviews.count.should == 2
13
+
14
+ interview = interviews.first
15
+ interview.attributes.id.should == '5154134c572fc07efc002341'
16
+ interview.attributes.title.should == 'Tutor Application Interview'
17
+ interview.attributes.status.should == 'active'
18
+ interview.attributes.description.should == 'Welcome to the online interview to become a tutor with Teach Me 2!'
19
+ interview.attributes.open_for_new_applications.should == true
20
+ end
21
+
22
+ it "should fetch an interview by id" do
23
+ interview = nil
24
+
25
+ VCR.use_cassette('interview') do
26
+ interview = Wowzer::Interview.find('5154134c572fc07efc002341')
27
+ end
28
+
29
+ interview.attributes['id'].should == '5154134c572fc07efc002341'
30
+ interview.attributes['title'].should == 'Tutor Application Interview'
31
+ interview.attributes['status'].should == 'active'
32
+ interview.attributes['description'].should == 'Welcome to the online interview to become a tutor with Teach Me 2!'
33
+ interview.attributes['open_for_new_applications'].should == true
34
+ end
35
+
36
+ end
@@ -0,0 +1,31 @@
1
+
2
+ require 'rubygems'
3
+ require 'bundler'
4
+
5
+ Bundler.require :default, :development
6
+
7
+ Combustion.initialize! :active_record
8
+
9
+ require 'rspec/rails'
10
+
11
+ RSpec.configure do |config|
12
+ config.use_transactional_fixtures = true
13
+ config.color_enabled = true
14
+ config.formatter = :documentation # :progress, :html, :textmate
15
+ config.fixture_path = "#{::Rails.root}/fixtures"
16
+
17
+ config.before(:suite) do
18
+
19
+ Wowzer::client do
20
+ app_id 'foo'
21
+ api_key 'bar'
22
+ api_endpoint 'https://api.wowzerapp.com'
23
+ end
24
+
25
+ VCR.configure do |c|
26
+ c.cassette_library_dir = 'fixtures/vcr_cassettes'
27
+ c.hook_into :webmock
28
+ end
29
+
30
+ end
31
+ end
data/wowzer.gemspec CHANGED
@@ -21,7 +21,8 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency "activesupport"
22
22
  s.add_dependency "activerecord", "~> 3.0"
23
23
  s.add_dependency "i18n"
24
- s.add_dependency "frenetic"
24
+ #s.add_dependency "frenetic"
25
+ s.add_dependency "hyperclient"
25
26
 
26
27
  s.add_development_dependency 'combustion', '~> 0.3.1'
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wowzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-03-26 00:00:00.000000000 Z
13
+ date: 2013-03-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -61,7 +61,7 @@ dependencies:
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  - !ruby/object:Gem::Dependency
64
- name: frenetic
64
+ name: hyperclient
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements:
@@ -100,17 +100,28 @@ executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
+ - .gitignore
103
104
  - .rvmrc
104
105
  - Gemfile
105
106
  - Gemfile.lock
106
107
  - README.md
107
108
  - Rakefile
108
109
  - config.ru
110
+ - fixtures/vcr_cassettes/interview.yml
111
+ - fixtures/vcr_cassettes/interviews.yml
109
112
  - lib/wowzer.rb
110
113
  - lib/wowzer/application.rb
111
114
  - lib/wowzer/client.rb
112
115
  - lib/wowzer/interview.rb
113
116
  - lib/wowzer/version.rb
117
+ - spec/internal/config/database.yml
118
+ - spec/internal/config/database.yml.sample
119
+ - spec/internal/config/routes.rb
120
+ - spec/internal/db/schema.rb
121
+ - spec/internal/db/wowzer_test.sqlite
122
+ - spec/internal/public/favicon.ico
123
+ - spec/lib/wowzer/interview_spec.rb
124
+ - spec/spec_helper.rb
114
125
  - wowzer.gemspec
115
126
  homepage: ''
116
127
  licenses: []
@@ -136,4 +147,12 @@ rubygems_version: 1.8.24
136
147
  signing_key:
137
148
  specification_version: 3
138
149
  summary: A gem that integrates with the Wowzer API.
139
- test_files: []
150
+ test_files:
151
+ - spec/internal/config/database.yml
152
+ - spec/internal/config/database.yml.sample
153
+ - spec/internal/config/routes.rb
154
+ - spec/internal/db/schema.rb
155
+ - spec/internal/db/wowzer_test.sqlite
156
+ - spec/internal/public/favicon.ico
157
+ - spec/lib/wowzer/interview_spec.rb
158
+ - spec/spec_helper.rb