ruboty-toggle_switch 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 580bf6e33db15308f664caee452443305ef7c62a
4
- data.tar.gz: 45b97438c8fa479f90585533bf967e7906b242e4
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDhkNmU5ZGE4MGUyMTQ0ZWM1YmRjNDY4Nzc0MWNlNmY2MDQzYWE0Nw==
5
+ data.tar.gz: !binary |-
6
+ ZDA1ZTc3ZjMyMGYyZGFlMWU5ZjBmZjc0N2Y5YWEzMTE4NzE0NTI0YQ==
5
7
  SHA512:
6
- metadata.gz: 82aa4cd51bb856c6069176874809f718915018e7a629031d3b37335306ad40f0a49b1d7870af029ca0cdb8441c93062dfb81fec01122c9cc13e1ad3e1e33d803
7
- data.tar.gz: 1bb763dfe7eff9d94f5b38c1784b2a85540d8feaa77f4236b7fde00c68a9a6249b943aef1c7c2f4bc96891ae9146066cbce4f6f96b4373c3d647e91f409f488c
8
+ metadata.gz: !binary |-
9
+ NzI5YmFkOTRhYmQ0NWMwZTc5YzZmM2MzMDk2N2Q0NTgxMjgzZGIxMGU0ZDhi
10
+ YTk5ODU0YzU5YmI0MzM0NTUzNDJmNWQwMjMyMWNlZTAzZGEwNDEzZWQ0YzI5
11
+ ZDQxNThkMWZiNzkxMDJjY2RkZjZlZWM4ZWVmM2FhMTQ5Njk3MDU=
12
+ data.tar.gz: !binary |-
13
+ OTRhYzI3NjY0MjVhZmJmYWU4OWNhMjBiMDk2OTBjMDYwYTcxZTE3Y2M4MjZk
14
+ Mzg5NTNlZjllMDA4M2ZlMGUzYmY2ODYwZGQ5OTJmMDNjOGM4YzhmNzVlMzFm
15
+ MGVlZDFlNTk0ZjE3YmUzMGNkMWZiMmNkNzI3YTZhMmZlMzVlMDQ=
data/.travis.yml CHANGED
@@ -3,3 +3,11 @@ rvm:
3
3
  - 2.3.0
4
4
  cache: bundler
5
5
  sudo: false
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: lpWEA88TEJ3dajzamEJyqfZJmFV44E/UDfvAjEvf2+tnZxA4E9goOlIP3iS8QZwaWHTCPbB8PUWMRX6Zumdbcnzx314i9dFcH+oiiypJO+Y2UxViGuB1WWwVye4EEEcsRCE82g5qi73/ALuFRi3TtQgRtzCgfTgzDGA2uS/gZtj9Al3B7AytdvmExCy5j6vB7WrU7YjTOFWGrqYQGSMo+ccS2fwJL2kMYAEBgF26Sx1oX9uhhokVvlA0kyFc04WFpdq7tAJxZYkGe4sFIMJ9+d9x5ZytDLjv96RWEl0z7Jxj1rOcUtc/zoFgd4jyszn8rMKkCeJSSYUCgZmVjz8D4iw0xXWRdnuuxjL856/PW3mN8ETRxlRWKG0ohdR5Tgk26reWlBBUWkvPBtjSkukO13DWWO5R7FJOawjA5y3iN24MjPbQOgUvC+YtvANjbIaAyyrZL4oCahgZyfDBeq3i22kE1cYc5oMQr5MfSoG+4XpspkpFgr3b0bmkANSD4fx0b/Ey0YbUUx+Glbx0StosH8DyUQvSdvBwbGfla6KJXRaUDZMNm130bmzBTbhnhQVEvWS6ahuZ7e5vgeouaqsZ6qexUf/XYpfHLCmRMGktGWaak4aL9j6qe9sP7j96jIoIlokBnKWMtmC2jaJClR5deZtQSpAHBWk4oLp4laZZ92k=
10
+ gem: ruboty-toggle_switch
11
+ on:
12
+ tags: true
13
+ repo: takai/ruboty-toggle_switch
data/README.md CHANGED
@@ -14,6 +14,14 @@ gem 'ruboty-toggle_switch'
14
14
 
15
15
  ## Usage
16
16
 
17
+ ```
18
+ ruboty: toggle <switch> (on|off) - Toggle key status.
19
+ ruboty: show <switch> status - Show the current status.
20
+ ruboty: list switches - List the statuses of switches
21
+ ```
22
+
23
+ ## Examples
24
+
17
25
  ```
18
26
  > ruboty: toggle switch on
19
27
  switch is now on.
@@ -23,6 +31,8 @@ switch is on on Apr 27 at 06:29.
23
31
  switch is now off.
24
32
  > ruboty: show switch status
25
33
  switch is off for good sleeping on Apr 27 at 06:30.
34
+ > ruboty: list switches
35
+ - switch is off.
26
36
  ```
27
37
 
28
38
  ## API
@@ -34,3 +44,5 @@ storage = Ruboty::ToggleSwitch::Storage.new(robot.brain)
34
44
  record = storage['switch']
35
45
  record.status # => 'on' or 'off'
36
46
  ```
47
+
48
+ http://www.rubydoc.info/github/takai/ruboty-toggle_switch/master/Ruboty/ToggleSwitch/Storage
@@ -3,47 +3,62 @@ module Ruboty
3
3
  class Storage
4
4
  include Enumerable
5
5
 
6
- Record = Struct.new(:state, :from, :at, :note)
6
+ # Represents a switch.
7
+ Switch = Struct.new(:state, :from, :at, :note)
7
8
 
8
9
  NAMESPACE = 'ruboty-toggle_switch-storage'
9
10
 
11
+ # Returns a new instance of Storage
12
+ # @param [Ruboty::Brain] brain
10
13
  def initialize(brain)
11
14
  @brain = brain
12
15
  end
13
16
 
17
+ # Returns the switch to which the specified key is mapped.
18
+ #
19
+ # @return [Switch, nil] the switch or nil
14
20
  def [](key)
15
- records[key]
21
+ switches[key]
16
22
  end
17
23
 
24
+ # Update the switch which is associated with the specified key.
25
+ #
26
+ # @param [String] key the key for the switch.
27
+ # @param [Hash] value the value to update the switch.
28
+ # @option value [String] :state "on" or "off".
29
+ # @option value [String] :from a name of the message sender.
18
30
  def []=(key, value)
19
- records[key] = Record.new(value[:state], value[:from], Time.now, value[:note])
31
+ switches[key] = Switch.new(value[:state], value[:from], Time.now, value[:note])
20
32
  end
21
33
 
34
+ # Returns true if the switch is 'on'.
35
+ #
36
+ # @return [Boolean] true if the state of the switch is "on"
22
37
  def on?(key)
23
38
  state_for(key) == 'on'
24
39
  end
25
40
 
41
+ # Returns true if the switch is 'off'.
42
+ #
43
+ # @return [Boolean] true if the state of the switch is "off"
26
44
  def off?(key)
27
45
  state_for(key) == 'off'
28
46
  end
29
47
 
48
+ # Yields each pair of the key and switch.
30
49
  def each
31
- records.each do |entry|
50
+ switches.each do |entry|
32
51
  yield(*entry)
33
52
  end
34
53
  end
35
54
 
36
- def size
37
- records.size
38
- end
39
-
40
55
  private
41
56
 
42
57
  def state_for(key)
43
- records[key] && records[key].state
58
+ switches[key] && switches[key].state
44
59
  end
45
60
 
46
- def records
61
+ def switches
47
62
  @brain.data[NAMESPACE] ||= {}
48
63
  end
49
64
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module ToggleSwitch
3
- VERSION = '0.4.0'
3
+ VERSION = '0.4.1'
4
4
  end
5
5
  end
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'bundler', '~> 1.11'
23
23
  spec.add_development_dependency 'rake', '~> 10.0'
24
24
  spec.add_development_dependency 'rspec', '~> 3.0'
25
+ spec.add_development_dependency 'yard', '~> 0.8'
25
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-toggle_switch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naoto Takai
@@ -14,58 +14,72 @@ dependencies:
14
14
  name: ruboty
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.11'
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
40
  version: '1.11'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '10.0'
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
54
  version: '10.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '3.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
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '0.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '0.8'
69
83
  description: ruboty-toggle_switch allows you to toggle switch on/off.
70
84
  email:
71
85
  - takai@recompile.net
@@ -73,9 +87,9 @@ executables: []
73
87
  extensions: []
74
88
  extra_rdoc_files: []
75
89
  files:
76
- - ".gitignore"
77
- - ".rspec"
78
- - ".travis.yml"
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
79
93
  - Gemfile
80
94
  - LICENSE
81
95
  - README.md
@@ -96,19 +110,18 @@ require_paths:
96
110
  - lib
97
111
  required_ruby_version: !ruby/object:Gem::Requirement
98
112
  requirements:
99
- - - ">="
113
+ - - ! '>='
100
114
  - !ruby/object:Gem::Version
101
115
  version: '0'
102
116
  required_rubygems_version: !ruby/object:Gem::Requirement
103
117
  requirements:
104
- - - ">="
118
+ - - ! '>='
105
119
  - !ruby/object:Gem::Version
106
120
  version: '0'
107
121
  requirements: []
108
122
  rubyforge_project:
109
- rubygems_version: 2.5.1
123
+ rubygems_version: 2.4.5
110
124
  signing_key:
111
125
  specification_version: 4
112
126
  summary: ruboty-toggle_switch allows you to toggle switch on/off.
113
127
  test_files: []
114
- has_rdoc: