inkling_api 0.0.1

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.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ lib/inkling_api_test_config.rb
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in inkling_api.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ InklingAPI
2
+ ----------
3
+
4
+ To run the tests
5
+ ================
6
+
7
+ create a file in lib/inkling_api_test_config.rb that looks like the following
8
+
9
+ module InklingApiTestConfig
10
+ class << self
11
+ def url
12
+ "https://url.inklingmarkets.com"
13
+ end
14
+
15
+ def login
16
+ "some-login"
17
+ end
18
+
19
+ def password
20
+ "some-password"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'autospec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'autospec')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'convert_to_should_syntax' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('shoulda', 'convert_to_should_syntax')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'edit_json.rb' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('json', 'edit_json.rb')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('inkling_api', 'htmldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('inkling_api', 'ldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'minitar' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('inkling_api', 'minitar')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'nokogiri' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('inkling_api', 'nokogiri')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'prettify_json.rb' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('json', 'prettify_json.rb')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rackup' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('inkling_api', 'rackup')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rdebug' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('ruby-debug19', 'rdebug')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'spec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('inkling_api', 'spec')
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "inkling_api/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "inkling_api"
7
+ s.version = InklingApi::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["David Chapman"]
10
+ s.email = ["david@isotope11.com"]
11
+ s.homepage = "http://www.isotope11.com/"
12
+ s.summary = %q{Gem to interact with inkling markets API}
13
+
14
+ s.rubyforge_project = "inkling_api"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency('faraday', '~> 0.7.4')
22
+ s.add_dependency('faraday-stack', '~> 0.1.3')
23
+ s.add_dependency('hashie', '~> 1.1.0')
24
+ s.add_dependency('activesupport', '~> 3.0.9')
25
+ s.add_dependency('i18n', '~> 0.6.0')
26
+
27
+ s.add_development_dependency('rspec')
28
+ s.add_development_dependency('json_spec', '~> 0.6.0')
29
+ s.add_development_dependency('shoulda', '~> 2.11.3')
30
+ s.add_development_dependency('ruby-debug19')
31
+ end
@@ -0,0 +1,89 @@
1
+ require 'faraday_stack'
2
+ require 'inkling_api/faraday_middlewares'
3
+ require 'hashie/mash'
4
+ require 'inkling_api/activesupport_yaml_hack'
5
+
6
+ module InklingApi
7
+ module Configuration
8
+ def configure
9
+ yield self
10
+ end
11
+ end
12
+
13
+ class Mashify < Faraday::Response::Middleware
14
+ def on_complete(env)
15
+ super if Hash === env[:body]
16
+ end
17
+
18
+ def parse(body)
19
+ Hashie::Mash.new(body)
20
+ end
21
+ end
22
+
23
+ class PreserveRawBody < Faraday::Response::Middleware
24
+ def on_complete(env)
25
+ env[:raw_body] = env[:body]
26
+ end
27
+ end
28
+
29
+ module Connection
30
+ def url=(url)
31
+ @url = url
32
+ end
33
+
34
+ def login=(login)
35
+ @login = login
36
+ end
37
+
38
+ def password=(password)
39
+ @password = password
40
+ end
41
+
42
+ def connection
43
+ raise "set_url first" unless @url
44
+ @connection ||= begin
45
+ conn = Faraday.new(@url) do |b|
46
+ b.use FaradayStack::ResponseJSON, content_type: 'application/json'
47
+ b.use FaradayMiddlewares::ResponseXMLToHash, content_type: 'application/xml'
48
+ b.use PreserveRawBody
49
+ #b.use FaradayStack::Caching, cache, strip_params: %w[access_token client_id] unless cache.nil?
50
+ b.response :raise_error
51
+ #b.use Faraday::Response::Logger
52
+ b.use FaradayStack::Instrumentation
53
+ b.adapter Faraday.default_adapter
54
+ b.use Mashify
55
+ end
56
+
57
+ conn.basic_auth(@login, @password)
58
+
59
+ conn
60
+ end
61
+ end
62
+
63
+ def get(path, params = nil)
64
+ connection.get(path) do |request|
65
+ request.params = params if params
66
+ end
67
+ end
68
+ end
69
+
70
+ module ApiMethods
71
+ def get(path, params = nil)
72
+ raw = params && params.delete(:raw)
73
+ response = super
74
+ raw ? response.env[:raw_body] : response.body
75
+ end
76
+
77
+ def market(market_id, *args)
78
+ get("markets/#{market_id}.xml", *args)
79
+ end
80
+
81
+ def markets(*args)
82
+ get("markets.json", *args)
83
+ end
84
+ end
85
+
86
+ extend Configuration
87
+ extend Connection
88
+ extend ApiMethods
89
+ end
@@ -0,0 +1,11 @@
1
+ require 'active_support'
2
+ # Apparently ActiveSupport moved some stuff around and FaradayStack is not wise to it
3
+ unless defined?(ActiveSupport::JSON::Backends::Yaml::DATE_REGEX)
4
+ module ActiveSupport::JSON
5
+ module Backends
6
+ module Yaml
7
+ DATE_REGEX = ::ActiveSupport::JSON::DATE_REGEX
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module FaradayMiddlewares
2
+ autoload :ResponseXMLSlop, 'inkling_api/faraday_middlewares/response_xml_slop'
3
+ autoload :ResponseXMLToHash, 'inkling_api/faraday_middlewares/response_xml_to_hash'
4
+ end
@@ -0,0 +1,12 @@
1
+ module FaradayMiddlewares
2
+ class ResponseXMLSlop < ::FaradayStack::ResponseMiddleware
3
+ dependency do
4
+ require 'nokogiri'
5
+ Nokogiri::Slop
6
+ end
7
+
8
+ define_parser do |body|
9
+ Nokogiri::Slop body
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module FaradayMiddlewares
2
+ class ResponseXMLToHash < ::FaradayStack::ResponseMiddleware
3
+ dependency do
4
+ require 'active_support/core_ext'
5
+ Hash
6
+ end
7
+
8
+ define_parser do |body|
9
+ Hash.from_xml body
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module InklingApi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ require 'ruby-debug'
3
+ require 'inkling_api_test_config'
4
+
5
+ describe InklingApi do
6
+
7
+ let(:url) {InklingApiTestConfig.url}
8
+ let(:login) {InklingApiTestConfig.login}
9
+ let(:password) {InklingApiTestConfig.password}
10
+ let(:inkling_api) do
11
+ InklingApi.url = url
12
+ InklingApi.login = login
13
+ InklingApi.password = password
14
+ InklingApi
15
+ end
16
+
17
+ %w( configure connection get markets market ).each do |meth|
18
+ it "should respond to #{meth}" do
19
+ inkling_api.should respond_to(meth.to_sym)
20
+ end
21
+ end
22
+
23
+ it "should not raise error on getting a connection" do
24
+ lambda{ inkling_api.connection }.should_not raise_error
25
+ end
26
+
27
+ it "should get a list of markets" do
28
+ inkling_api.markets.should be_an(Array)
29
+ end
30
+
31
+ # NOTE: This will only work if the markets aren't empty
32
+ it "should get a market" do
33
+ markets = inkling_api.markets
34
+ inkling_api.market(markets.first["id"]).should be_a(Hash)
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'inkling_api'
5
+ require 'json_spec'
6
+
7
+ RSpec.configure do |config|
8
+ # some (optional) config here
9
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inkling_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Chapman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-09 00:00:00.000000000 +00:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: faraday
17
+ requirement: &25789460 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.7.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *25789460
26
+ - !ruby/object:Gem::Dependency
27
+ name: faraday-stack
28
+ requirement: &25782880 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *25782880
37
+ - !ruby/object:Gem::Dependency
38
+ name: hashie
39
+ requirement: &25782420 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.1.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: *25782420
48
+ - !ruby/object:Gem::Dependency
49
+ name: activesupport
50
+ requirement: &25781820 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 3.0.9
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: *25781820
59
+ - !ruby/object:Gem::Dependency
60
+ name: i18n
61
+ requirement: &25781200 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 0.6.0
67
+ type: :runtime
68
+ prerelease: false
69
+ version_requirements: *25781200
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: &25780700 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *25780700
81
+ - !ruby/object:Gem::Dependency
82
+ name: json_spec
83
+ requirement: &25780040 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 0.6.0
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *25780040
92
+ - !ruby/object:Gem::Dependency
93
+ name: shoulda
94
+ requirement: &25779520 !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: 2.11.3
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: *25779520
103
+ - !ruby/object:Gem::Dependency
104
+ name: ruby-debug19
105
+ requirement: &25779080 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: *25779080
114
+ description:
115
+ email:
116
+ - david@isotope11.com
117
+ executables:
118
+ - autospec
119
+ - convert_to_should_syntax
120
+ - edit_json.rb
121
+ - htmldiff
122
+ - ldiff
123
+ - minitar
124
+ - nokogiri
125
+ - prettify_json.rb
126
+ - rackup
127
+ - rdebug
128
+ - rspec
129
+ - spec
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .rspec
135
+ - Gemfile
136
+ - README.md
137
+ - Rakefile
138
+ - bin/autospec
139
+ - bin/convert_to_should_syntax
140
+ - bin/edit_json.rb
141
+ - bin/htmldiff
142
+ - bin/ldiff
143
+ - bin/minitar
144
+ - bin/nokogiri
145
+ - bin/prettify_json.rb
146
+ - bin/rackup
147
+ - bin/rdebug
148
+ - bin/rspec
149
+ - bin/spec
150
+ - inkling_api.gemspec
151
+ - lib/inkling_api.rb
152
+ - lib/inkling_api/activesupport_yaml_hack.rb
153
+ - lib/inkling_api/faraday_middlewares.rb
154
+ - lib/inkling_api/faraday_middlewares/response_xml_slop.rb
155
+ - lib/inkling_api/faraday_middlewares/response_xml_to_hash.rb
156
+ - lib/inkling_api/version.rb
157
+ - spec/inkling_api_spec.rb
158
+ - spec/spec_helper.rb
159
+ has_rdoc: true
160
+ homepage: http://www.isotope11.com/
161
+ licenses: []
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ none: false
168
+ requirements:
169
+ - - ! '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project: inkling_api
180
+ rubygems_version: 1.6.2
181
+ signing_key:
182
+ specification_version: 3
183
+ summary: Gem to interact with inkling markets API
184
+ test_files: []