eatabit_rails 0.1.0

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 855c3770b3de8fb0f176ff10f4553c7176588668
4
+ data.tar.gz: 79c8a42589d71dcff7d61a6fae763b4e98517ed5
5
+ SHA512:
6
+ metadata.gz: 8cd73b22c478d5b311fb24684973853529fddfb4756974d6f275a7e03e6189b85fc521eb6a1691e2e3712e480d50dd1abf78dfd424eb07c983049e17f32a6662
7
+ data.tar.gz: 8febe20d5e2303ab930369b33c817bb45cbf1ad1373569934c1da6ba3e4b153b5657dbde98fd062fc739edd2894eec90fff785682516a540ae8ce24e1124a7c2
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in eatabit_rails.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Greg Oleksiak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # eatabit_rails
2
+
3
+ The official gem for the [eatabit.io](http://eatabit.io) API.
4
+
5
+ ## Documentation
6
+ API documentation can be found [here](http://eatabit.io/documentation/v2/).
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'eatabit_rails'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install eatabit_rails
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/eatabit_rails.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "eatabit_rails"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eatabit_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eatabit_rails"
8
+ spec.version = EatabitRails::VERSION
9
+ spec.authors = ["Greg Oleksiak"]
10
+ spec.email = ["greg.oleksiak@gmail.com"]
11
+
12
+ spec.summary = %q{The official gem for the eatabit.io API}
13
+ spec.description = %q{Taking orders online is easy. (ok, not that easy) but getting the order into the hands of the restaurant...that's hard.}
14
+ spec.homepage = "http://www.eatabit.io"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency 'bundler', '~> 1.10'
31
+ spec.add_development_dependency 'rake', '~> 10.0'
32
+ spec.add_development_dependency 'rspec', '~> 3.3', '>= 3.3.0'
33
+ spec.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.3'
34
+ spec.add_development_dependency 'webmock', '~> 1.21', '>= 1.21.0'
35
+
36
+ spec.add_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
37
+ spec.add_dependency 'json', '~> 1.8', '>= 1.8.3'
38
+ end
@@ -0,0 +1,20 @@
1
+ require 'rest-client'
2
+
3
+ require 'eatabit_rails/version'
4
+ require 'eatabit_rails/util/configuration'
5
+ require 'eatabit_rails/rest/config'
6
+ require 'eatabit_rails/rest/uri'
7
+ require 'eatabit_rails/account'
8
+ require 'eatabit_rails/printer'
9
+ require 'eatabit_rails/job'
10
+
11
+ module EatabitRails
12
+
13
+ def self.configure(&block)
14
+ yield configuration
15
+ end
16
+
17
+ def self.configuration
18
+ @configuration ||= Util::Configuration.new
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ module EatabitRails
2
+
3
+ class Account
4
+
5
+ attr_reader :name,
6
+ :environment,
7
+ :enabled,
8
+ :created_at
9
+
10
+ def initialize(attributes)
11
+ @name = attributes['name']
12
+ @environment = attributes['environment']
13
+ @enabled = attributes['enabled']
14
+ @created_at = attributes['created_at']
15
+ end
16
+
17
+ def self.find
18
+ account_uri = EatabitRails::REST::Uri.new.account
19
+ params = EatabitRails::REST::Uri.default_params
20
+ response = RestClient.get account_uri, params
21
+ attributes = JSON.parse(response.body)['account']
22
+
23
+ new(attributes)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,45 @@
1
+ module EatabitRails
2
+
3
+ class Job
4
+
5
+ attr_reader :id,
6
+ :body,
7
+ :state,
8
+ :environment,
9
+ :pickup_minutes,
10
+ :delivery_minutes,
11
+ :status_url,
12
+ :status_url_method,
13
+ :created_at
14
+
15
+ def initialize(attributes)
16
+ @id = attributes['id']
17
+ @body = attributes['body']
18
+ @state = attributes['state']
19
+ @environment = attributes['environment']
20
+ @pickup_minutes = attributes['pickup_minutes']
21
+ @delivery_minutes = attributes['delivery_minutes']
22
+ @status_url = attributes['status_url']
23
+ @status_url_method = attributes['status_url_method']
24
+ @created_at = attributes['created_at']
25
+ end
26
+
27
+ def self.create(printer_id, job_attributes)
28
+ job_uri = EatabitRails::REST::Uri.new.job printer_id
29
+ params = EatabitRails::REST::Uri.default_params
30
+ response = RestClient.post job_uri, job_attributes
31
+ response_attributes = JSON.parse(response.body)['job']
32
+
33
+ new response_attributes
34
+ end
35
+
36
+ def self.find(printer_id, job_id)
37
+ job_uri = EatabitRails::REST::Uri.new.job printer_id, job_id
38
+ params = EatabitRails::REST::Uri.default_params
39
+ response = RestClient.get job_uri, params
40
+ response_attributes = JSON.parse(response.body)['job']
41
+
42
+ new response_attributes
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ module EatabitRails
2
+
3
+ class Printer
4
+
5
+ attr_reader :name,
6
+ :enabled,
7
+ :pickup_minutes,
8
+ :delivery_minutes,
9
+ :state,
10
+ :online,
11
+ :has_paper
12
+
13
+ def initialize(attributes)
14
+ @name = attributes['name']
15
+ @enabled = attributes['enabled']
16
+ @pickup_minutes = attributes['pickup_minutes']
17
+ @delivery_minutes = attributes['delivery_minutes']
18
+ @state = attributes['state']
19
+ @online = attributes['online']
20
+ @has_paper = attributes['has_paper']
21
+ end
22
+
23
+ def self.find(id)
24
+ printer_uri = EatabitRails::REST::Uri.new.printer id
25
+ params = EatabitRails::REST::Uri.default_params
26
+ response = RestClient.get printer_uri, params
27
+ attributes = JSON.parse(response.body)['printer']
28
+
29
+ new(attributes)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,11 @@
1
+ module EatabitRails
2
+
3
+ module REST
4
+
5
+ module Config
6
+ HOST = 'api.eatabit.io'
7
+ PROTOCOL = 'https'
8
+ VERSION = 'v2'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,62 @@
1
+ module EatabitRails
2
+
3
+ module REST
4
+
5
+ class Uri
6
+
7
+ def self.default_params
8
+ {
9
+ content_type: :json,
10
+ accept: :json
11
+ }
12
+ end
13
+
14
+ def initialize
15
+ @sid = EatabitRails.configuration.sid
16
+ @token = EatabitRails.configuration.token
17
+ @protocol = EatabitRails::REST::Config::PROTOCOL
18
+ @host = EatabitRails::REST::Config::HOST
19
+ @version = EatabitRails.configuration.version || EatabitRails::REST::Config::VERSION
20
+ end
21
+
22
+ def base_uri
23
+ [
24
+ @protocol,
25
+ '://',
26
+ @sid,
27
+ ':',
28
+ @token,
29
+ '@',
30
+ @host,
31
+ '/',
32
+ @version,
33
+ '/account/',
34
+ @sid
35
+ ].join
36
+ end
37
+
38
+ def printer(id)
39
+ [
40
+ base_uri,
41
+ 'printers',
42
+ id
43
+ ].join('/')
44
+ end
45
+
46
+ def job(printer_id, job_id = nil)
47
+ uri = [
48
+ printer(printer_id),
49
+ 'jobs'
50
+ ]
51
+
52
+ if job_id
53
+ uri.push job_id
54
+ end
55
+
56
+ uri.join('/')
57
+ end
58
+
59
+ alias :account :base_uri
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,9 @@
1
+ module EatabitRails
2
+
3
+ module Util
4
+
5
+ class Configuration
6
+ attr_accessor :sid, :token, :version
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module EatabitRails
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,192 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eatabit_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Greg Oleksiak
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.3.0
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '3.3'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 3.3.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: vcr
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '2.9'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.9.3
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '2.9'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 2.9.3
81
+ - !ruby/object:Gem::Dependency
82
+ name: webmock
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.21'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.21.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.21'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.21.0
101
+ - !ruby/object:Gem::Dependency
102
+ name: rest-client
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '1.8'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.8.0
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.8'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 1.8.0
121
+ - !ruby/object:Gem::Dependency
122
+ name: json
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '1.8'
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 1.8.3
131
+ type: :runtime
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '1.8'
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 1.8.3
141
+ description: Taking orders online is easy. (ok, not that easy) but getting the order
142
+ into the hands of the restaurant...that's hard.
143
+ email:
144
+ - greg.oleksiak@gmail.com
145
+ executables: []
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - ".gitignore"
150
+ - ".rspec"
151
+ - ".travis.yml"
152
+ - Gemfile
153
+ - LICENSE.txt
154
+ - README.md
155
+ - Rakefile
156
+ - bin/console
157
+ - bin/setup
158
+ - eatabit_rails.gemspec
159
+ - lib/eatabit_rails.rb
160
+ - lib/eatabit_rails/account.rb
161
+ - lib/eatabit_rails/job.rb
162
+ - lib/eatabit_rails/printer.rb
163
+ - lib/eatabit_rails/rest/config.rb
164
+ - lib/eatabit_rails/rest/uri.rb
165
+ - lib/eatabit_rails/util/configuration.rb
166
+ - lib/eatabit_rails/version.rb
167
+ homepage: http://www.eatabit.io
168
+ licenses:
169
+ - MIT
170
+ metadata:
171
+ allowed_push_host: https://rubygems.org
172
+ post_install_message:
173
+ rdoc_options: []
174
+ require_paths:
175
+ - lib
176
+ required_ruby_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ required_rubygems_version: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ requirements: []
187
+ rubyforge_project:
188
+ rubygems_version: 2.4.8
189
+ signing_key:
190
+ specification_version: 4
191
+ summary: The official gem for the eatabit.io API
192
+ test_files: []