evolis-premium_sdk 1.0.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: 5a24254811c654b6b0e7101dedeeafeaae18b621
4
+ data.tar.gz: 243cd2662b01920e5acce05c1401ebbe7143affa
5
+ SHA512:
6
+ metadata.gz: ea377cdc59fd18f5338fb14c09503c3ac40775ca3a18ddadab6aae84edeb85a76d9d9123d55875f9b93083b5b7b3332850dc23d8c07eb21f09f4c35c54b02697
7
+ data.tar.gz: f8fee0513e47bec357bf915e4011a39a2ea26c9ca6f0d938ab44da7f66879a76b8a97efb1007e9f66c506fbb06c15d5e3e4b27dde6e379d648e2b54e977c0241
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ /.idea/
15
+
16
+ # do not include gems
17
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at boye.holden@ntnu.no. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in evolis-premium_sdk.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Boye Holden
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,45 @@
1
+ # Evolis::PremiumSdk
2
+
3
+ This gem is a ruby interface for the [Evolis Premium SDK](http://www.evolis.com/software/evolis-premium-sdk-software-development-kit),
4
+ and are therefore based on the documentation from Evolis.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'evolis-premium_sdk'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install evolis-premium_sdk
21
+
22
+ ## Usage
23
+
24
+ Require the library and then use the classes as their own services or set up a new Sdk class and use all the other classes from that.
25
+ The code documents the usage.
26
+
27
+ require 'evolis/premium_sdk'
28
+ sdk = Evolis::PremiumSdk::Sdk.new '127.0.0.1', 18000
29
+ sdk.echo.echo 'Hello World'
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ 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).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/esselt/evolis-premium_sdk](https://github.com/esselt/evolis-premium_sdk). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
40
+
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
45
+
@@ -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 "evolis/premium_sdk"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # 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 'evolis/premium_sdk/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "evolis-premium_sdk"
8
+ spec.version = Evolis::PremiumSdk::VERSION
9
+ spec.authors = ["Boye Holden"]
10
+ spec.email = ["esselt@esselt.net"]
11
+
12
+ spec.summary = %q{Implements Evolis Premium SDK.}
13
+ spec.description = %q{Implements usage of the Evolis Premium Suite SDK so Ruby can communicate with the SDK.}
14
+ spec.homepage = "https://github.com/esselt/evolis-premium_sdk"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing 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 " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.14"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+
37
+ spec.add_dependency "multi_json", "~> 1.12"
38
+ end
@@ -0,0 +1,52 @@
1
+ require 'evolis/premium_sdk/version'
2
+ require 'evolis/premium_sdk/rpc_client'
3
+ require 'evolis/premium_sdk/addon'
4
+ require 'evolis/premium_sdk/cmd'
5
+ require 'evolis/premium_sdk/echo'
6
+ require 'evolis/premium_sdk/espf'
7
+ require 'evolis/premium_sdk/print'
8
+ require 'evolis/premium_sdk/sdk_base'
9
+ require 'evolis/premium_sdk/setting'
10
+ require 'evolis/premium_sdk/supervision'
11
+
12
+ module Evolis
13
+ module PremiumSdk
14
+ class Sdk
15
+
16
+ # @return [Addon]
17
+ attr_reader :addon
18
+
19
+ # @return [Cmd]
20
+ attr_reader :cmd
21
+
22
+ # @return [Echo]
23
+ attr_reader :echo
24
+
25
+ # @return [Espf]
26
+ attr_reader :espf
27
+
28
+ # @return [Print]
29
+ attr_reader :print
30
+
31
+ # @return [Setting]
32
+ attr_reader :setting
33
+
34
+ # @return [Supervision]
35
+ attr_reader :supervision
36
+
37
+ # Initialize child classes so they can be used directly under a Evolis::PremiumSdk.new
38
+ #
39
+ # @param host [String] host or IP of SDK
40
+ # @param port [String, Fixnum] port of SDK
41
+ def initialize(host, port)
42
+ @addon = Addon.new host, port
43
+ @cmd = Cmd.new host, port
44
+ @echo = Echo.new host, port
45
+ @espf = Espf.new host, port
46
+ @print = Print.new host, port
47
+ @setting = Setting.new host, port
48
+ @supervision = Supervision.new host, port
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ require 'evolis/premium_sdk/sdk_base'
2
+
3
+ module Evolis
4
+ module PremiumSdk
5
+ class Addon < SdkBase
6
+
7
+ # Initializes the class and sets SDK host and port
8
+ #
9
+ # @param host [String] host or IP for SDK
10
+ # @param port [String, Fixnum] port for SDK
11
+ def initialize(host, port)
12
+ super(host, port, 'ADDON')
13
+ end
14
+
15
+ # Executes an application on the server
16
+ #
17
+ # @param command [String] what command to launch
18
+ # @param data [String] parameters to give to command
19
+ # @return [String] results from command
20
+ def launch(command, data)
21
+ call_rpc('Launch', {
22
+ command: command,
23
+ data: data
24
+ })
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,54 @@
1
+ require 'evolis/premium_sdk/sdk_base'
2
+
3
+ module Evolis
4
+ module PremiumSdk
5
+ class Cmd < SdkBase
6
+ # Default timeout for CMD service
7
+ TIMEOUT = '3000'
8
+
9
+ # Initializes the class and sets SDK host and port
10
+ #
11
+ # @param host [String] host or IP for SDK
12
+ # @param port [String, Fixnum] port for SDK
13
+ def initialize(host, port)
14
+ super(host, port, 'CMD')
15
+ end
16
+
17
+ # Sends commands in text or binary format
18
+ #
19
+ # @param device [String] printer name
20
+ # @param command [String] command, in clear text or base64-encoded format
21
+ # @param timeout [String] communication timeout
22
+ # @return [String] response to the sent command
23
+ def send_command(device, command, timeout = TIMEOUT)
24
+ call_rpc('SendCommand', {
25
+ command: command,
26
+ timeout: timeout,
27
+ device: device
28
+ })
29
+ end
30
+
31
+ # Retrieves the binary status of a device
32
+ #
33
+ # @param device [String] printer name
34
+ # @return [String] binary status of the device, see SDK document
35
+ def get_status(device)
36
+ call_rpc('GetStatus', {
37
+ device: device
38
+ })
39
+ end
40
+
41
+ # Reset communications with a device
42
+ #
43
+ # @param device [String] printer name
44
+ # @param timeout [String] communication timeout
45
+ # @return [true] if reset successful
46
+ def reset_com(device, timeout = TIMEOUT)
47
+ call_rpc('ResetCom', {
48
+ timeout: timeout,
49
+ device: device
50
+ })
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,26 @@
1
+ require 'evolis/premium_sdk/sdk_base'
2
+
3
+ module Evolis
4
+ module PremiumSdk
5
+ class Echo < SdkBase
6
+
7
+ # Initializes the class and sets SDK host and port
8
+ #
9
+ # @param host [String] host or IP for SDK
10
+ # @param port [String, Fixnum] port for SDK
11
+ def initialize(host, port)
12
+ super(host, port, 'ECHO')
13
+ end
14
+
15
+ # Sends a character string to the server
16
+ #
17
+ # @param msg [String] character string
18
+ # @return [String] same as msg parameter
19
+ def echo(msg)
20
+ call_rpc('Echo', {
21
+ data: msg
22
+ })
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,93 @@
1
+ module Evolis
2
+ module PremiumSdk
3
+ module Error
4
+ class InvalidResponse < StandardError
5
+ def initialize
6
+ super('Invalid or empty response from server.')
7
+ end
8
+ end
9
+
10
+ class InvalidJSON < StandardError
11
+ def initialize(json)
12
+ super("Couldn't parse JSON string received from server:\n#{json}")
13
+ end
14
+ end
15
+
16
+ class ServerError < StandardError
17
+ attr_reader :code, :response_error
18
+
19
+ def initialize(code, message)
20
+ @code = code
21
+ @response_error = message
22
+ super("Server error #{code}: #{message}")
23
+ end
24
+ end
25
+
26
+ class Base64FormatError < StandardError
27
+ def initialize(value)
28
+ super("Value is not valid base64 format: #{value}")
29
+ end
30
+ end
31
+
32
+ class NoActiveSessionError < StandardError
33
+ def initialize
34
+ super('Could not find active session.')
35
+ end
36
+ end
37
+
38
+ class InvalidPrintSettingError < StandardError
39
+ def initialize(value)
40
+ super("Setting or value is invalid print settings: #{value}")
41
+ end
42
+ end
43
+
44
+ class NoSuchFaceError < StandardError
45
+ def initialize(face)
46
+ super("Invalid face for printing: #{face}")
47
+ end
48
+ end
49
+
50
+ class NoSuchPanelError < StandardError
51
+ def initialize(panel)
52
+ super("Invalid panel for printing: #{panel}")
53
+ end
54
+ end
55
+
56
+ class InvalidExportFormatError < StandardError
57
+ def initialize(format)
58
+ super("Invalid format for exporting settings: #{format}")
59
+ end
60
+ end
61
+
62
+ class InvalidImportFormatError < StandardError
63
+ def initialize(format)
64
+ super("Invalid format for importing settings: #{format}")
65
+ end
66
+ end
67
+
68
+ class InvalidStateLevelError < StandardError
69
+ def initialize(level)
70
+ super("Invalid level for listing printer state: #{level}")
71
+ end
72
+ end
73
+
74
+ class InvalidEventError < StandardError
75
+ def initialize(event)
76
+ super("Invalid event for setting state: #{event}")
77
+ end
78
+ end
79
+
80
+ class InvalidActionError < StandardError
81
+ def initialize(action)
82
+ super("Invalid action for setting state: #{action}")
83
+ end
84
+ end
85
+
86
+ class InvalidParamError < StandardError
87
+ def initialize(param)
88
+ super("Invalid parameter or value for ESPF service: #{param}")
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end