lifx 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,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 357ce53a9c5e511833c6917f09d72396d203df38
4
- data.tar.gz: 135ecdc739e64aaf4615702eedb273f9c3cb570e
3
+ metadata.gz: e976d2a6d1ab56351ef47fbae89e84a1c08c98ed
4
+ data.tar.gz: 2f8d52787abf6aee8dd809e3f61ac2395c0c8225
5
5
  SHA512:
6
- metadata.gz: 7d2ad759de8697cf02de2914782742315be5c545678bae5b848e9dfeb13acc945823b78a1145f82df308e2dec308c31ec01aae6601c67262632cf64f36f56867
7
- data.tar.gz: 212a318bab27a3f967971364e8384daa82842334a3b8f9327de66c12e3e01309b9b2d015f9c650dea8e0e91ea1cbf63a7ed3b2e722fc47186889b21f908506a4
6
+ metadata.gz: 49dd808c6baabd1d07a15e355e6367a272af8ef40c2469b3db1475a648e52ae5a4ef59c17395903825ac4ca42ee247e07c126bddda40804d0c0201d6592200ba
7
+ data.tar.gz: 2123ea65a1c2f246ab93c0c81532bc774de9669540bb312c7e3ec0a71b34e67dd6bca51b9faeb8fb3cd97575b4b2651248b691628fbac9cd6d716e69333d28d4
data/.yardopts CHANGED
@@ -1 +1,3 @@
1
1
  --markup markdown
2
+ --no-private
3
+ --query "@api.text != 'private'"
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 LIFX Labs
1
+ Copyright (c) 2012-2014 LIFX Labs
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -19,7 +19,7 @@ This gem is in an early beta state. Expect breaking API changes.
19
19
  Add this line to your application's Gemfile:
20
20
 
21
21
  ```ruby
22
- gem 'lifx', git: "git@github.com:LIFX/lifx-gem.git"
22
+ gem 'lifx'
23
23
  ```
24
24
 
25
25
  And then execute:
@@ -28,6 +28,12 @@ And then execute:
28
28
  $ bundle
29
29
  ```
30
30
 
31
+ Or install the gem with:
32
+
33
+ ```shell
34
+ gem install lifx
35
+ ```
36
+
31
37
  ## Usage
32
38
 
33
39
  ```ruby
@@ -1,3 +1,4 @@
1
+ # @private
1
2
  module BinData
2
3
  class Bool < Primitive
3
4
  uint8 :_value
data/lib/lifx/firmware.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module LIFX
2
2
  # LIFX::Firmware handles decoding firmware payloads
3
+ # @private
3
4
  class Firmware < Struct.new(:build_time, :major, :minor)
4
5
  include Comparable
5
6
 
@@ -3,6 +3,7 @@ require 'lifx/timers'
3
3
 
4
4
  module LIFX
5
5
  # @api private
6
+ # @private
6
7
  class GatewayConnection
7
8
  # GatewayConnection handles the UDP and TCP connections to the gateway
8
9
  # A GatewayConnection is created when a new device sends a StatePanGateway
data/lib/lifx/light.rb CHANGED
@@ -51,6 +51,7 @@ module LIFX
51
51
  # Adds a block to be run when a payload of class `payload_class` is received
52
52
  # @param payload_class [Class] Payload type to execute block on
53
53
  # @param &hook [Proc] Hook to run
54
+ # @api private
54
55
  # @return [void]
55
56
  def add_hook(payload_class, hook_arg = nil, &hook_block)
56
57
  hook = block_given? ? hook_block : hook_arg
@@ -63,6 +64,7 @@ module LIFX
63
64
  # Removes a hook added by {#add_hook}
64
65
  # @param payload_class [Class] Payload type to delete hook from
65
66
  # @param hook [Proc] The original hook passed into {#add_hook}
67
+ # @api private
66
68
  # @return [void]
67
69
  def remove_hook(payload_class, hook)
68
70
  @message_hooks[payload_class].delete(hook)
@@ -132,14 +134,16 @@ module LIFX
132
134
  set_power!(0)
133
135
  end
134
136
 
137
+ # @see #power
135
138
  # @return [Boolean] Returns true if device is on
136
- def on?(**kwargs)
137
- power(**kwargs) == :on
139
+ def on?(refresh: false, fetch: true)
140
+ power(refresh: refresh, fetch: fetch) == :on
138
141
  end
139
142
 
143
+ # @see #power
140
144
  # @return [Boolean] Returns true if device is off
141
- def off?(**kwargs)
142
- power(**kwargs) == :off
145
+ def off?(refresh: false, fetch: true)
146
+ power(refresh: refresh, fetch: fetch) == :off
143
147
  end
144
148
 
145
149
  # @param refresh: see #label
@@ -322,6 +326,7 @@ module LIFX
322
326
  end
323
327
 
324
328
  # Returns a nice string representation of the Light
329
+ # @return [String]
325
330
  def to_s
326
331
  %Q{#<LIFX::Light id=#{id} label=#{label(fetch: false)} power=#{power(fetch: false)}>}.force_encoding(Encoding.default_external)
327
332
  end
@@ -83,12 +83,14 @@ module LIFX
83
83
  DEFAULT_ALIVE_THRESHOLD = 30 # seconds
84
84
  # Returns an Array of {Light}s considered alive
85
85
  # @param threshold: The maximum number of seconds a {Light} was last seen to be considered alive
86
+ # @return [Array<Light>] Lights considered alive
86
87
  def alive(threshold: DEFAULT_ALIVE_THRESHOLD)
87
88
  lights.select { |l| l.seconds_since_seen <= threshold }
88
89
  end
89
90
 
90
91
  # Returns an Array of {Light}s considered stale
91
92
  # @param threshold: The minimum number of seconds since a {Light} was last seen to be considered stale
93
+ # @return [Array<Light>] Lights considered stale
92
94
  def stale(threshold: DEFAULT_ALIVE_THRESHOLD)
93
95
  lights.select { |l| l.seconds_since_seen > threshold }
94
96
  end
data/lib/lifx/logging.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module LIFX
2
+ # @private
2
3
  module Logging
3
4
  def self.included(mod)
4
5
  mod.extend(self)
@@ -8,4 +9,4 @@ module LIFX
8
9
  LIFX::Config.logger
9
10
  end
10
11
  end
11
- end
12
+ end
data/lib/lifx/message.rb CHANGED
@@ -3,7 +3,6 @@ require 'lifx/protocol_path'
3
3
 
4
4
  module LIFX
5
5
  # @api private
6
-
7
6
  class Message
8
7
  include Logging
9
8
  extend Forwardable
@@ -151,6 +151,11 @@ module LIFX
151
151
  transport_manager.gateways.map(&:values).flatten
152
152
  end
153
153
 
154
+ def to_s
155
+ %Q{#<LIFX::NetworkContext connections=#{gateway_connections}>}
156
+ end
157
+ alias_method :inspect, :to_s
158
+
154
159
  protected
155
160
 
156
161
  def handle_message(message, ip, transport)
@@ -1,4 +1,5 @@
1
1
  module LIFX
2
+ # @private
2
3
  module Observable
3
4
  class ObserverCallbackMismatch < ArgumentError; end
4
5
  def add_observer(obj, &callback)
@@ -1,6 +1,6 @@
1
- # Generated code ahoy!
2
1
  module LIFX
3
2
  module Protocol
3
+ # @api private
4
4
  module Device
5
5
  module Service
6
6
  UDP = 1
@@ -1,6 +1,6 @@
1
- # Generated code ahoy!
2
1
  module LIFX
3
2
  module Protocol
3
+ # @api private
4
4
  module Light
5
5
  module Waveform
6
6
  SAW = 0
@@ -1,6 +1,6 @@
1
1
  module LIFX
2
+ # @api private
2
3
  module Protocol
3
- # @api private
4
4
  class Payload < BinData::Record
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
- # Generated code ahoy!
2
1
  module LIFX
3
2
  module Protocol
3
+ # @api private
4
4
  module Sensor
5
5
  class GetAmbientLight < Payload
6
6
  endian :little
@@ -1,6 +1,6 @@
1
- # Generated code ahoy!
2
1
  module LIFX
3
2
  module Protocol
3
+ # @api private
4
4
  module Wan
5
5
  class ConnectPlain < Payload
6
6
  endian :little
@@ -1,6 +1,6 @@
1
- # Generated code ahoy!
2
1
  module LIFX
3
2
  module Protocol
3
+ # @api private
4
4
  module Wifi
5
5
  module Interface
6
6
  SOFT_AP = 1
@@ -1,6 +1,7 @@
1
1
  require 'lifx/utilities'
2
2
 
3
3
  module LIFX
4
+ # @private
4
5
  class ProtocolPath
5
6
  # ProtocolPath contains all the addressable information that is required
6
7
  # for the protocol.
@@ -3,6 +3,7 @@ require 'lifx/tag_table'
3
3
  require 'lifx/utilities'
4
4
 
5
5
  module LIFX
6
+ # @private
6
7
  class RoutingManager
7
8
  include Utilities
8
9
  # RoutingManager manages a routing table of site <-> device
@@ -1,4 +1,5 @@
1
1
  module LIFX
2
+ # @private
2
3
  class RoutingTable
3
4
  class Entry < Struct.new(:site_id, :device_id, :tag_ids, :last_seen); end
4
5
  # RoutingTable stores the device <-> site mapping
data/lib/lifx/seen.rb CHANGED
@@ -1,13 +1,21 @@
1
1
  module LIFX
2
2
  module Seen
3
+ # Returns the time when the device was last seen.
4
+ # @return [Time]
3
5
  def last_seen
4
6
  @last_seen
5
7
  end
6
8
 
9
+ # Returns the number of seconds since the device was last seen.
10
+ # If the device hasn't been seen yet, it will use Unix epoch as
11
+ # the time it was seen.
12
+ # @return [Float]
7
13
  def seconds_since_seen
8
14
  Time.now - (last_seen || Time.at(0))
9
15
  end
10
16
 
17
+ # Marks the device as being seen.
18
+ # @private
11
19
  def seen!
12
20
  @last_seen = Time.now
13
21
  end
@@ -1,5 +1,6 @@
1
1
  module LIFX
2
2
  # @api private
3
+ # @private
3
4
  class TagManager
4
5
  # TagManager handles discovery of tags, resolving tags to [site_id, tags_field] pairs,
5
6
  # creating, setting and removing tags.
data/lib/lifx/target.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  module LIFX
2
+ # Target is a high-level abstraction for the target of a Message
2
3
  # @api private
3
-
4
4
  class Target
5
- # Target is a high-level abstraction for the target of a Message
6
5
 
7
6
  attr_reader :site_id, :device_id, :tag, :broadcast
8
7
  def initialize(device_id: nil, site_id: nil, tag: nil, broadcast: nil)
data/lib/lifx/timers.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'timers'
2
2
  module LIFX
3
+ # @private
3
4
  module Timers
4
5
  protected
5
6
  def initialize_timer_thread
@@ -3,6 +3,7 @@ require 'socket'
3
3
  module LIFX
4
4
  class Transport
5
5
  # @api private
6
+ # @private
6
7
  class TCP < Transport
7
8
  include Logging
8
9
 
@@ -2,6 +2,7 @@ require 'socket'
2
2
  module LIFX
3
3
  class Transport
4
4
  # @api private
5
+ # @private
5
6
  class UDP < Transport
6
7
  def initialize(*args)
7
8
  super
@@ -1,4 +1,5 @@
1
1
  module LIFX
2
+ # @private
2
3
  module Utilities
3
4
  def try_until(condition_proc, timeout_exception: Timeout::Error,
4
5
  timeout: 3,
data/lib/lifx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LIFX
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -4,15 +4,15 @@ module LIFX
4
4
  describe Client, integration: true do
5
5
  describe '#sync' do
6
6
  it 'schedules sending all messages to be executed at the same time' do
7
+ if lights.count < 3
8
+ pending "This test requires 3 or more lights tagged under Test"
9
+ return
10
+ end
7
11
 
8
12
  lifx.discover! do
9
13
  lights.count >= 3
10
14
  end
11
15
 
12
- if lights.count < 3
13
- fail "This test requires 3 or more lights tagged under Test"
14
- end
15
-
16
16
  white = LIFX::Color.white(brightness: 0.5)
17
17
  lights.set_color(white, duration: 0)
18
18
  sleep 1
@@ -37,4 +37,4 @@ module LIFX
37
37
  end
38
38
  end
39
39
  end
40
- end
40
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lifx
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
  - Jack Chen (chendo)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-23 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata