lifx 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -0
- data/CHANGES.md +7 -0
- data/Gemfile +5 -0
- data/README.md +2 -0
- data/Rakefile +6 -0
- data/lib/lifx.rb +2 -0
- data/lib/lifx/gateway_connection.rb +1 -1
- data/lib/lifx/light.rb +19 -11
- data/lib/lifx/light_collection.rb +2 -1
- data/lib/lifx/light_target.rb +16 -8
- data/lib/lifx/network_context.rb +5 -3
- data/lib/lifx/required_keyword_arguments.rb +10 -0
- data/lib/lifx/routing_manager.rb +3 -1
- data/lib/lifx/routing_table.rb +1 -1
- data/lib/lifx/site.rb +2 -1
- data/lib/lifx/tag_manager.rb +5 -4
- data/lib/lifx/tag_table.rb +1 -1
- data/lib/lifx/transport.rb +1 -1
- data/lib/lifx/transport_manager/lan.rb +10 -3
- data/lib/lifx/version.rb +1 -1
- data/lifx.gemspec +4 -4
- data/spec/integration/client_spec.rb +1 -1
- data/spec/integration/light_spec.rb +4 -4
- data/spec/spec_helper.rb +10 -4
- data/spec/transport/udp_spec.rb +3 -4
- metadata +27 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e413317b0ac40abc57bdf3699b8373451b86614c
|
4
|
+
data.tar.gz: 39852a66321e7352078e56e4b8073c4cb98f067b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c75b51ea1267b7605c5bcaf74bc0daf4c298143aed8e7155f9969231fdc7658ed3ec018bcec9cea0a483fc0b327366db72ab7f2fe17a8ac1f45a7f49efc8eef7
|
7
|
+
data.tar.gz: 7b1b3274a505d44b2e793e1a616058bb4feb96054ea39ebbaf320c79e873f3550686c2a6c35ece2ec6cc0d99dd266fd96bf2b01fdf6e94c3b91b21b42dd03706
|
data/.travis.yml
ADDED
data/CHANGES.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.4.5
|
2
|
+
|
3
|
+
- Now supports Ruby 2.0
|
4
|
+
- Light#label can be nil
|
5
|
+
- Light#set_power and Light#set_power! now take :on and :off rather than magic number
|
6
|
+
- Use timers 1.x so no compilation is required
|
7
|
+
|
1
8
|
# 0.4.4
|
2
9
|
|
3
10
|
- Fix SO_REUSEPORT issue on older Linux kernels.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# LIFX
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/lifx.png)](https://rubygems.org/gems/lifx) [![Build Status](https://travis-ci.org/LIFX/lifx-gem.png)](https://travis-ci.org/LIFX/lifx-gem)
|
4
|
+
|
3
5
|
This gem allows you to control your [LIFX](http://lifx.co) lights.
|
4
6
|
|
5
7
|
It handles discovery, gateway connections, tags, and provides a object-based API
|
data/Rakefile
CHANGED
data/lib/lifx.rb
CHANGED
@@ -66,7 +66,7 @@ module LIFX
|
|
66
66
|
@tcp_attempts += 1
|
67
67
|
logger.info("#{self}: Establishing connection to #{ip}:#{port}")
|
68
68
|
@tcp_transport = Transport::TCP.new(ip, port)
|
69
|
-
@tcp_transport.add_observer(self) do |message
|
69
|
+
@tcp_transport.add_observer(self) do |message: nil, ip: nil, transport: nil|
|
70
70
|
notify_observers(message: message, ip: ip, transport: @tcp_transport)
|
71
71
|
end
|
72
72
|
@tcp_transport.listen
|
data/lib/lifx/light.rb
CHANGED
@@ -11,6 +11,7 @@ module LIFX
|
|
11
11
|
include LightTarget
|
12
12
|
include Logging
|
13
13
|
include Utilities
|
14
|
+
include RequiredKeywordArguments
|
14
15
|
|
15
16
|
# @return [NetworkContext] NetworkContext the Light belongs to
|
16
17
|
attr_reader :context
|
@@ -22,7 +23,7 @@ module LIFX
|
|
22
23
|
# @param id: [String] Device ID of the Light
|
23
24
|
# @param site_id: [String] Site ID of the Light. Avoid using when possible.
|
24
25
|
# @param label: [String] Label of Light to prepopulate
|
25
|
-
def initialize(context
|
26
|
+
def initialize(context: required!(:context), id: id, site_id: nil, label: nil)
|
26
27
|
@context = context
|
27
28
|
@id = id
|
28
29
|
@site_id = site_id
|
@@ -83,7 +84,7 @@ module LIFX
|
|
83
84
|
# Returns the label of the light
|
84
85
|
# @param refresh: [Boolean] If true, will request for current label
|
85
86
|
# @param fetch: [Boolean] If false, it will not request current label if it's not cached
|
86
|
-
# @return [String] Label
|
87
|
+
# @return [String, nil] Label
|
87
88
|
def label(refresh: false, fetch: true)
|
88
89
|
@label = nil if refresh
|
89
90
|
send_message!(Protocol::Light::Get.new, wait_for: Protocol::Light::Get) if fetch && !@label
|
@@ -107,13 +108,20 @@ module LIFX
|
|
107
108
|
self
|
108
109
|
end
|
109
110
|
|
110
|
-
# Set the power state to `
|
111
|
-
#
|
112
|
-
# @param level [0, 1] 0 for off, 1 for on
|
111
|
+
# Set the power state to `state` synchronously.
|
112
|
+
# @param state [:on, :off]
|
113
113
|
# @return [Light, LightCollection] self for chaining
|
114
|
-
def set_power!(
|
114
|
+
def set_power!(state)
|
115
|
+
level = case state
|
116
|
+
when :on
|
117
|
+
1
|
118
|
+
when :off
|
119
|
+
0
|
120
|
+
else
|
121
|
+
raise ArgumentError.new("Must pass in either :on or :off")
|
122
|
+
end
|
115
123
|
send_message!(Protocol::Device::SetPower.new(level: level), wait_for: Protocol::Device::StatePower) do |payload|
|
116
|
-
if level
|
124
|
+
if level == 0
|
117
125
|
payload.level == 0
|
118
126
|
else
|
119
127
|
payload.level > 0
|
@@ -125,13 +133,13 @@ module LIFX
|
|
125
133
|
# Turns the light(s) on synchronously
|
126
134
|
# @return [Light, LightCollection] self for chaining
|
127
135
|
def turn_on!
|
128
|
-
set_power!(
|
136
|
+
set_power!(:on)
|
129
137
|
end
|
130
138
|
|
131
139
|
# Turns the light(s) off synchronously
|
132
140
|
# @return [Light, LightCollection]
|
133
141
|
def turn_off!
|
134
|
-
set_power!(
|
142
|
+
set_power!(:off)
|
135
143
|
end
|
136
144
|
|
137
145
|
# @see #power
|
@@ -356,7 +364,7 @@ module LIFX
|
|
356
364
|
# @param block: [Proc] the block that is executed when the expected `wait_for` payload comes back. If the return value is false or nil, it will try to send the message again.
|
357
365
|
# @return [Object] the truthy result of `block` is returned.
|
358
366
|
# @raise [Timeout::Error]
|
359
|
-
def send_message!(payload, wait_for
|
367
|
+
def send_message!(payload, wait_for: wait_for, wait_timeout: 3, timeout_exception: Timeout::Error, &block)
|
360
368
|
if Thread.current[:sync_enabled]
|
361
369
|
raise "Cannot use synchronous methods inside a sync block"
|
362
370
|
end
|
@@ -385,7 +393,7 @@ module LIFX
|
|
385
393
|
end
|
386
394
|
|
387
395
|
add_hook(Protocol::Light::State) do |payload|
|
388
|
-
@label = payload.label.
|
396
|
+
@label = payload.label.snapshot
|
389
397
|
@color = Color.from_struct(payload.color.snapshot)
|
390
398
|
@power = payload.power.to_i
|
391
399
|
@tags_field = payload.tags
|
@@ -6,6 +6,7 @@ module LIFX
|
|
6
6
|
class LightCollection
|
7
7
|
include LightTarget
|
8
8
|
include Enumerable
|
9
|
+
include RequiredKeywordArguments
|
9
10
|
extend Forwardable
|
10
11
|
|
11
12
|
class TagNotFound < ArgumentError; end
|
@@ -22,7 +23,7 @@ module LIFX
|
|
22
23
|
# @api private
|
23
24
|
# @param context: [NetworkContext] NetworkContext this collection belongs to
|
24
25
|
# @param tag: [String] Tag
|
25
|
-
def initialize(context
|
26
|
+
def initialize(context: required!(:context), tag: nil)
|
26
27
|
@context = context
|
27
28
|
@tag = tag
|
28
29
|
end
|
data/lib/lifx/light_target.rb
CHANGED
@@ -21,8 +21,8 @@ module LIFX
|
|
21
21
|
# Attempts to apply a waveform to the light(s) asynchronously.
|
22
22
|
# @note Don't use this directly.
|
23
23
|
# @api private
|
24
|
-
def set_waveform(color, waveform
|
25
|
-
cycles
|
24
|
+
def set_waveform(color, waveform: required!(:waveform),
|
25
|
+
cycles: required!(:cycles),
|
26
26
|
stream: 0,
|
27
27
|
transient: true,
|
28
28
|
period: 1.0,
|
@@ -138,12 +138,20 @@ module LIFX
|
|
138
138
|
period: period)
|
139
139
|
end
|
140
140
|
|
141
|
-
# Attempts to set the power state to `
|
141
|
+
# Attempts to set the power state to `state` asynchronously.
|
142
142
|
# This method cannot guarantee the message was received.
|
143
|
-
# @param
|
143
|
+
# @param state [:on, :off]
|
144
144
|
# @return [Light, LightCollection] self for chaining
|
145
|
-
def set_power(
|
146
|
-
|
145
|
+
def set_power(state)
|
146
|
+
level = case state
|
147
|
+
when :on
|
148
|
+
1
|
149
|
+
when :off
|
150
|
+
0
|
151
|
+
else
|
152
|
+
raise ArgumentError.new("Must pass in either :on or :off")
|
153
|
+
end
|
154
|
+
send_message(Protocol::Device::SetPower.new(level: level))
|
147
155
|
self
|
148
156
|
end
|
149
157
|
|
@@ -151,14 +159,14 @@ module LIFX
|
|
151
159
|
# This method cannot guarantee the message was received.
|
152
160
|
# @return [Light, LightCollection] self for chaining
|
153
161
|
def turn_on
|
154
|
-
set_power(
|
162
|
+
set_power(:on)
|
155
163
|
end
|
156
164
|
|
157
165
|
# Attempts to turn the light(s) off asynchronously.
|
158
166
|
# This method cannot guarantee the message was received.
|
159
167
|
# @return [Light, LightCollection] self for chaining
|
160
168
|
def turn_off
|
161
|
-
set_power(
|
169
|
+
set_power(:off)
|
162
170
|
end
|
163
171
|
|
164
172
|
# Requests light(s) to report their state
|
data/lib/lifx/network_context.rb
CHANGED
@@ -10,6 +10,7 @@ module LIFX
|
|
10
10
|
include Timers
|
11
11
|
include Logging
|
12
12
|
include Utilities
|
13
|
+
include RequiredKeywordArguments
|
13
14
|
extend Forwardable
|
14
15
|
|
15
16
|
# NetworkContext stores lights and ties together TransportManager, TagManager and RoutingManager
|
@@ -24,7 +25,7 @@ module LIFX
|
|
24
25
|
else
|
25
26
|
raise ArgumentError.new("Unknown transport method: #{transport}")
|
26
27
|
end
|
27
|
-
@transport_manager.add_observer(self) do |message
|
28
|
+
@transport_manager.add_observer(self) do |message: nil, ip: nil, transport: nil|
|
28
29
|
handle_message(message, ip, transport)
|
29
30
|
end
|
30
31
|
|
@@ -60,7 +61,7 @@ module LIFX
|
|
60
61
|
# @param target: [Target] Target of the message
|
61
62
|
# @param payload: [Protocol::Payload] Message payload
|
62
63
|
# @param acknowledge: [Boolean] If recipients must acknowledge with a response
|
63
|
-
def send_message(target
|
64
|
+
def send_message(target: required!(:target), payload: required!(:payload), acknowledge: false)
|
64
65
|
paths = @routing_manager.resolve_target(target)
|
65
66
|
|
66
67
|
messages = paths.map do |path|
|
@@ -77,9 +78,10 @@ module LIFX
|
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
|
-
|
81
|
+
def within_sync?
|
81
82
|
!!Thread.current[:sync_enabled]
|
82
83
|
end
|
84
|
+
protected :within_sync?
|
83
85
|
|
84
86
|
# Synchronize asynchronous set_color, set_waveform and set_power messages to multiple devices.
|
85
87
|
# You cannot use synchronous methods in the block
|
data/lib/lifx/routing_manager.rb
CHANGED
@@ -6,12 +6,14 @@ module LIFX
|
|
6
6
|
# @private
|
7
7
|
class RoutingManager
|
8
8
|
include Utilities
|
9
|
+
include RequiredKeywordArguments
|
10
|
+
|
9
11
|
# RoutingManager manages a routing table of site <-> device
|
10
12
|
# It can resolve a target to ProtocolPaths and manages the TagTable
|
11
13
|
|
12
14
|
attr_reader :context, :tag_table, :routing_table
|
13
15
|
|
14
|
-
def initialize(context:)
|
16
|
+
def initialize(context: required!(:context))
|
15
17
|
@context = context
|
16
18
|
@routing_table = RoutingTable.new
|
17
19
|
@tag_table = TagTable.new
|
data/lib/lifx/routing_table.rb
CHANGED
@@ -7,7 +7,7 @@ module LIFX
|
|
7
7
|
@device_site_mapping = entries
|
8
8
|
end
|
9
9
|
|
10
|
-
def update_table(site_id
|
10
|
+
def update_table(site_id: site_id, device_id: device_id, tag_ids: nil)
|
11
11
|
device_mapping = @device_site_mapping[device_id] ||= Entry.new(site_id, device_id, [])
|
12
12
|
device_mapping.site_id = site_id
|
13
13
|
device_mapping.last_seen = Time.now
|
data/lib/lifx/site.rb
CHANGED
@@ -10,10 +10,11 @@ module LIFX
|
|
10
10
|
include Timers
|
11
11
|
include Logging
|
12
12
|
include Observable
|
13
|
+
include RequiredKeywordArguments
|
13
14
|
|
14
15
|
attr_reader :id, :gateways, :tag_manager
|
15
16
|
|
16
|
-
def initialize(id:)
|
17
|
+
def initialize(id: required!(:id))
|
17
18
|
@id = id
|
18
19
|
@gateways = {}
|
19
20
|
@gateways_mutex = Mutex.new
|
data/lib/lifx/tag_manager.rb
CHANGED
@@ -8,17 +8,18 @@ module LIFX
|
|
8
8
|
# Stores site <-> [tag_name, tag_id]
|
9
9
|
include Utilities
|
10
10
|
include Logging
|
11
|
+
include RequiredKeywordArguments
|
11
12
|
|
12
13
|
attr_reader :context
|
13
14
|
|
14
15
|
class TagLimitReached < StandardError; end
|
15
16
|
|
16
|
-
def initialize(context
|
17
|
+
def initialize(context: required!(:context), tag_table: required!(:tag_table))
|
17
18
|
@context = context
|
18
19
|
@tag_table = tag_table
|
19
20
|
end
|
20
21
|
|
21
|
-
def create_tag(label
|
22
|
+
def create_tag(label: required!(:label), site_id: required!(:site_id))
|
22
23
|
id = next_unused_id_on_site_id(site_id)
|
23
24
|
raise TagLimitReached if id.nil?
|
24
25
|
# Add the entry for the tag we're about to create to prevent a case where
|
@@ -28,7 +29,7 @@ module LIFX
|
|
28
29
|
payload: Protocol::Device::SetTagLabels.new(tags: id_to_tags_field(id), label: label))
|
29
30
|
end
|
30
31
|
|
31
|
-
def add_tag_to_device(tag
|
32
|
+
def add_tag_to_device(tag: required!(:tag), device: required!(:device))
|
32
33
|
tag_entry = entry_with(label: tag, site_id: device.site_id)
|
33
34
|
if !tag_entry
|
34
35
|
create_tag(label: tag, site_id: device.site_id)
|
@@ -42,7 +43,7 @@ module LIFX
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
def remove_tag_from_device(tag
|
46
|
+
def remove_tag_from_device(tag: required!(:tag), device: required!(:device))
|
46
47
|
tag_entry = entry_with(label: tag, site_id: device.site_id)
|
47
48
|
return if !tag_entry
|
48
49
|
|
data/lib/lifx/tag_table.rb
CHANGED
@@ -24,7 +24,7 @@ module LIFX
|
|
24
24
|
entries_with(**args).first
|
25
25
|
end
|
26
26
|
|
27
|
-
def update_table(tag_id
|
27
|
+
def update_table(tag_id: tag_id, label: label, site_id: site_id)
|
28
28
|
entry = @entries[site_id][tag_id] ||= Entry.new(tag_id, label, site_id)
|
29
29
|
entry.label = label
|
30
30
|
end
|
data/lib/lifx/transport.rb
CHANGED
@@ -71,7 +71,14 @@ module LIFX
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def on_network?
|
74
|
-
Socket.getifaddrs
|
74
|
+
if Socket.respond_to?(:getifaddrs) # Ruby 2.1+
|
75
|
+
Socket.getifaddrs.any? { |ifaddr| ifaddr.broadaddr }
|
76
|
+
else # Ruby 2.0
|
77
|
+
Socket.ip_address_list.any? do |addrinfo|
|
78
|
+
# Not entirely sure how to check if on a LAN with IPv6
|
79
|
+
addrinfo.ipv4_private? || addrinfo.ipv6_unique_local?
|
80
|
+
end
|
81
|
+
end
|
75
82
|
end
|
76
83
|
|
77
84
|
def broadcast(message)
|
@@ -105,7 +112,7 @@ module LIFX
|
|
105
112
|
|
106
113
|
def create_broadcast_transport
|
107
114
|
@transport = Transport::UDP.new(@send_ip, @port)
|
108
|
-
@transport.add_observer(self) do |message
|
115
|
+
@transport.add_observer(self) do |message: nil, ip: nil, transport: nil|
|
109
116
|
handle_broadcast_message(message, ip, @transport)
|
110
117
|
notify_observers(message: message, ip: ip, transport: transport)
|
111
118
|
end
|
@@ -114,7 +121,7 @@ module LIFX
|
|
114
121
|
|
115
122
|
def create_peer_transport
|
116
123
|
@peer_transport = Transport::UDP.new('255.255.255.255', @peer_port)
|
117
|
-
@peer_transport.add_observer(self) do |message
|
124
|
+
@peer_transport.add_observer(self) do |message: nil, ip: nil, transport: nil|
|
118
125
|
notify_observers(message: message, ip: ip, transport: transport)
|
119
126
|
end
|
120
127
|
@peer_transport.listen(ip: @bind_ip)
|
data/lib/lifx/version.rb
CHANGED
data/lifx.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "lifx"
|
8
8
|
spec.version = LIFX::VERSION
|
9
9
|
spec.authors = ["Jack Chen (chendo)"]
|
10
|
-
spec.email = ["chendo@lifx.co"]
|
10
|
+
spec.email = ["chendo+lifx-gem@lifx.co"]
|
11
11
|
spec.description = %q{A Ruby gem that allows easy interaction with LIFX devices.}
|
12
12
|
spec.summary = %q{A Ruby gem that allows easy interaction with LIFX devices. Handles discovery, rate limiting, tags, gateway connections and provides an object-based API for interacting with LIFX devices. }
|
13
13
|
spec.homepage = "https://github.com/LIFX/lifx-gem"
|
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
|
-
spec.required_ruby_version = ">= 2.
|
20
|
+
spec.required_ruby_version = ">= 2.0"
|
21
21
|
|
22
22
|
spec.add_dependency "bindata", "~> 2.0"
|
23
23
|
spec.add_dependency "yell", "~> 2.0"
|
24
|
-
spec.add_dependency "timers", "~>
|
24
|
+
spec.add_dependency "timers", "~> 1.0"
|
25
25
|
spec.add_dependency "configatron", "~> 3.0"
|
26
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
-
spec.add_development_dependency "rake",
|
27
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
28
28
|
spec.add_development_dependency "rspec", "~> 2.14"
|
29
29
|
end
|
@@ -4,18 +4,18 @@ module LIFX
|
|
4
4
|
describe Light, integration: true do
|
5
5
|
describe '#set_power' do
|
6
6
|
it 'sets the power of the light asynchronously' do
|
7
|
-
light.set_power(
|
7
|
+
light.set_power(:off)
|
8
8
|
wait { expect(light).to be_off }
|
9
|
-
light.set_power(
|
9
|
+
light.set_power(:on)
|
10
10
|
wait { expect(light).to be_on }
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#set_power!' do
|
15
15
|
it 'sets the power of the light synchronously' do
|
16
|
-
light.set_power!(
|
16
|
+
light.set_power!(:off)
|
17
17
|
expect(light).to be_off
|
18
|
-
light.set_power!(
|
18
|
+
light.set_power!(:on)
|
19
19
|
expect(light).to be_on
|
20
20
|
end
|
21
21
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler.require
|
3
|
-
|
3
|
+
begin
|
4
|
+
require 'pry'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
4
7
|
|
5
8
|
require 'lifx'
|
6
9
|
require 'lifx/utilities'
|
@@ -24,6 +27,11 @@ shared_context 'integration', integration: true do
|
|
24
27
|
lifx.flush
|
25
28
|
end
|
26
29
|
|
30
|
+
let(:lights) { lifx.lights.with_tag('Test') }
|
31
|
+
let(:light) { lights.first }
|
32
|
+
end
|
33
|
+
|
34
|
+
module SpecHelpers
|
27
35
|
def wait(timeout: 5, retry_wait: 0.1, &block)
|
28
36
|
Timeout.timeout(timeout) do
|
29
37
|
begin
|
@@ -36,14 +44,12 @@ shared_context 'integration', integration: true do
|
|
36
44
|
rescue Timeout::Error
|
37
45
|
block.call
|
38
46
|
end
|
39
|
-
|
40
|
-
let(:lights) { lifx.lights.with_tag('Test') }
|
41
|
-
let(:light) { lights.first }
|
42
47
|
end
|
43
48
|
|
44
49
|
LIFX::Config.logger = Yell.new(STDERR) if ENV['DEBUG']
|
45
50
|
|
46
51
|
RSpec.configure do |config|
|
52
|
+
config.include(SpecHelpers)
|
47
53
|
config.formatter = 'documentation'
|
48
54
|
config.color = true
|
49
55
|
end
|
data/spec/transport/udp_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe LIFX::Transport::UDP do
|
3
|
+
describe LIFX::Transport::UDP, integration: true do
|
4
4
|
subject(:udp) { LIFX::Transport::UDP.new(host, port) }
|
5
5
|
|
6
6
|
let(:host) { 'localhost' }
|
@@ -24,7 +24,7 @@ describe LIFX::Transport::UDP do
|
|
24
24
|
|
25
25
|
it 'listens to the specified socket data, unpacks it and notifies observers' do
|
26
26
|
messages = []
|
27
|
-
udp.add_observer(self) do |message
|
27
|
+
udp.add_observer(self) do |message: nil, ip: nil, transport: nil|
|
28
28
|
messages << message
|
29
29
|
end
|
30
30
|
udp.listen
|
@@ -33,8 +33,7 @@ describe LIFX::Transport::UDP do
|
|
33
33
|
.with(raw_message)
|
34
34
|
.and_return(message)
|
35
35
|
socket.send(raw_message, 0, host, port)
|
36
|
-
|
37
|
-
expect(messages).to include(message)
|
36
|
+
wait { expect(messages).to include(message) }
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
metadata
CHANGED
@@ -1,123 +1,124 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lifx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Chen (chendo)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
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: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yell
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.0'
|
34
34
|
type: :runtime
|
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: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: timers
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: configatron
|
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: :runtime
|
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
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '10.1'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '10.1'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '2.14'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.14'
|
111
111
|
description: A Ruby gem that allows easy interaction with LIFX devices.
|
112
112
|
email:
|
113
|
-
- chendo@lifx.co
|
113
|
+
- chendo+lifx-gem@lifx.co
|
114
114
|
executables:
|
115
115
|
- lifx-snoop
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
-
-
|
120
|
-
-
|
119
|
+
- .gitignore
|
120
|
+
- .travis.yml
|
121
|
+
- .yardopts
|
121
122
|
- CHANGES.md
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.txt
|
@@ -157,6 +158,7 @@ files:
|
|
157
158
|
- lib/lifx/protocol/wan.rb
|
158
159
|
- lib/lifx/protocol/wifi.rb
|
159
160
|
- lib/lifx/protocol_path.rb
|
161
|
+
- lib/lifx/required_keyword_arguments.rb
|
160
162
|
- lib/lifx/routing_manager.rb
|
161
163
|
- lib/lifx/routing_table.rb
|
162
164
|
- lib/lifx/seen.rb
|
@@ -195,17 +197,17 @@ require_paths:
|
|
195
197
|
- lib
|
196
198
|
required_ruby_version: !ruby/object:Gem::Requirement
|
197
199
|
requirements:
|
198
|
-
- -
|
200
|
+
- - '>='
|
199
201
|
- !ruby/object:Gem::Version
|
200
|
-
version: '2.
|
202
|
+
version: '2.0'
|
201
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
204
|
requirements:
|
203
|
-
- -
|
205
|
+
- - '>='
|
204
206
|
- !ruby/object:Gem::Version
|
205
207
|
version: '0'
|
206
208
|
requirements: []
|
207
209
|
rubyforge_project:
|
208
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.0.3
|
209
211
|
signing_key:
|
210
212
|
specification_version: 4
|
211
213
|
summary: A Ruby gem that allows easy interaction with LIFX devices. Handles discovery,
|