ruboty-pi_gpio 0.1.2 → 0.2.0

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
2
  SHA1:
3
- metadata.gz: 5277d61c5fc39199fcb1ba9dd02b5a8cf7301e3f
4
- data.tar.gz: 5fce6dc8615971328b4bb83541282cc31a738931
3
+ metadata.gz: ce5fdece496978e95494680de50bae38b427cb62
4
+ data.tar.gz: 349332be9c40271c9044a386480490253833d400
5
5
  SHA512:
6
- metadata.gz: 3c909882b16b1fef8f18c7f7d8648be395b932322e18b95083dcf832e7481a38b9a443ec46984b8cacffc08437e464ebc496f0b4d5b589a17664f689f5ae9eba
7
- data.tar.gz: ced0469dc0d634540b9fb31469c5836c472554ba29f7d7921494b8dbe3c5b8eb652f85eb53a27d9402d133ca0560976f8e56b5d6376a940dc30e64c23e52f0f0
6
+ metadata.gz: 3816299186b9524563cb5c1f4c74b1f16409f8c63ed73bcc9280ab469e8159292f5bd73dd9b7939d0db5f17480fb38beb6416ed0f35f33cc44bf93a855a56688
7
+ data.tar.gz: 915259760117f15ba6ea890054589c536016411a7e2123b6cb197fbdbcf25da93d0b9d6248bd1f4b1542719b7b10ad84dfcbd782b1601ee25df925decef91ca7
@@ -8,6 +8,10 @@ module Ruboty
8
8
  message[:pin]
9
9
  end
10
10
 
11
+ def robot
12
+ message.robot
13
+ end
14
+
11
15
  def export
12
16
  open('/sys/class/gpio/export', 'w') { |f| f.write(pin) }
13
17
  rescue => e
@@ -27,6 +31,10 @@ module Ruboty
27
31
  Ruboty.logger.error(e.backtrace.join("\n") + "\n")
28
32
  end
29
33
  end
34
+
35
+ def prefix
36
+ Ruboty::Action.prefix_pattern(robot.name)
37
+ end
30
38
  end
31
39
  end
32
40
  end
@@ -2,19 +2,25 @@ module Ruboty
2
2
  module PiGpio
3
3
  module Actions
4
4
  class Read < Base
5
+ include Mem
6
+
5
7
  def call
6
- message.reply(value)
8
+ robot.receive(message.original.merge(body: body))
7
9
  end
8
10
 
9
11
  private
10
12
 
13
+ def body
14
+ "#{message.body[prefix]}GPIO#{pin} is #{value}"
15
+ end
16
+
11
17
  def value
12
- File.read("/sys/class/gpio/gpio#{pin}/value")
18
+ File.read("/sys/class/gpio/gpio#{pin}/value").chomp
13
19
  rescue => e
14
20
  log(e)
15
21
  end
22
+ memoize :value
16
23
  end
17
24
  end
18
25
  end
19
26
  end
20
-
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module PiGpio
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-pi_gpio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - izumin5210