lifx-lan 0.1.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.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +8 -0
  4. data/.yardopts +3 -0
  5. data/CHANGES.md +45 -0
  6. data/Gemfile +19 -0
  7. data/LICENSE.txt +23 -0
  8. data/README.md +15 -0
  9. data/Rakefile +20 -0
  10. data/bin/lifx-snoop +50 -0
  11. data/examples/auto-off/auto-off.rb +34 -0
  12. data/examples/blink/blink.rb +19 -0
  13. data/examples/identify/identify.rb +69 -0
  14. data/examples/travis-build-light/build-light.rb +57 -0
  15. data/lib/bindata_ext/bool.rb +30 -0
  16. data/lib/bindata_ext/record.rb +11 -0
  17. data/lib/lifx-lan.rb +27 -0
  18. data/lib/lifx/lan/client.rb +149 -0
  19. data/lib/lifx/lan/color.rb +199 -0
  20. data/lib/lifx/lan/config.rb +17 -0
  21. data/lib/lifx/lan/firmware.rb +60 -0
  22. data/lib/lifx/lan/gateway_connection.rb +185 -0
  23. data/lib/lifx/lan/light.rb +440 -0
  24. data/lib/lifx/lan/light_collection.rb +111 -0
  25. data/lib/lifx/lan/light_target.rb +185 -0
  26. data/lib/lifx/lan/logging.rb +14 -0
  27. data/lib/lifx/lan/message.rb +168 -0
  28. data/lib/lifx/lan/network_context.rb +188 -0
  29. data/lib/lifx/lan/observable.rb +66 -0
  30. data/lib/lifx/lan/protocol/address.rb +25 -0
  31. data/lib/lifx/lan/protocol/device.rb +387 -0
  32. data/lib/lifx/lan/protocol/header.rb +24 -0
  33. data/lib/lifx/lan/protocol/light.rb +142 -0
  34. data/lib/lifx/lan/protocol/message.rb +19 -0
  35. data/lib/lifx/lan/protocol/metadata.rb +23 -0
  36. data/lib/lifx/lan/protocol/payload.rb +12 -0
  37. data/lib/lifx/lan/protocol/sensor.rb +31 -0
  38. data/lib/lifx/lan/protocol/type.rb +204 -0
  39. data/lib/lifx/lan/protocol/wan.rb +51 -0
  40. data/lib/lifx/lan/protocol/wifi.rb +102 -0
  41. data/lib/lifx/lan/protocol_path.rb +85 -0
  42. data/lib/lifx/lan/required_keyword_arguments.rb +12 -0
  43. data/lib/lifx/lan/routing_manager.rb +114 -0
  44. data/lib/lifx/lan/routing_table.rb +48 -0
  45. data/lib/lifx/lan/seen.rb +25 -0
  46. data/lib/lifx/lan/site.rb +97 -0
  47. data/lib/lifx/lan/tag_manager.rb +111 -0
  48. data/lib/lifx/lan/tag_table.rb +49 -0
  49. data/lib/lifx/lan/target.rb +24 -0
  50. data/lib/lifx/lan/thread.rb +13 -0
  51. data/lib/lifx/lan/timers.rb +29 -0
  52. data/lib/lifx/lan/transport.rb +46 -0
  53. data/lib/lifx/lan/transport/tcp.rb +91 -0
  54. data/lib/lifx/lan/transport/udp.rb +87 -0
  55. data/lib/lifx/lan/transport_manager.rb +43 -0
  56. data/lib/lifx/lan/transport_manager/lan.rb +169 -0
  57. data/lib/lifx/lan/utilities.rb +36 -0
  58. data/lib/lifx/lan/version.rb +5 -0
  59. data/lifx-lan.gemspec +26 -0
  60. data/spec/color_spec.rb +43 -0
  61. data/spec/gateway_connection_spec.rb +30 -0
  62. data/spec/integration/client_spec.rb +42 -0
  63. data/spec/integration/light_spec.rb +56 -0
  64. data/spec/integration/tags_spec.rb +42 -0
  65. data/spec/light_collection_spec.rb +37 -0
  66. data/spec/message_spec.rb +183 -0
  67. data/spec/protocol_path_spec.rb +109 -0
  68. data/spec/routing_manager_spec.rb +25 -0
  69. data/spec/routing_table_spec.rb +23 -0
  70. data/spec/spec_helper.rb +56 -0
  71. data/spec/transport/udp_spec.rb +44 -0
  72. data/spec/transport_spec.rb +14 -0
  73. metadata +187 -0
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ module LIFX
4
+ module LAN
5
+ describe Transport::UDP, integration: true do
6
+ subject(:udp) { Transport::UDP.new(host, port) }
7
+
8
+ let(:host) { 'localhost' }
9
+ let(:message) { double }
10
+ let(:port) { 45_828 }
11
+
12
+ describe '#write' do
13
+ let(:payload) { double }
14
+
15
+ it 'writes a Message to specified host' do
16
+ expect(message).to receive(:pack).and_return(payload)
17
+ expect_any_instance_of(UDPSocket).to receive(:send)
18
+ .with(payload, 0, host, port)
19
+ udp.write(message)
20
+ end
21
+ end
22
+
23
+ describe '#listen' do
24
+ let(:raw_message) { 'some binary data' }
25
+ let(:socket) { UDPSocket.new }
26
+ let(:messages) { [] }
27
+ before do
28
+ udp.add_observer(self, :message_received) do |message: nil, ip: nil, transport: nil|
29
+ messages << message
30
+ end
31
+ udp.listen
32
+ end
33
+
34
+ it 'listens to the specified socket data, unpacks it and notifies observers' do
35
+ expect(Message).to receive(:unpack)
36
+ .with(raw_message)
37
+ .and_return(message)
38
+ socket.send(raw_message, 0, host, port)
39
+ wait { expect(messages).to include(message) }
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe LIFX::LAN::Transport do
4
+ # Transport handles communicating to the bulbs
5
+ # UDP, TCP, Cloud
6
+
7
+ describe 'initialize' do
8
+ it 'takes an host and port' do
9
+ transport = LIFX::LAN::Transport.new('127.0.0.1', 31_337)
10
+ expect(transport.host).to eq '127.0.0.1'
11
+ expect(transport.port).to eq 31_337
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lifx-lan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jack Chen (chendo), Julian Cheal (juliancheal)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bindata
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: timers
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: configatron
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ description: A Ruby gem that allows easy interaction with LIFX devices.
70
+ email:
71
+ - julian.cheal+lifx-gem@lifx.co
72
+ executables:
73
+ - lifx-snoop
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - ".yardopts"
80
+ - CHANGES.md
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/lifx-snoop
86
+ - examples/auto-off/auto-off.rb
87
+ - examples/blink/blink.rb
88
+ - examples/identify/identify.rb
89
+ - examples/travis-build-light/build-light.rb
90
+ - lib/bindata_ext/bool.rb
91
+ - lib/bindata_ext/record.rb
92
+ - lib/lifx-lan.rb
93
+ - lib/lifx/lan/client.rb
94
+ - lib/lifx/lan/color.rb
95
+ - lib/lifx/lan/config.rb
96
+ - lib/lifx/lan/firmware.rb
97
+ - lib/lifx/lan/gateway_connection.rb
98
+ - lib/lifx/lan/light.rb
99
+ - lib/lifx/lan/light_collection.rb
100
+ - lib/lifx/lan/light_target.rb
101
+ - lib/lifx/lan/logging.rb
102
+ - lib/lifx/lan/message.rb
103
+ - lib/lifx/lan/network_context.rb
104
+ - lib/lifx/lan/observable.rb
105
+ - lib/lifx/lan/protocol/address.rb
106
+ - lib/lifx/lan/protocol/device.rb
107
+ - lib/lifx/lan/protocol/header.rb
108
+ - lib/lifx/lan/protocol/light.rb
109
+ - lib/lifx/lan/protocol/message.rb
110
+ - lib/lifx/lan/protocol/metadata.rb
111
+ - lib/lifx/lan/protocol/payload.rb
112
+ - lib/lifx/lan/protocol/sensor.rb
113
+ - lib/lifx/lan/protocol/type.rb
114
+ - lib/lifx/lan/protocol/wan.rb
115
+ - lib/lifx/lan/protocol/wifi.rb
116
+ - lib/lifx/lan/protocol_path.rb
117
+ - lib/lifx/lan/required_keyword_arguments.rb
118
+ - lib/lifx/lan/routing_manager.rb
119
+ - lib/lifx/lan/routing_table.rb
120
+ - lib/lifx/lan/seen.rb
121
+ - lib/lifx/lan/site.rb
122
+ - lib/lifx/lan/tag_manager.rb
123
+ - lib/lifx/lan/tag_table.rb
124
+ - lib/lifx/lan/target.rb
125
+ - lib/lifx/lan/thread.rb
126
+ - lib/lifx/lan/timers.rb
127
+ - lib/lifx/lan/transport.rb
128
+ - lib/lifx/lan/transport/tcp.rb
129
+ - lib/lifx/lan/transport/udp.rb
130
+ - lib/lifx/lan/transport_manager.rb
131
+ - lib/lifx/lan/transport_manager/lan.rb
132
+ - lib/lifx/lan/utilities.rb
133
+ - lib/lifx/lan/version.rb
134
+ - lifx-lan.gemspec
135
+ - spec/color_spec.rb
136
+ - spec/gateway_connection_spec.rb
137
+ - spec/integration/client_spec.rb
138
+ - spec/integration/light_spec.rb
139
+ - spec/integration/tags_spec.rb
140
+ - spec/light_collection_spec.rb
141
+ - spec/message_spec.rb
142
+ - spec/protocol_path_spec.rb
143
+ - spec/routing_manager_spec.rb
144
+ - spec/routing_table_spec.rb
145
+ - spec/spec_helper.rb
146
+ - spec/transport/udp_spec.rb
147
+ - spec/transport_spec.rb
148
+ homepage: https://github.com/juliancheal/lifx-lan
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '2.0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.6.13
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: A Ruby gem that allows easy interaction with LIFX devices. Handles discovery,
172
+ rate limiting, tags, gateway connections and provides an object-based API for interacting
173
+ with LIFX devices.
174
+ test_files:
175
+ - spec/color_spec.rb
176
+ - spec/gateway_connection_spec.rb
177
+ - spec/integration/client_spec.rb
178
+ - spec/integration/light_spec.rb
179
+ - spec/integration/tags_spec.rb
180
+ - spec/light_collection_spec.rb
181
+ - spec/message_spec.rb
182
+ - spec/protocol_path_spec.rb
183
+ - spec/routing_manager_spec.rb
184
+ - spec/routing_table_spec.rb
185
+ - spec/spec_helper.rb
186
+ - spec/transport/udp_spec.rb
187
+ - spec/transport_spec.rb