hueshift 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hueshift +17 -2
- data/hueshift.gemspec +2 -1
- data/lib/hueshift.rb +1 -0
- data/lib/hueshift/server.rb +36 -0
- data/lib/hueshift/user_settings.rb +8 -3
- data/lib/hueshift/version.rb +1 -1
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ab7b3bd2f06c8c25f8f77194a05a6e24719c2bc
|
4
|
+
data.tar.gz: c2a14f439563fac888dff3ca6324c2d20c156708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c47265ae42b37a9f1a0c35b30d3d22c0d6b6faaa4b953812940b0d6b2b28a20e766fb6da04f9c6d052f66fd195557bb24671925d574b5b91b352f350fca7fbb5
|
7
|
+
data.tar.gz: d48c3236243ff1ebadfa12eeefbd971c18fcf78fdd8c93d1e3fdadfd0db80aead42219aa25af40efe9cf220bedbc6f6f7704daeff309170a31ff38239c99fb20
|
data/bin/hueshift
CHANGED
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
require_relative "../lib/hueshift"
|
4
4
|
require "slop"
|
5
|
+
require "filewatcher"
|
5
6
|
|
6
7
|
include Hueshift
|
7
8
|
|
8
|
-
load_user_settings
|
9
|
+
is_user_settings_file = load_user_settings
|
9
10
|
|
10
11
|
opts = Slop.parse do |o|
|
11
12
|
o.on "-s", "--server", "continually update color temperature" do
|
@@ -16,7 +17,21 @@ opts = Slop.parse do |o|
|
|
16
17
|
exit
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
+
server = Server.new
|
21
|
+
|
22
|
+
if is_user_settings_file
|
23
|
+
server.start
|
24
|
+
filewatcher = FileWatcher.new USER_SETTINGS_PATH
|
25
|
+
fw_thread = Thread.new(filewatcher) do |fw|
|
26
|
+
fw.watch do |file|
|
27
|
+
puts "Detected change to #{file}. Restarting with updated settings."
|
28
|
+
load_user_settings
|
29
|
+
server.restart
|
30
|
+
end
|
31
|
+
end.join
|
32
|
+
else
|
33
|
+
server.start.join
|
34
|
+
end
|
20
35
|
end
|
21
36
|
o.on "-v", "--version", "print the version" do
|
22
37
|
puts Hueshift::VERSION
|
data/hueshift.gemspec
CHANGED
data/lib/hueshift.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Hueshift
|
2
|
+
class Server
|
3
|
+
DEFAULT_POLLING_INTERVAL = 30 # seconds
|
4
|
+
|
5
|
+
def start
|
6
|
+
polling_interval = (ENV.fetch "POLLING_INTERVAL", DEFAULT_POLLING_INTERVAL).to_i
|
7
|
+
@thread = Thread.new do
|
8
|
+
loop do
|
9
|
+
redshift_safe
|
10
|
+
sleep polling_interval
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def stop
|
16
|
+
@thread.exit
|
17
|
+
end
|
18
|
+
|
19
|
+
def restart
|
20
|
+
stop
|
21
|
+
start
|
22
|
+
end
|
23
|
+
|
24
|
+
private ####################################################################
|
25
|
+
|
26
|
+
def redshift_safe
|
27
|
+
begin
|
28
|
+
redshift
|
29
|
+
rescue Exception => e
|
30
|
+
puts "#{Time.now}: Received #{e.class}: #{e.message}"
|
31
|
+
e.backtrace.each { |line| puts "\t#{line}" }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module Hueshift
|
2
2
|
USER_SETTINGS_FILE = ".hueshift"
|
3
|
+
USER_SETTINGS_PATH = File.expand_path USER_SETTINGS_FILE, Dir.home
|
3
4
|
|
5
|
+
##
|
6
|
+
# Load the settings in USER_SETTINGS_PATH, if it exists.
|
7
|
+
#
|
8
|
+
# @return whether USER_SETTINGS_PATH exists
|
4
9
|
def load_user_settings
|
5
|
-
|
6
|
-
if File.exist? settings_file
|
10
|
+
if (exists = File.exist? USER_SETTINGS_PATH)
|
7
11
|
require "dotenv"
|
8
|
-
Dotenv.
|
12
|
+
Dotenv.overload USER_SETTINGS_PATH
|
9
13
|
end
|
14
|
+
exists
|
10
15
|
end
|
11
16
|
end
|
data/lib/hueshift/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hueshift
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Toniazzo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.0
|
89
|
+
version: '2.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.0
|
96
|
+
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: filewatcher
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.5'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.5'
|
97
111
|
description:
|
98
112
|
email:
|
99
113
|
- jutonz42@gmail.com
|
@@ -114,6 +128,7 @@ files:
|
|
114
128
|
- bin/setup
|
115
129
|
- hueshift.gemspec
|
116
130
|
- lib/hueshift.rb
|
131
|
+
- lib/hueshift/server.rb
|
117
132
|
- lib/hueshift/user_settings.rb
|
118
133
|
- lib/hueshift/version.rb
|
119
134
|
homepage: http://www.github.com/jutonz/hueshift
|