omega2_gpio 0.1.06.pre.alpha01 → 0.1.06.pre.alpha02

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 77040ca234ecd31572765fe213728ddccc6f510b
4
- data.tar.gz: 5f79acc2d383d214f238939b0f566ab81ed17d8f
2
+ SHA256:
3
+ metadata.gz: a78a1b7725c58604f843bf7ec51dfe8f55f7e39e768a779a837b7b9ea1e18289
4
+ data.tar.gz: 048d6c243b1e1a8b13a1f770966e3e1cbf82c19d804e3c05188b05ad2c74f0bb
5
5
  SHA512:
6
- metadata.gz: 44e73fa735f855c1fa49d0cd5a98e20ec0eeccfa276d7d26de4cad8d3a1e4e155e3d0e054d09cf994cd34c3bf8a996814921e2f3fcc440527faa46e48439dbfc
7
- data.tar.gz: a2e366d12d9e592d9723bad44887b783feace6895573b8a498833465ec09febbc898eb4cc95775a9efd83a27cc4fbc87a6426a86a5fd7fa9c301982c45bee179
6
+ metadata.gz: 15d49af68f1a7b63ce34bbb3bea968bd1a0b2bb51b4e00162bb0ff0a7760a1659712d9dbdb2e68d14d120459125ae95f35966bfc0c970ebc5679384522982918
7
+ data.tar.gz: 8d659b90de87c7a68d89d3e87e7d26a61e458696e863eb0241df915f25ecd4aeea97176fae97943a017a11034bec6b7258b83a09631036704554fd01e8bfaf06
data/.travis.yml CHANGED
@@ -1,22 +1,22 @@
1
- language: ruby
2
- before_install: gem install bundler -v 1.11.2
3
-
4
- rvm:
5
- - 1.9
6
- - 2.2.4
7
- - 2.3
8
- - 2.4
9
-
10
- script: echo "Running tests against $(ruby -v) ..."
11
-
12
- jobs:
13
- include:
14
- - stage: gem build
15
- rvm: 2.2
16
- script: echo "Deploying to rubygems.org ..."
17
- deploy:
18
- provider: rubygems
19
- #gem: omega2_gpio
20
- api_key: $RUBYGEMS_API_KEY
21
- on:
1
+ language: ruby
2
+ before_install: gem install bundler -v 1.11.2
3
+
4
+ rvm:
5
+ - 1.9
6
+ - 2.2.4
7
+ - 2.3
8
+ - 2.4
9
+
10
+ script: echo "Running tests against $(ruby -v) ..."
11
+
12
+ jobs:
13
+ include:
14
+ - stage: gem build
15
+ rvm: 2.2
16
+ script: echo "Deploying to rubygems.org ..."
17
+ deploy:
18
+ provider: rubygems
19
+ #gem: omega2_gpio
20
+ api_key: $RUBYGEMS_API_KEY
21
+ on:
22
22
  branch: master
data/Rakefile CHANGED
@@ -7,4 +7,10 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
+ Rake::TestTask.new(:damagingtest) do |t|
11
+ t.libs << "test"
12
+ t.libs << "lib"
13
+ t.test_files = FileList['test/**/*_test_may_damage_hardware.rb']
14
+ end
15
+
10
16
  task :default => :test
@@ -1,56 +1,56 @@
1
- # coding: utf-8
2
- module Omega2Gpio
3
- class Configuration
4
-
5
- # Controls whether the GPIO shall be controlled on Onion Omegas file system
6
- # or just mocked/faked as valid to allow development on systems that
7
- # do not support Omega's GPIO control and would raise errors constantly
8
- # Defaults to `false`. Set to `true` to mock Onion Omega GPIO
9
- attr_accessor :mock
10
-
11
- # Controls whether the Gem shall write debug messages
12
- # to standard out.
13
- # This can be helpful messages like file system commands that are mocked
14
- # Defaults to :debug.
15
- # Defined are
16
- # 2 ==> puts all messages
17
- # 1 ==> puts warnings
18
- # 0 ==> no messages at all
19
- attr_accessor :messaging_level
20
-
21
- # depends on Onion Omega2 hardware,
22
- # needed to raise error in mock-mode
23
- attr_accessor :highest_gpio_number
24
-
25
- def initialize
26
- @mock = false
27
- @messaging_level = 2
28
- @highest_gpio_number = 46
29
- end
30
- end
31
-
32
- # @return [Omega2Gpio::Configuration] Omega2Gpio's current configuration
33
- def self.configuration
34
- @configuration ||= Configuration.new
35
- end
36
-
37
- ## Set Omega2Gpio's configuration
38
- ## @param config [Omega2Gpio::Configuration]
39
- def self.configuration=(config)
40
- @configuration = config
41
- end
42
-
43
- # Modify Omega2Gpio's current configuration
44
- # @yieldparam [Omega2Gpio::Configuration] config current Omega2Gpio config
45
- # ```
46
- # Omega2Gpio.configure do |config|
47
- # config.routes = false
48
- # end
49
- # ```
50
- def self.configure
51
- yield configuration
52
- end
53
- end
54
-
55
- # Configuration pattern stolen from Thoughtbot's Clearance
56
- # https://github.com/thoughtbot/clearance/blob/master/lib/clearance/configuration.rb
1
+ # coding: utf-8
2
+ module Omega2Gpio
3
+ class Configuration
4
+
5
+ # Controls whether the GPIO shall be controlled on Onion Omegas file system
6
+ # or just mocked/faked as valid to allow development on systems that
7
+ # do not support Omega's GPIO control and would raise errors constantly
8
+ # Defaults to `false`. Set to `true` to mock Onion Omega GPIO
9
+ attr_accessor :mock
10
+
11
+ # Controls whether the Gem shall write debug messages
12
+ # to standard out.
13
+ # This can be helpful messages like file system commands that are mocked
14
+ # Defaults to :debug.
15
+ # Defined are
16
+ # 2 ==> puts all messages
17
+ # 1 ==> puts warnings
18
+ # 0 ==> no messages at all
19
+ attr_accessor :messaging_level
20
+
21
+ # depends on Onion Omega2 hardware,
22
+ # needed to raise error in mock-mode
23
+ attr_accessor :highest_gpio_number
24
+
25
+ def initialize
26
+ @mock = false
27
+ @messaging_level = 2
28
+ @highest_gpio_number = 46
29
+ end
30
+ end
31
+
32
+ # @return [Omega2Gpio::Configuration] Omega2Gpio's current configuration
33
+ def self.configuration
34
+ @configuration ||= Configuration.new
35
+ end
36
+
37
+ ## Set Omega2Gpio's configuration
38
+ ## @param config [Omega2Gpio::Configuration]
39
+ def self.configuration=(config)
40
+ @configuration = config
41
+ end
42
+
43
+ # Modify Omega2Gpio's current configuration
44
+ # @yieldparam [Omega2Gpio::Configuration] config current Omega2Gpio config
45
+ # ```
46
+ # Omega2Gpio.configure do |config|
47
+ # config.routes = false
48
+ # end
49
+ # ```
50
+ def self.configure
51
+ yield configuration
52
+ end
53
+ end
54
+
55
+ # Configuration pattern stolen from Thoughtbot's Clearance
56
+ # https://github.com/thoughtbot/clearance/blob/master/lib/clearance/configuration.rb
@@ -1,9 +1,9 @@
1
- # coding: utf-8
2
- module Omega2Gpio
3
- class FastGpioError < StandardError
4
- end
5
-
6
- def raise_error(error)
7
- raise(FastGpioError, error.message)
8
- end
1
+ # coding: utf-8
2
+ module Omega2Gpio
3
+ class FastGpioError < StandardError
4
+ end
5
+
6
+ def raise_error(error)
7
+ raise(FastGpioError, error.message)
8
+ end
9
9
  end
@@ -1,76 +1,76 @@
1
- # coding: utf-8
2
- module Omega2Gpio
3
- class Gpio
4
- attr_reader :gpio_number
5
- attr_reader :value
6
- attr_reader :direction
7
-
8
- def initialize(gpio_number, direction)
9
- @gpio_number = gpio_number
10
- @value = 0
11
- @direction = direction
12
-
13
- command = "fast-gpio set-#{direction} #{self.gpio_number}"
14
- if Omega2Gpio.configuration.mock && gpio_number.between?(0, Omega2Gpio.configuration.highest_gpio_number)
15
- Omega2Gpio.messenger.debug "Init Fake-GPIO#{@gpio_number} and mock all interactions as valid"
16
- mock_fast_gpio_command command
17
- else
18
- execute_fast_gpio_command command
19
- end
20
-
21
- self
22
- end
23
-
24
- def self.is_mock?
25
- Omega2Gpio.configuration.mock
26
- end
27
-
28
- def read
29
- command = "fast-gpio read #{@gpio_number}"
30
- if Omega2Gpio.configuration.mock
31
- mock_fast_gpio_command command
32
- else
33
- stdout = execute_fast_gpio_command command
34
- @value = stdout.gets.to_s.split.last.to_i
35
- end
36
-
37
- @value
38
- end
39
-
40
- def get
41
- read
42
- end
43
-
44
- def is_high?
45
- read == 1
46
- end
47
-
48
- def high?
49
- is_high?
50
- end
51
-
52
- def is_low?
53
- read == 0
54
- end
55
-
56
- def low?
57
- is_low?
58
- end
59
-
60
- private
61
-
62
- def execute_fast_gpio_command(command)
63
- stdin, stdout, stderr = Open3.popen3(command)
64
- if stderr.gets
65
- Omega2Gpio.raise_error(stderr.gets)
66
- end
67
- Omega2Gpio.messenger.debug "System command: #{command}"
68
- Omega2Gpio.messenger.debug " returns: #{stdout}"
69
- stdout
70
- end
71
-
72
- def mock_fast_gpio_command(command)
73
- Omega2Gpio.messenger.debug "Mock command: #{command}"
74
- end
75
- end
76
- end
1
+ # coding: utf-8
2
+ module Omega2Gpio
3
+ class Gpio
4
+ attr_reader :gpio_number
5
+ attr_reader :value
6
+ attr_reader :direction
7
+
8
+ def initialize(gpio_number, direction)
9
+ @gpio_number = gpio_number
10
+ @value = 0
11
+ @direction = direction
12
+
13
+ command = "fast-gpio set-#{direction} #{self.gpio_number}"
14
+ if Omega2Gpio.configuration.mock && gpio_number.between?(0, Omega2Gpio.configuration.highest_gpio_number)
15
+ Omega2Gpio.messenger.debug "Init Fake-GPIO#{@gpio_number} and mock all interactions as valid"
16
+ mock_fast_gpio_command command
17
+ else
18
+ execute_fast_gpio_command command
19
+ end
20
+
21
+ self
22
+ end
23
+
24
+ def self.is_mock?
25
+ Omega2Gpio.configuration.mock
26
+ end
27
+
28
+ def read
29
+ command = "fast-gpio read #{@gpio_number}"
30
+ if Omega2Gpio.configuration.mock
31
+ mock_fast_gpio_command command
32
+ else
33
+ stdout = execute_fast_gpio_command command
34
+ @value = stdout.gets.to_s.split.last.to_i
35
+ end
36
+
37
+ @value
38
+ end
39
+
40
+ def get
41
+ read
42
+ end
43
+
44
+ def is_high?
45
+ read == 1
46
+ end
47
+
48
+ def high?
49
+ is_high?
50
+ end
51
+
52
+ def is_low?
53
+ read == 0
54
+ end
55
+
56
+ def low?
57
+ is_low?
58
+ end
59
+
60
+ private
61
+
62
+ def execute_fast_gpio_command(command)
63
+ stdin, stdout, stderr = Open3.popen3(command)
64
+ if stderr.gets
65
+ Omega2Gpio.raise_error(stderr.gets)
66
+ end
67
+ Omega2Gpio.messenger.debug "System command: #{command}"
68
+ Omega2Gpio.messenger.debug " returns: #{stdout}"
69
+ stdout
70
+ end
71
+
72
+ def mock_fast_gpio_command(command)
73
+ Omega2Gpio.messenger.debug "Mock command: #{command}"
74
+ end
75
+ end
76
+ end
@@ -1,8 +1,8 @@
1
- # coding: utf-8
2
- module Omega2Gpio
3
- class Input < Gpio
4
- def initialize(gpio_number)
5
- super(gpio_number, "input")
6
- end
7
- end
1
+ # coding: utf-8
2
+ module Omega2Gpio
3
+ class Input < Gpio
4
+ def initialize(gpio_number)
5
+ super(gpio_number, "input")
6
+ end
7
+ end
8
8
  end
@@ -1,16 +1,16 @@
1
- # coding: utf-8
2
- module Omega2Gpio
3
- class Messaging
4
- def debug(message)
5
- puts message if Omega2Gpio.configuration.messaging_level >= 2
6
- end
7
-
8
- def warn(message)
9
- puts message if Omega2Gpio.configuration.messaging_level >= 1
10
- end
11
- end
12
-
13
- def self.messenger
14
- @messenger ||= Messaging.new
15
- end
1
+ # coding: utf-8
2
+ module Omega2Gpio
3
+ class Messaging
4
+ def debug(message)
5
+ puts message if Omega2Gpio.configuration.messaging_level >= 2
6
+ end
7
+
8
+ def warn(message)
9
+ puts message if Omega2Gpio.configuration.messaging_level >= 1
10
+ end
11
+ end
12
+
13
+ def self.messenger
14
+ @messenger ||= Messaging.new
15
+ end
16
16
  end
@@ -1,29 +1,29 @@
1
- # coding: utf-8
2
- module Omega2Gpio
3
- class Output < Gpio
4
- def initialize(gpio_number)
5
- super(gpio_number, "output")
6
- end
7
-
8
- def set(value)
9
- command = "fast-gpio set #{self.gpio_number} #{value}"
10
- if Omega2Gpio.configuration.mock
11
- mock_fast_gpio_command command
12
- else
13
- execute_fast_gpio_command command
14
- end
15
- @value = value
16
-
17
- self
18
- end
19
-
20
- def high
21
- set(1)
22
- end
23
-
24
- def low
25
- set(0)
26
- end
27
-
28
- end
29
- end
1
+ # coding: utf-8
2
+ module Omega2Gpio
3
+ class Output < Gpio
4
+ def initialize(gpio_number)
5
+ super(gpio_number, "output")
6
+ end
7
+
8
+ def set(value)
9
+ command = "fast-gpio set #{self.gpio_number} #{value}"
10
+ if Omega2Gpio.configuration.mock
11
+ mock_fast_gpio_command command
12
+ else
13
+ execute_fast_gpio_command command
14
+ end
15
+ @value = value
16
+
17
+ self
18
+ end
19
+
20
+ def high
21
+ set(1)
22
+ end
23
+
24
+ def low
25
+ set(0)
26
+ end
27
+
28
+ end
29
+ end
@@ -1,4 +1,4 @@
1
- # coding: utf-8
2
- module Omega2Gpio
3
- VERSION = "0.1.06-alpha01".freeze
4
- end
1
+ # coding: utf-8
2
+ module Omega2Gpio
3
+ VERSION = "0.1.06-alpha02".freeze
4
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omega2_gpio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.06.pre.alpha01
4
+ version: 0.1.06.pre.alpha02
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sönke Ohls
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
11
+ date: 2017-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: 1.3.1
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.6.3
114
+ rubygems_version: 2.7.2
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Ruby wrapper to control Onion Omega2 GPIOs