irkit 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/bin/irkit +23 -14
- data/lib/irkit/device.rb +4 -0
- data/lib/irkit/internet_api.rb +4 -0
- data/lib/irkit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ce7272c56532c32aaedd21f2a3610563191485f
|
4
|
+
data.tar.gz: acebb9b4fd74740a49ff54221a5e7f092611bedb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81f9a6d9bd0061a0205582f88e32d1dfb0dd05b3f07488fac8b869746148f5657b9c78c2b4ca9eacdea2dc0a30276ca5dbde7567d2c57b0143643ebcf9d31bbb
|
7
|
+
data.tar.gz: 7f4e86403ea1f8752885ebd3c2a8237ecee1c399ad5ebd353823e86bc2ef64e69f2ef72cf8ab6fb2a8766fab50e34d746ad420e699f2637ed476f0d27d9790ea
|
data/History.txt
CHANGED
data/bin/irkit
CHANGED
@@ -9,6 +9,7 @@ args = ArgsParser.parse ARGV do
|
|
9
9
|
arg :get, "get IR Data", :alias => :read
|
10
10
|
arg :post, "post IR Data", :alias => :write
|
11
11
|
arg :delete, "delete IR Data"
|
12
|
+
arg :show, "print IR Data"
|
12
13
|
arg :list, "show list of IR Data and Devices"
|
13
14
|
arg :address, "IRKit IP Address"
|
14
15
|
arg :device, "use Internet API"
|
@@ -28,7 +29,7 @@ if args.has_option? :help or
|
|
28
29
|
(!args.has_param?(:get) and !args.has_param?(:post) and
|
29
30
|
!args.has_option?(:list) and !args.has_param?(:delete) and
|
30
31
|
!args.has_param?(:device) and !args.has_param?("device:add") and
|
31
|
-
!args.has_param?("device:delete"))
|
32
|
+
!args.has_param?("device:delete") and !args.has_param?(:show))
|
32
33
|
STDERR.puts "IRKit v#{IRKit::VERSION}"
|
33
34
|
STDERR.puts " https://github.com/shokai/ruby-irkit"
|
34
35
|
STDERR.puts
|
@@ -38,6 +39,7 @@ if args.has_option? :help or
|
|
38
39
|
STDERR.puts " % #{binname} --get tv_on"
|
39
40
|
STDERR.puts " % #{binname} --post tv_on"
|
40
41
|
STDERR.puts " % #{binname} --post tv_on --address 192.168.0.123"
|
42
|
+
STDERR.puts " % #{binname} --show tv_on"
|
41
43
|
STDERR.puts " % #{binname} --delete tv_on"
|
42
44
|
STDERR.puts " % #{binname} --device:add myhouse"
|
43
45
|
STDERR.puts " % #{binname} --post tv_on --device myhouse"
|
@@ -48,11 +50,11 @@ end
|
|
48
50
|
if args.has_option? :list
|
49
51
|
puts "~> #{IRKit::App::DATA_FILE}"
|
50
52
|
puts "== Data"
|
51
|
-
IRKit::App::Data
|
53
|
+
IRKit::App::Data["IR"].each do |k,v|
|
52
54
|
puts k
|
53
55
|
end
|
54
56
|
puts "== Devices"
|
55
|
-
IRKit::App::Data
|
57
|
+
IRKit::App::Data["Device"].each do |k,v|
|
56
58
|
puts "#{k}\tInternet API"
|
57
59
|
end
|
58
60
|
IRKit::Device.find.each do |device|
|
@@ -61,11 +63,17 @@ if args.has_option? :list
|
|
61
63
|
exit
|
62
64
|
end
|
63
65
|
|
66
|
+
if args.has_param? :show
|
67
|
+
name = args[:show]
|
68
|
+
puts IRKit::App::Data["IR"][name].to_json
|
69
|
+
exit
|
70
|
+
end
|
71
|
+
|
64
72
|
if args.has_param? :delete
|
65
73
|
name = args[:delete]
|
66
74
|
print %Q{delete IR-Data "#{name}"? [Y/n] > }
|
67
75
|
exit 1 if STDIN.gets.strip.downcase =~ /n/
|
68
|
-
IRKit::App::Data
|
76
|
+
IRKit::App::Data["IR"].delete name
|
69
77
|
IRKit::App::Data.save
|
70
78
|
puts %Q{"#{name}" delete!}
|
71
79
|
exit
|
@@ -75,7 +83,7 @@ if args.has_param? "device:delete"
|
|
75
83
|
name = args["device:delete"]
|
76
84
|
print %Q{delete Device "#{name}"? [Y/n] > }
|
77
85
|
exit 1 if STDIN.gets.strip.downcase =~ /n/
|
78
|
-
IRKit::App::Data
|
86
|
+
IRKit::App::Data["Device"].delete name
|
79
87
|
IRKit::App::Data.save
|
80
88
|
puts %Q{"#{name}" delete!}
|
81
89
|
exit
|
@@ -84,12 +92,13 @@ end
|
|
84
92
|
if args.has_param? :address
|
85
93
|
irkit = IRKit::Device.new(address: args[:address])
|
86
94
|
elsif args.has_param? :device
|
87
|
-
unless info = IRKit::App::Data
|
95
|
+
unless info = IRKit::App::Data["Device"][ args[:device] ]
|
88
96
|
STDERR.puts %Q{Device "#{args[:device]}" not found}
|
89
97
|
exit 1
|
90
98
|
end
|
91
99
|
irkit = IRKit::InternetAPI.new(clientkey: info.clientkey, deviceid: info.deviceid)
|
92
100
|
else
|
101
|
+
puts "finding IRKit with bonjour..."
|
93
102
|
irkit = IRKit::Device.find.first
|
94
103
|
end
|
95
104
|
|
@@ -98,11 +107,11 @@ unless irkit
|
|
98
107
|
exit 1
|
99
108
|
end
|
100
109
|
|
101
|
-
|
110
|
+
puts "using #{irkit}"
|
102
111
|
|
103
112
|
if args.has_param? :get
|
104
113
|
name = args[:get]
|
105
|
-
if IRKit::App::Data
|
114
|
+
if IRKit::App::Data["IR"].has_key? name
|
106
115
|
print %Q{overwrite "#{name}"? [Y/n] > }
|
107
116
|
exit 1 if STDIN.gets.strip.downcase =~ /n/
|
108
117
|
end
|
@@ -116,7 +125,7 @@ if args.has_param? :get
|
|
116
125
|
ir_data = res
|
117
126
|
end
|
118
127
|
puts ir_data.to_json
|
119
|
-
IRKit::App::Data
|
128
|
+
IRKit::App::Data["IR"][name] = ir_data
|
120
129
|
IRKit::App::Data.save
|
121
130
|
puts %Q{"#{name}" saved!}
|
122
131
|
exit
|
@@ -125,7 +134,7 @@ end
|
|
125
134
|
if args.has_param? :post
|
126
135
|
name = args[:post]
|
127
136
|
puts %Q{post "#{name}"}
|
128
|
-
unless ir_data = IRKit::App::Data
|
137
|
+
unless ir_data = IRKit::App::Data["IR"][name]
|
129
138
|
STDERR.puts %Q{IR Data "#{name}" not found}
|
130
139
|
exit 1
|
131
140
|
end
|
@@ -140,7 +149,7 @@ end
|
|
140
149
|
|
141
150
|
if args.has_param? "device:add"
|
142
151
|
name = args["device:add"]
|
143
|
-
if IRKit::App::Data
|
152
|
+
if IRKit::App::Data["Device"].has_key? name
|
144
153
|
print %Q{overwrite "#{name}"? [Y/n] > }
|
145
154
|
exit 1 if STDIN.gets.strip.downcase =~ /n/
|
146
155
|
end
|
@@ -148,9 +157,9 @@ if args.has_param? "device:add"
|
|
148
157
|
puts "token:\t#{token}"
|
149
158
|
res = irkit.get_key_and_deviceid(token)
|
150
159
|
|
151
|
-
puts "clientkey:\t#{res.clientkey}"
|
152
|
-
puts "deviceid:\t#{res.deviceid}"
|
153
|
-
IRKit::App::Data
|
160
|
+
puts "clientkey:\t#{res.clientkey[0..6]}XXXXXX"
|
161
|
+
puts "deviceid:\t#{res.deviceid[0..6]}XXXXXX"
|
162
|
+
IRKit::App::Data["Device"][name] = res
|
154
163
|
IRKit::App::Data.save
|
155
164
|
puts %Q{"#{name}" saved!}
|
156
165
|
exit
|
data/lib/irkit/device.rb
CHANGED
data/lib/irkit/internet_api.rb
CHANGED
@@ -15,6 +15,10 @@ module IRKit
|
|
15
15
|
"https://api.getirkit.com/1"
|
16
16
|
end
|
17
17
|
|
18
|
+
def to_s
|
19
|
+
%Q{#<#{self.class} @deviceid="#{@deviceid[0..6]}XXXXX" @clientkey="#{@clientkey[0..6]}XXXXX">}
|
20
|
+
end
|
21
|
+
|
18
22
|
def get_messages(query={})
|
19
23
|
opts = {
|
20
24
|
:query => {:clientkey => @clientkey}
|
data/lib/irkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|