eatabit_rails 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/bin/bundle +105 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/rake +29 -0
- data/bin/restclient +29 -0
- data/bin/rspec +29 -0
- data/bin/safe_yaml +29 -0
- data/eatabit_rails.gemspec +6 -6
- data/lib/eatabit_rails.rb +2 -1
- data/lib/eatabit_rails/account.rb +15 -12
- data/lib/eatabit_rails/job.rb +47 -41
- data/lib/eatabit_rails/printer.rb +43 -28
- data/lib/eatabit_rails/rest/config.rb +5 -5
- data/lib/eatabit_rails/rest/uri.rb +8 -12
- data/lib/eatabit_rails/util/configuration.rb +3 -3
- data/lib/eatabit_rails/version.rb +3 -1
- metadata +22 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5307a5bc7209173dbce696067b07debcfc13f7d363603c5828010de19d9c7b11
|
4
|
+
data.tar.gz: c233bf7438490522225d3fd5c54e49656e906a9bd3e667562b0d1b9e1b79e59c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d11104b3bc6c295ae05d8abe5f511e8ffcca6e1a48e0af8be99d911f609663d4e45ea889220a9b91a6ebba65503163527c541b24df5bb48648f51948a78626e
|
7
|
+
data.tar.gz: 411cda56f04a1fc93f687f79bfc23218a2f470dfe5cc130d620294281e921c5d4100f012af14f8774cce106d0e51928181f8e37f742a2010cc4113ee84c0c2c8
|
data/.gitignore
CHANGED
data/bin/bundle
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1 || ">= 0.a"
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||= begin
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version || "#{Gem::Requirement.default}.a"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def load_bundler!
|
71
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
72
|
+
|
73
|
+
# must dup string for RG < 1.8 compatibility
|
74
|
+
activate_bundler(bundler_version.dup)
|
75
|
+
end
|
76
|
+
|
77
|
+
def activate_bundler(bundler_version)
|
78
|
+
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
79
|
+
bundler_version = "< 2"
|
80
|
+
end
|
81
|
+
gem_error = activation_error_handling do
|
82
|
+
gem "bundler", bundler_version
|
83
|
+
end
|
84
|
+
return if gem_error.nil?
|
85
|
+
require_error = activation_error_handling do
|
86
|
+
require "bundler/version"
|
87
|
+
end
|
88
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
89
|
+
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
90
|
+
exit 42
|
91
|
+
end
|
92
|
+
|
93
|
+
def activation_error_handling
|
94
|
+
yield
|
95
|
+
nil
|
96
|
+
rescue StandardError, LoadError => e
|
97
|
+
e
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
m.load_bundler!
|
102
|
+
|
103
|
+
if m.invoked_as_script?
|
104
|
+
load Gem.bin_path("bundler", "bundle")
|
105
|
+
end
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/restclient
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'restclient' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rest-client", "restclient")
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/safe_yaml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'safe_yaml' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("safe_yaml", "safe_yaml")
|
data/eatabit_rails.gemspec
CHANGED
@@ -27,12 +27,12 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
31
|
-
spec.add_development_dependency 'rake', '~>
|
32
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
33
|
-
spec.add_development_dependency 'vcr', '~>
|
34
|
-
spec.add_development_dependency 'webmock', '~>
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
31
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.7'
|
33
|
+
spec.add_development_dependency 'vcr', '~> 4.0'
|
34
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
35
35
|
|
36
36
|
spec.add_dependency 'rest-client', '~> 2.0'
|
37
|
-
spec.add_dependency 'json', '~> 2.
|
37
|
+
spec.add_dependency 'json', '~> 2.1'
|
38
38
|
end
|
data/lib/eatabit_rails.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rest-client'
|
2
4
|
|
3
5
|
require 'eatabit_rails/version'
|
@@ -9,7 +11,6 @@ require 'eatabit_rails/printer'
|
|
9
11
|
require 'eatabit_rails/job'
|
10
12
|
|
11
13
|
module EatabitRails
|
12
|
-
|
13
14
|
def self.configure(&block)
|
14
15
|
yield configuration
|
15
16
|
end
|
@@ -1,23 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module EatabitRails
|
2
4
|
class Account
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
attr_reader(
|
6
|
+
:name,
|
7
|
+
:environment,
|
8
|
+
:enabled,
|
9
|
+
:created_at
|
10
|
+
)
|
8
11
|
|
9
12
|
def initialize(attributes)
|
10
|
-
@name
|
11
|
-
@environment
|
12
|
-
@enabled
|
13
|
-
@created_at
|
13
|
+
@name = attributes['name']
|
14
|
+
@environment = attributes['environment']
|
15
|
+
@enabled = attributes['enabled']
|
16
|
+
@created_at = attributes['created_at']
|
14
17
|
end
|
15
18
|
|
16
19
|
def self.find
|
17
20
|
account_uri = EatabitRails::REST::Uri.new.account
|
18
|
-
params
|
19
|
-
response
|
20
|
-
attributes
|
21
|
+
params = EatabitRails::REST::Uri.default_params
|
22
|
+
response = RestClient.get(account_uri, params)
|
23
|
+
attributes = JSON.parse(response.body)['account']
|
21
24
|
|
22
25
|
new(attributes)
|
23
26
|
end
|
data/lib/eatabit_rails/job.rb
CHANGED
@@ -1,58 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module EatabitRails
|
2
4
|
class Job
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
5
|
+
attr_reader(
|
6
|
+
:id,
|
7
|
+
:external_id,
|
8
|
+
:body,
|
9
|
+
:state,
|
10
|
+
:environment,
|
11
|
+
:pickup_minutes,
|
12
|
+
:delivery_minutes,
|
13
|
+
:status_url,
|
14
|
+
:status_url_method,
|
15
|
+
:created_at,
|
16
|
+
:fulfill_at,
|
17
|
+
:api_version,
|
18
|
+
:expire_seconds,
|
19
|
+
:expires_at,
|
20
|
+
:account,
|
21
|
+
:printer
|
22
|
+
)
|
20
23
|
|
21
24
|
def initialize(attributes)
|
22
|
-
@id
|
23
|
-
@external_id
|
24
|
-
@body
|
25
|
-
@state
|
26
|
-
@environment
|
27
|
-
@pickup_minutes
|
28
|
-
@delivery_minutes
|
29
|
-
@status_url
|
30
|
-
@status_url_method
|
31
|
-
@created_at
|
32
|
-
@fulfill_at
|
33
|
-
@api_version
|
34
|
-
@expire_seconds
|
35
|
-
@expires_at
|
36
|
-
@account
|
37
|
-
@printer
|
25
|
+
@id = attributes['id']
|
26
|
+
@external_id = attributes['external_id']
|
27
|
+
@body = attributes['body']
|
28
|
+
@state = attributes['state']
|
29
|
+
@environment = attributes['environment']
|
30
|
+
@pickup_minutes = attributes['pickup_minutes']
|
31
|
+
@delivery_minutes = attributes['delivery_minutes']
|
32
|
+
@status_url = attributes['status_url']
|
33
|
+
@status_url_method = attributes['status_url_method']
|
34
|
+
@created_at = attributes['created_at']
|
35
|
+
@fulfill_at = attributes['fulfill_at']
|
36
|
+
@api_version = attributes['api_version']
|
37
|
+
@expire_seconds = attributes['expire_seconds']
|
38
|
+
@expires_at = attributes['expires_at']
|
39
|
+
@account = attributes['account']
|
40
|
+
@printer = attributes['printer']
|
38
41
|
end
|
39
42
|
|
40
43
|
def self.create(printer_id, job_attributes)
|
41
|
-
job_uri
|
42
|
-
params
|
43
|
-
response
|
44
|
+
job_uri = EatabitRails::REST::Uri.new.job printer_id
|
45
|
+
params = EatabitRails::REST::Uri.default_params
|
46
|
+
response = RestClient.post(
|
47
|
+
job_uri,
|
48
|
+
params.merge!(job_attributes)
|
49
|
+
)
|
44
50
|
response_attributes = JSON.parse(response.body)['job']
|
45
51
|
|
46
|
-
new
|
52
|
+
new(response_attributes)
|
47
53
|
end
|
48
54
|
|
49
55
|
def self.find(printer_id, job_id)
|
50
|
-
job_uri
|
51
|
-
params
|
52
|
-
response
|
56
|
+
job_uri = EatabitRails::REST::Uri.new.job(printer_id, job_id)
|
57
|
+
params = EatabitRails::REST::Uri.default_params
|
58
|
+
response = RestClient.get(job_uri, params)
|
53
59
|
response_attributes = JSON.parse(response.body)['job']
|
54
60
|
|
55
|
-
new
|
61
|
+
new(response_attributes)
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
@@ -1,39 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module EatabitRails
|
2
4
|
class Printer
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
attr_reader(
|
6
|
+
:id,
|
7
|
+
:name,
|
8
|
+
:enabled,
|
9
|
+
:pickup_minutes,
|
10
|
+
:delivery_minutes,
|
11
|
+
:state,
|
12
|
+
:online,
|
13
|
+
:paper,
|
14
|
+
:fulfillment,
|
15
|
+
:sound,
|
16
|
+
:light,
|
17
|
+
:autoprint
|
18
|
+
)
|
16
19
|
|
17
20
|
def initialize(attributes)
|
18
|
-
@id
|
19
|
-
@name
|
20
|
-
@enabled
|
21
|
-
@pickup_minutes
|
21
|
+
@id = attributes['id']
|
22
|
+
@name = attributes['name']
|
23
|
+
@enabled = attributes['enabled']
|
24
|
+
@pickup_minutes = attributes['pickup_minutes']
|
22
25
|
@delivery_minutes = attributes['delivery_minutes']
|
23
|
-
@state
|
24
|
-
@online
|
25
|
-
@paper
|
26
|
-
@fulfillment
|
27
|
-
@sound
|
28
|
-
@light
|
29
|
-
@autoprint
|
26
|
+
@state = attributes['state']
|
27
|
+
@online = attributes['online']
|
28
|
+
@paper = attributes['paper']
|
29
|
+
@fulfillment = attributes['fulfillment']
|
30
|
+
@sound = attributes['sound']
|
31
|
+
@light = attributes['light']
|
32
|
+
@autoprint = attributes['autoprint']
|
30
33
|
end
|
31
34
|
|
32
35
|
def self.find(id)
|
33
|
-
printer_uri = EatabitRails::REST::Uri.new.printer
|
34
|
-
params
|
35
|
-
response
|
36
|
-
attributes
|
36
|
+
printer_uri = EatabitRails::REST::Uri.new.printer(id)
|
37
|
+
params = EatabitRails::REST::Uri.default_params
|
38
|
+
response = RestClient.get(printer_uri, params)
|
39
|
+
attributes = JSON.parse(response.body)['printer']
|
40
|
+
|
41
|
+
new(attributes)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.update(id, printer_attributes)
|
45
|
+
printer_uri = EatabitRails::REST::Uri.new.printer(id)
|
46
|
+
params = EatabitRails::REST::Uri.default_params
|
47
|
+
response = RestClient.put(
|
48
|
+
printer_uri,
|
49
|
+
params.merge!(printer_attributes)
|
50
|
+
)
|
51
|
+
attributes = JSON.parse(response.body)['printer']
|
37
52
|
|
38
53
|
new(attributes)
|
39
54
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module EatabitRails
|
3
4
|
module REST
|
4
|
-
|
5
5
|
module Config
|
6
|
-
HOST
|
7
|
-
PROTOCOL
|
8
|
-
VERSION
|
6
|
+
HOST = 'api.eatabit.io'
|
7
|
+
PROTOCOL = 'https'
|
8
|
+
VERSION = 'v2'
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module EatabitRails
|
3
4
|
module REST
|
4
|
-
|
5
5
|
class Uri
|
6
|
-
|
7
6
|
def self.default_params
|
8
7
|
{
|
9
8
|
content_type: :json,
|
@@ -12,11 +11,11 @@ module EatabitRails
|
|
12
11
|
end
|
13
12
|
|
14
13
|
def initialize
|
15
|
-
@sid
|
16
|
-
@token
|
14
|
+
@sid = EatabitRails.configuration.sid
|
15
|
+
@token = EatabitRails.configuration.token
|
17
16
|
@protocol = EatabitRails::REST::Config::PROTOCOL
|
18
|
-
@host
|
19
|
-
@version
|
17
|
+
@host = EatabitRails::REST::Config::HOST
|
18
|
+
@version = EatabitRails.configuration.version || EatabitRails::REST::Config::VERSION
|
20
19
|
end
|
21
20
|
|
22
21
|
def base_uri
|
@@ -49,14 +48,11 @@ module EatabitRails
|
|
49
48
|
'jobs'
|
50
49
|
]
|
51
50
|
|
52
|
-
if job_id
|
53
|
-
uri.push job_id
|
54
|
-
end
|
55
|
-
|
51
|
+
uri.push(job_id) if job_id
|
56
52
|
uri.join('/')
|
57
53
|
end
|
58
54
|
|
59
|
-
alias
|
55
|
+
alias account base_uri
|
60
56
|
end
|
61
57
|
end
|
62
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eatabit_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Oleksiak
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.16'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12.3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.7'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: vcr
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '3.4'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '3.4'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rest-client
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2.
|
103
|
+
version: '2.1'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '2.
|
110
|
+
version: '2.1'
|
111
111
|
description: Taking orders online is easy. (ok, not that easy) but getting the order
|
112
112
|
into the hands of the restaurant...that's hard.
|
113
113
|
email:
|
@@ -123,7 +123,14 @@ files:
|
|
123
123
|
- LICENSE.txt
|
124
124
|
- README.md
|
125
125
|
- Rakefile
|
126
|
+
- bin/bundle
|
126
127
|
- bin/console
|
128
|
+
- bin/htmldiff
|
129
|
+
- bin/ldiff
|
130
|
+
- bin/rake
|
131
|
+
- bin/restclient
|
132
|
+
- bin/rspec
|
133
|
+
- bin/safe_yaml
|
127
134
|
- bin/setup
|
128
135
|
- eatabit_rails.gemspec
|
129
136
|
- lib/eatabit_rails.rb
|
@@ -155,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
162
|
version: '0'
|
156
163
|
requirements: []
|
157
164
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.6
|
165
|
+
rubygems_version: 2.7.6
|
159
166
|
signing_key:
|
160
167
|
specification_version: 4
|
161
168
|
summary: The official gem for the eatabit.io API
|