hue-cli 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b5cd07631bec145ebd9eb5f2f81ded743ee26f13
4
+ data.tar.gz: 76ffd9f8f9fc3466b3b9126a527a1a45d8abdd1c
5
+ SHA512:
6
+ metadata.gz: 43516b2457214e1300e43f24840fb68f3b352c32aa62a81ad6d72c6c097678a83c15a1051a1d4d93bc5b06762e649e4c30a8f1785f35cf402f7c239260f6955e
7
+ data.tar.gz: e9370c0d8846ee6eb343aa8353a45da5341c0d075ba8389f9ec5a591f23bb477120952de609ed986e5f550afb945dec1bb0f953896579af2b3d5db97e4721afd
data/.gitignore CHANGED
@@ -13,6 +13,7 @@ spec/reports
13
13
  test/tmp
14
14
  test/version_tmp
15
15
  tmp
16
+ .*.swp
16
17
 
17
18
  # YARD artifacts
18
19
  .yardoc
data/TODO.md ADDED
@@ -0,0 +1,11 @@
1
+ # TODOs
2
+
3
+ * Bridges command to handle registration, deleting, switching between multiple bridges.
4
+ * Smarter switching (check local network, look for a match, or default to the match).
5
+ * Pattern matcher / Processor for shorthands (hue register, hue 1 etc...)
6
+ * Multi action command processor (hue 1 --color 6500 --brightness 50 --on)
7
+ * Delete applications.
8
+ * Print unreachable state.
9
+ * Add localhost to registered application hash (hue-cli@localhost).
10
+ * Groups
11
+ * Schedules
data/bin/hue CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "#{File.dirname(__FILE__)}/../lib/hue/cli"
3
+ require "#{File.dirname(__FILE__)}/../lib/hue/cli.rb"
4
4
 
5
5
  Hue::CLI.run(ARGV)
data/hue-cli.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "hue-cli"
6
- s.version = '0.1.2'
6
+ s.version = '0.1.3'
7
7
  s.authors = ["Birkir A. Barkarson", ""]
8
8
  s.email = ["birkirb@stoicviking.net"]
9
9
  s.homepage = "https://github.com/birkirb/hue-lib"
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_runtime_dependency("json")
21
- s.add_runtime_dependency("hue-lib", '>= 0.7.2')
21
+ s.add_runtime_dependency("hue-lib", '>= 0.7.3')
22
22
  s.add_development_dependency("rspec", '>= 2.6.0')
23
23
  s.add_development_dependency("mocha", '>= 0.9.0')
24
24
  s.add_development_dependency("webmock", '>= 1.8.0')
data/lib/hue/cli.rb CHANGED
@@ -15,6 +15,7 @@ module Hue
15
15
  class Error < StandardError; end;
16
16
 
17
17
  ERROR_BRIDGE_CONNECTION_PROBLEM = /execution expired|No route to host/
18
+ @@retry_count = 0
18
19
 
19
20
  def self.bridge
20
21
  Hue.application
@@ -37,9 +38,15 @@ module Hue
37
38
  end
38
39
  rescue Hue::Error => err
39
40
  if ERROR_BRIDGE_CONNECTION_PROBLEM.match(err.message)
41
+ @@retry_count += 1
40
42
  Hue.logger.warn("Error contacting bridge, verifying IP and trying again.")
41
43
  Hue.register_bridges
42
- retry
44
+ if @@retry_count > 2
45
+ puts "Giving up contacting bridge after #{@@retry_count} retries."
46
+ bridge.print_config
47
+ else
48
+ retry
49
+ end
43
50
  else
44
51
  puts err.message
45
52
  end
@@ -2,6 +2,14 @@ module Hue
2
2
  class Bridge
3
3
  include Indentation
4
4
 
5
+ def print_config
6
+ puts "Config:"
7
+ indent do
8
+ puts "Application id: #{application_id}"
9
+ puts "Bridge URI: #{bridge_uri}"
10
+ end
11
+ end
12
+
5
13
  def print_state
6
14
  state = self.status
7
15
  config = state['config']
@@ -9,21 +17,29 @@ module Hue
9
17
  puts "Button pressed: #{config['linkbutton']}"
10
18
  puts "Timestamp: #{config['UTC']}"
11
19
  puts "Network configuration:"
12
- puts " IP: #{config['ipaddress']}"
13
- puts " Gateway: #{config['gateway']}"
14
- puts " Mask: #{config['netmask']}"
15
- puts " DHCP: #{config['dhcp']}"
16
- puts " MAC: #{config['mac']}"
17
- if !config['proxyaddress'].strip.empty?
18
- puts " Proxy: #{config['proxyaddress']}:#{config['proxyport']}"
20
+ indent do
21
+ puts "IP: #{config['ipaddress']}"
22
+ puts "Gateway: #{config['gateway']}"
23
+ puts "Mask: #{config['netmask']}"
24
+ puts "DHCP: #{config['dhcp']}"
25
+ puts "MAC: #{config['mac']}"
26
+ if !config['proxyaddress'].strip.empty?
27
+ puts "Proxy: #{config['proxyaddress']}:#{config['proxyport']}"
28
+ end
19
29
  end
30
+
20
31
  puts "Applications:"
21
- config['whitelist'].each do |key, values|
22
- puts " #{key} : #{values['name']}"
32
+ indent do
33
+ config['whitelist'].each do |key, values|
34
+ puts "#{key} : #{values['name']}"
35
+ end
23
36
  end
37
+
24
38
  puts "Lights:"
25
- state['lights'].each do |key, values|
26
- puts " #{key}. #{values['name']} - #{values['state']['on'] ? 'ON' : 'OFF'}"
39
+ indent do
40
+ state['lights'].each do |key, values|
41
+ puts " #{key}. #{values['name']} - #{values['state']['on'] ? 'ON' : 'OFF'}"
42
+ end
27
43
  end
28
44
  end
29
45
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hue-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Birkir A. Barkarson
@@ -10,86 +9,76 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-11-03 00:00:00.000000000 Z
12
+ date: 2015-08-03 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: json
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: hue-lib
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
- version: 0.7.2
34
+ version: 0.7.3
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
- version: 0.7.2
41
+ version: 0.7.3
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: 2.6.0
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: 2.6.0
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: mocha
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: 0.9.0
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: 0.9.0
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: webmock
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - '>='
85
75
  - !ruby/object:Gem::Version
86
76
  version: 1.8.0
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - '>='
93
82
  - !ruby/object:Gem::Version
94
83
  version: 1.8.0
95
84
  description: CLI that allows simple printing of bridge and light state, with easy-to-use
@@ -105,6 +94,7 @@ files:
105
94
  - Gemfile
106
95
  - README.md
107
96
  - Rakefile
97
+ - TODO.md
108
98
  - bin/hue
109
99
  - config/light_alias.yml
110
100
  - hue-cli.gemspec
@@ -120,26 +110,25 @@ files:
120
110
  - lib/utilities/indentation.rb
121
111
  homepage: https://github.com/birkirb/hue-lib
122
112
  licenses: []
113
+ metadata: {}
123
114
  post_install_message:
124
115
  rdoc_options: []
125
116
  require_paths:
126
117
  - lib
127
118
  required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
119
  requirements:
130
- - - ! '>='
120
+ - - '>='
131
121
  - !ruby/object:Gem::Version
132
122
  version: '0'
133
123
  required_rubygems_version: !ruby/object:Gem::Requirement
134
- none: false
135
124
  requirements:
136
- - - ! '>='
125
+ - - '>='
137
126
  - !ruby/object:Gem::Version
138
127
  version: '0'
139
128
  requirements: []
140
129
  rubyforge_project: hue-cli
141
- rubygems_version: 1.8.23
130
+ rubygems_version: 2.0.3
142
131
  signing_key:
143
- specification_version: 3
132
+ specification_version: 4
144
133
  summary: Command line interface for controlling Philips Hue system's lights and bridge.
145
134
  test_files: []