display_words 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +37 -0
- data/README +5 -0
- data/display_words.gemspec +24 -0
- data/lib/display_words.rb +24 -0
- data/lib/display_words/api.rb +18 -0
- data/lib/display_words/authentication.rb +42 -0
- data/lib/display_words/client.rb +9 -0
- data/lib/display_words/client/inventory_source.rb +15 -0
- data/lib/display_words/configuration.rb +36 -0
- data/lib/display_words/request.rb +43 -0
- data/lib/display_words/version.rb +4 -0
- data/spec/display_words/api_spec.rb +66 -0
- data/spec/display_words/client/inventory_source_spec.rb +93 -0
- data/spec/display_words_spec.rb +26 -0
- data/spec/fixtures/auth.json +6 -0
- data/spec/fixtures/inventory_source.json +29 -0
- data/spec/fixtures/inventory_sources.json +73 -0
- data/spec/spec_helper.rb +53 -0
- metadata +170 -0
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.8.7-p330@display_words
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
display_words (0.0.1)
|
5
|
+
httparty (~> 0.7.7)
|
6
|
+
json_pure (~> 1.5)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.2.5)
|
12
|
+
crack (0.1.8)
|
13
|
+
diff-lcs (1.1.2)
|
14
|
+
httparty (0.7.7)
|
15
|
+
crack (= 0.1.8)
|
16
|
+
json_pure (1.5.1)
|
17
|
+
rake (0.8.7)
|
18
|
+
rspec (2.5.0)
|
19
|
+
rspec-core (~> 2.5.0)
|
20
|
+
rspec-expectations (~> 2.5.0)
|
21
|
+
rspec-mocks (~> 2.5.0)
|
22
|
+
rspec-core (2.5.2)
|
23
|
+
rspec-expectations (2.5.0)
|
24
|
+
diff-lcs (~> 1.1.2)
|
25
|
+
rspec-mocks (2.5.0)
|
26
|
+
webmock (1.6.2)
|
27
|
+
addressable (>= 2.2.2)
|
28
|
+
crack (>= 0.1.7)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
display_words!
|
35
|
+
rake (~> 0.8)
|
36
|
+
rspec (~> 2.5)
|
37
|
+
webmock (~> 1.6)
|
data/README
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/display_words/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.add_development_dependency('rake', '~> 0.8')
|
6
|
+
s.add_development_dependency('rspec', '~> 2.5')
|
7
|
+
s.add_development_dependency('webmock', '~> 1.6')
|
8
|
+
s.add_runtime_dependency('json_pure', '~> 1.5')
|
9
|
+
s.add_runtime_dependency('httparty', '~> 0.7.7')
|
10
|
+
s.authors = ["Will Watson"]
|
11
|
+
s.description = %q{A Ruby wrapper for the DisplayWords API}
|
12
|
+
s.email = ['will@ackmanndickenson.com']
|
13
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.homepage = 'https://github.com/ackmann-dickenson/display_words'
|
16
|
+
s.name = 'display_words'
|
17
|
+
s.platform = Gem::Platform::RUBY
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
|
20
|
+
s.rubyforge_project = s.name
|
21
|
+
s.summary = %q{Ruby wrapper for the DisplayWords API}
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.version = DisplayWords::VERSION.dup
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
require File.expand_path('../display_words/configuration', __FILE__)#can this not use expand_path?
|
5
|
+
require File.expand_path('../display_words/api', __FILE__)
|
6
|
+
require File.expand_path('../display_words/client', __FILE__)
|
7
|
+
|
8
|
+
module DisplayWords
|
9
|
+
extend Configuration
|
10
|
+
|
11
|
+
def self.client(options = {})
|
12
|
+
DisplayWords::Client.new(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Delegate to DisplayWords::Client
|
16
|
+
# def self.method_missing(method, *args, &block)
|
17
|
+
# return super unless client.respond_to?(method)
|
18
|
+
# client.send(method, *args, &block)
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# def self.respond_to?(method, include_private = false)
|
22
|
+
# client.respond_to?(method, include_private) || super(method, include_private)
|
23
|
+
# end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../request', __FILE__)
|
2
|
+
|
3
|
+
module DisplayWords
|
4
|
+
class API
|
5
|
+
attr_accessor *Configuration::VALID_OPTIONS_KEYS
|
6
|
+
|
7
|
+
include DisplayWords::Request
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
self.class.base_uri options[:domain]
|
11
|
+
|
12
|
+
options = DisplayWords.options.merge(options)
|
13
|
+
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
14
|
+
send("#{key}=", options[key])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module DisplayWords
|
2
|
+
module Request
|
3
|
+
module Authentication
|
4
|
+
ENDPOINT = '/auth'
|
5
|
+
|
6
|
+
attr_accessor :token, :token_expire
|
7
|
+
|
8
|
+
def authenticate(username, password)
|
9
|
+
options = authentication_options(username, password)
|
10
|
+
|
11
|
+
response = post(ENDPOINT, options)
|
12
|
+
|
13
|
+
@token_expire = Time.now + (2 * 60 * 60) #Token expires two hours from when it was given
|
14
|
+
@token = response['token']
|
15
|
+
end
|
16
|
+
|
17
|
+
def expired_token?
|
18
|
+
token_expire <= Time.now
|
19
|
+
end
|
20
|
+
|
21
|
+
def authentication_needed?
|
22
|
+
!token || expired_token?
|
23
|
+
end
|
24
|
+
|
25
|
+
def authentication_options(username, password)
|
26
|
+
credentials = {
|
27
|
+
:auth => {
|
28
|
+
:username => username,
|
29
|
+
:password => password
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
{
|
34
|
+
:body => credentials.to_json,
|
35
|
+
:headers => {
|
36
|
+
"content_type" => "json"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DisplayWords
|
2
|
+
class Client
|
3
|
+
module InventorySource
|
4
|
+
def inventory_source(id)
|
5
|
+
response = get("/inventory-source/?id=#{id}")
|
6
|
+
response['inventory-source']
|
7
|
+
end
|
8
|
+
|
9
|
+
def inventory_sources(start = 0, num = Client::DEFAULT_RESULT_LIMIT)
|
10
|
+
response = get("/inventory-source?start_element=#{start}&num_elements=#{num}")
|
11
|
+
response['inventory-sources']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module DisplayWords
|
2
|
+
module Configuration
|
3
|
+
VALID_OPTIONS_KEYS = [:username, :password, :domain, :format]
|
4
|
+
VALID_FORMATS = [:json]
|
5
|
+
|
6
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
7
|
+
|
8
|
+
DEFAULT_DOMAIN = 'http://hb.sand-08.adnxs.net/'
|
9
|
+
DEFAULT_FORMAT = 'json'
|
10
|
+
|
11
|
+
# When this module is extended, set all configuration options to their default values
|
12
|
+
def self.extended(base)
|
13
|
+
base.reset
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
# Convenience method to allow configuration options to be set in a block
|
18
|
+
def configure
|
19
|
+
yield self
|
20
|
+
end
|
21
|
+
|
22
|
+
# Create a hash of options and their values
|
23
|
+
def options
|
24
|
+
options = {}
|
25
|
+
VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) }
|
26
|
+
options
|
27
|
+
end
|
28
|
+
|
29
|
+
# Reset all configuration options to defaults
|
30
|
+
def reset
|
31
|
+
self.domain = DEFAULT_DOMAIN
|
32
|
+
self.format = DEFAULT_FORMAT
|
33
|
+
self
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../authentication', __FILE__)
|
2
|
+
|
3
|
+
module DisplayWords
|
4
|
+
module Request
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
include HTTParty
|
8
|
+
include Authentication
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(path, options = {})
|
13
|
+
request(:get, path, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def post(path, options = {})
|
17
|
+
request(:post, path, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def request(method, path, options)
|
23
|
+
authenticate(@username, @password) if authentication_needed? && path != Authentication::ENDPOINT
|
24
|
+
|
25
|
+
options[:headers] ||= {}
|
26
|
+
options[:headers]['authorization'] = token if token
|
27
|
+
response = case method
|
28
|
+
when :post
|
29
|
+
self.class.post(
|
30
|
+
path,
|
31
|
+
options
|
32
|
+
)
|
33
|
+
when :get
|
34
|
+
self.class.get(
|
35
|
+
path,
|
36
|
+
options
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
response['response']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe DisplayWords::API do
|
4
|
+
before do
|
5
|
+
@keys = DisplayWords::Configuration::VALID_OPTIONS_KEYS
|
6
|
+
end
|
7
|
+
|
8
|
+
context "with module configuration" do
|
9
|
+
before do
|
10
|
+
DisplayWords.configure do |config|
|
11
|
+
@keys.each do |key|
|
12
|
+
config.send("#{key}=", key)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
after do
|
18
|
+
DisplayWords.reset
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should inherit module configuration" do
|
22
|
+
api = DisplayWords::API.new
|
23
|
+
@keys.each do |key|
|
24
|
+
api.send(key).should == key
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with class configuration" do
|
29
|
+
|
30
|
+
before do
|
31
|
+
@configuration = {
|
32
|
+
:username => 'U',
|
33
|
+
:password => 'P',
|
34
|
+
:domain => 'http://www.d.com',
|
35
|
+
:format => 'json'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
context "during initialization"
|
40
|
+
|
41
|
+
it "should override module configuration" do
|
42
|
+
api = DisplayWords::API.new(@configuration)
|
43
|
+
@keys.each do |key|
|
44
|
+
api.send(key).should == @configuration[key]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "after initilization" do
|
49
|
+
|
50
|
+
it "should override module configuration after initialization" do
|
51
|
+
api = DisplayWords::API.new
|
52
|
+
@configuration.each do |key, value|
|
53
|
+
api.send("#{key}=", value)
|
54
|
+
end
|
55
|
+
@keys.each do |key|
|
56
|
+
api.send(key).should == @configuration[key]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should have set the base_uri" do
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
|
3
|
+
describe DisplayWords::Client do
|
4
|
+
DisplayWords::Configuration::VALID_FORMATS.each do |format|
|
5
|
+
context ".new" do
|
6
|
+
before do
|
7
|
+
@client = DisplayWords::Client.new(:username => 'u', :password => 'p', :domain => "http://hb.sand-08.adnxs.net/")
|
8
|
+
@client.stub(:authentication_needed?).and_return(false)
|
9
|
+
@client.stub(:token).and_return("abcdefg")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".inventory_sources" do
|
13
|
+
before do
|
14
|
+
@client.stub(:get).
|
15
|
+
with("/inventory-source?start_element=0&num_elements=100").and_return(fixture_json("inventory_sources.json")['response'])
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should get the correct resource" do
|
19
|
+
@client.should_receive(:get).with("/inventory-source?start_element=0&num_elements=100")
|
20
|
+
@client.inventory_sources
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return inventory sources" do
|
24
|
+
inventory_sources = @client.inventory_sources
|
25
|
+
inventory_sources.should be_an Array
|
26
|
+
inventory_sources.first['name'].should == "Premium Nature 1"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# describe ".direct_messages_sent" do
|
31
|
+
#
|
32
|
+
# before do
|
33
|
+
# stub_get("direct_messages/sent.#{format}").
|
34
|
+
# to_return(:body => fixture("direct_messages.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# it "should get the correct resource" do
|
38
|
+
# @client.direct_messages_sent
|
39
|
+
# a_get("direct_messages/sent.#{format}").
|
40
|
+
# should have_been_made
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# it "should return the 20 most recent direct messages sent by the authenticating user" do
|
44
|
+
# direct_messages = @client.direct_messages_sent
|
45
|
+
# direct_messages.should be_an Array
|
46
|
+
# direct_messages.first.sender.name.should == "Erik Michaels-Ober"
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# describe ".direct_message_create" do
|
52
|
+
#
|
53
|
+
# before do
|
54
|
+
# stub_post("direct_messages/new.#{format}").
|
55
|
+
# with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the DisplayWords gem"}).
|
56
|
+
# to_return(:body => fixture("direct_message.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# it "should get the correct resource" do
|
60
|
+
# @client.direct_message_create("pengwynn", "Creating a fixture for the DisplayWords gem")
|
61
|
+
# a_post("direct_messages/new.#{format}").
|
62
|
+
# with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the DisplayWords gem"}).
|
63
|
+
# should have_been_made
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# it "should return the sent message" do
|
67
|
+
# direct_message = @client.direct_message_create("pengwynn", "Creating a fixture for the DisplayWords gem")
|
68
|
+
# direct_message.text.should == "Creating a fixture for the DisplayWords gem"
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# describe ".direct_message_destroy" do
|
74
|
+
#
|
75
|
+
# before do
|
76
|
+
# stub_delete("direct_messages/destroy/1825785544.#{format}").
|
77
|
+
# to_return(:body => fixture("direct_message.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
|
78
|
+
# end
|
79
|
+
#
|
80
|
+
# it "should get the correct resource" do
|
81
|
+
# @client.direct_message_destroy(1825785544)
|
82
|
+
# a_delete("direct_messages/destroy/1825785544.#{format}").
|
83
|
+
# should have_been_made
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# it "should return the deleted message" do
|
87
|
+
# direct_message = @client.direct_message_destroy(1825785544)
|
88
|
+
# direct_message.text.should == "Creating a fixture for the DisplayWords gem"
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DisplayWords do
|
4
|
+
after do
|
5
|
+
DisplayWords.reset
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ".client" do
|
9
|
+
it "should be a DisplayWords::Client" do
|
10
|
+
DisplayWords.client.should be_a DisplayWords::Client
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".domain" do
|
15
|
+
it "should return the default domain" do
|
16
|
+
DisplayWords.domain.should == DisplayWords::Configuration::DEFAULT_DOMAIN
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".domain=" do
|
21
|
+
it "should set the endpoint" do
|
22
|
+
DisplayWords.domain = 'https://api.displaywords.com/'
|
23
|
+
DisplayWords.domain.should == 'https://api.displaywords.com/'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"response": {
|
3
|
+
"status": "OK",
|
4
|
+
"inventory-source": {
|
5
|
+
"id": 14,
|
6
|
+
"name": "MyYearbook",
|
7
|
+
"description": "",
|
8
|
+
"aggregator": "MyYearbook",
|
9
|
+
"url": "myyearbook.com",
|
10
|
+
"integration_type": "premium_first",
|
11
|
+
"monthly_volume": 464493100,
|
12
|
+
"monthly_uniques": 5638924,
|
13
|
+
"daily_volume": 1123983,
|
14
|
+
"daily_uniques": 659323,
|
15
|
+
"member_id": null,
|
16
|
+
"class": "class_3",
|
17
|
+
"status": "reviewed",
|
18
|
+
"created_on": "2009-11-02 05:00:00",
|
19
|
+
"discrepancy_pct": null,
|
20
|
+
"curated_type": "appnexus",
|
21
|
+
"inventory_exposure": "public",
|
22
|
+
"last_modified": "2010-10-15 00:11:43",
|
23
|
+
"ecp": 0.91957,
|
24
|
+
"age_coverage": 0.994941,
|
25
|
+
"gender_coverage": 0.994845,
|
26
|
+
"expose_domains": true
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
{
|
2
|
+
"response":{
|
3
|
+
"status":"OK",
|
4
|
+
"inventory-sources":[
|
5
|
+
{
|
6
|
+
"id":2,
|
7
|
+
"name":"Premium Nature 1",
|
8
|
+
"description":"",
|
9
|
+
"aggregator":"AdMeld",
|
10
|
+
"url":"",
|
11
|
+
"integration_type":"remnant_first",
|
12
|
+
"monthly_volume":0,
|
13
|
+
"monthly_uniques":0,
|
14
|
+
"daily_volume":0,
|
15
|
+
"daily_uniques":0,
|
16
|
+
"member_id":null,
|
17
|
+
"class":"class_3",
|
18
|
+
"status":"pending",
|
19
|
+
"created_on":"2009-11-02 05:00:00",
|
20
|
+
"discrepancy_pct":5,
|
21
|
+
"curated_type":"appnexus",
|
22
|
+
"inventory_exposure":"public",
|
23
|
+
"last_modified":"2010-04-14 14:35:56",
|
24
|
+
"ecp":null
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"id":3,
|
28
|
+
"name":"Premium Human Behavior 1",
|
29
|
+
"description":"",
|
30
|
+
"aggregator":"AdMeld",
|
31
|
+
"url":"",
|
32
|
+
"integration_type":"remnant_first",
|
33
|
+
"monthly_volume":0,
|
34
|
+
"monthly_uniques":0,
|
35
|
+
"daily_volume":0,
|
36
|
+
"daily_uniques":0,
|
37
|
+
"member_id":null,
|
38
|
+
"class":"class_3",
|
39
|
+
"status":"pending",
|
40
|
+
"created_on":"2009-11-02 05:00:00",
|
41
|
+
"discrepancy_pct":5,
|
42
|
+
"curated_type":"appnexus",
|
43
|
+
"inventory_exposure":"public",
|
44
|
+
"last_modified":"2010-04-14 14:35:56",
|
45
|
+
"ecp":null
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"id":4,
|
49
|
+
"name":"Premium Health 1",
|
50
|
+
"description":"",
|
51
|
+
"aggregator":"AdMeld",
|
52
|
+
"url":"",
|
53
|
+
"integration_type":"remnant_first",
|
54
|
+
"monthly_volume":0,
|
55
|
+
"monthly_uniques":0,
|
56
|
+
"daily_volume":0,
|
57
|
+
"daily_uniques":0,
|
58
|
+
"member_id":null,
|
59
|
+
"class":"class_3",
|
60
|
+
"status":"pending",
|
61
|
+
"created_on":"2009-11-02 05:00:00",
|
62
|
+
"discrepancy_pct":5,
|
63
|
+
"curated_type":"appnexus",
|
64
|
+
"inventory_exposure":"public",
|
65
|
+
"last_modified":"2010-04-14 14:35:56",
|
66
|
+
"ecp":null
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"count":769,
|
70
|
+
"start_element":1,
|
71
|
+
"num_elments":3
|
72
|
+
}
|
73
|
+
}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path('../../lib/display_words.rb', __FILE__)
|
2
|
+
require 'rspec'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.include WebMock::API
|
7
|
+
end
|
8
|
+
|
9
|
+
def a_delete(path)
|
10
|
+
a_request(:delete, DisplayWords.domain + path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def a_get(path)
|
14
|
+
a_request(:get, DisplayWords.domain + path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def a_post(path)
|
18
|
+
a_request(:post, DisplayWords.domain + path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def a_put(path)
|
22
|
+
a_request(:put, DisplayWords.domain + path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def stub_delete(path)
|
26
|
+
stub_request(:delete, DisplayWords.domain + path)
|
27
|
+
end
|
28
|
+
|
29
|
+
def stub_get(path)
|
30
|
+
stub_request(:get, DisplayWords.domain + path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def stub_post(path)
|
34
|
+
|
35
|
+
stub_request(:post, DisplayWords.domain + path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def stub_put(path)
|
39
|
+
stub_request(:put, DisplayWords.domain + path)
|
40
|
+
end
|
41
|
+
|
42
|
+
def fixture_path
|
43
|
+
File.expand_path("../fixtures", __FILE__)
|
44
|
+
end
|
45
|
+
|
46
|
+
def fixture(file)
|
47
|
+
File.new(fixture_path + '/' + file)
|
48
|
+
end
|
49
|
+
|
50
|
+
def fixture_json(file)
|
51
|
+
s = File.new(fixture_path + '/' + file).each_line.inject("") {|sum, line| sum += line }
|
52
|
+
JSON s
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: display_words
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Will Watson
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-06 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 8
|
33
|
+
version: "0.8"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 9
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 5
|
48
|
+
version: "2.5"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: webmock
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 6
|
63
|
+
version: "1.6"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: json_pure
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 5
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 5
|
78
|
+
version: "1.5"
|
79
|
+
type: :runtime
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: httparty
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 13
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
- 7
|
93
|
+
- 7
|
94
|
+
version: 0.7.7
|
95
|
+
type: :runtime
|
96
|
+
version_requirements: *id005
|
97
|
+
description: A Ruby wrapper for the DisplayWords API
|
98
|
+
email:
|
99
|
+
- will@ackmanndickenson.com
|
100
|
+
executables: []
|
101
|
+
|
102
|
+
extensions: []
|
103
|
+
|
104
|
+
extra_rdoc_files: []
|
105
|
+
|
106
|
+
files:
|
107
|
+
- .rvmrc
|
108
|
+
- Gemfile
|
109
|
+
- Gemfile.lock
|
110
|
+
- README
|
111
|
+
- display_words.gemspec
|
112
|
+
- lib/display_words.rb
|
113
|
+
- lib/display_words/api.rb
|
114
|
+
- lib/display_words/authentication.rb
|
115
|
+
- lib/display_words/client.rb
|
116
|
+
- lib/display_words/client/inventory_source.rb
|
117
|
+
- lib/display_words/configuration.rb
|
118
|
+
- lib/display_words/request.rb
|
119
|
+
- lib/display_words/version.rb
|
120
|
+
- spec/display_words/api_spec.rb
|
121
|
+
- spec/display_words/client/inventory_source_spec.rb
|
122
|
+
- spec/display_words_spec.rb
|
123
|
+
- spec/fixtures/auth.json
|
124
|
+
- spec/fixtures/inventory_source.json
|
125
|
+
- spec/fixtures/inventory_sources.json
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
has_rdoc: true
|
128
|
+
homepage: https://github.com/ackmann-dickenson/display_words
|
129
|
+
licenses: []
|
130
|
+
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 3
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
hash: 23
|
151
|
+
segments:
|
152
|
+
- 1
|
153
|
+
- 3
|
154
|
+
- 6
|
155
|
+
version: 1.3.6
|
156
|
+
requirements: []
|
157
|
+
|
158
|
+
rubyforge_project: display_words
|
159
|
+
rubygems_version: 1.5.0
|
160
|
+
signing_key:
|
161
|
+
specification_version: 3
|
162
|
+
summary: Ruby wrapper for the DisplayWords API
|
163
|
+
test_files:
|
164
|
+
- spec/display_words/api_spec.rb
|
165
|
+
- spec/display_words/client/inventory_source_spec.rb
|
166
|
+
- spec/display_words_spec.rb
|
167
|
+
- spec/fixtures/auth.json
|
168
|
+
- spec/fixtures/inventory_source.json
|
169
|
+
- spec/fixtures/inventory_sources.json
|
170
|
+
- spec/spec_helper.rb
|