reco4life 0.1.0 → 0.1.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: 10f31ff989799d3444b18b212898126fdfe0778b
4
- data.tar.gz: 57a6394d4a65c88376b515c960f5226fe1dc91c9
3
+ metadata.gz: 2c82c14ee5fec5864cbb7bcf3dfa9a7ecb812e30
4
+ data.tar.gz: 4940993e395714a5f9594061e825bf817e5a8577
5
5
  SHA512:
6
- metadata.gz: fbedb7e4f13fbbabb359a54b15c3f3d2f0e3bdf9ca0063c24f67142a5482779ffc790192ea37fa59f719293c24158721bc1ae060b3ad5c9a377ad0ae65d8d405
7
- data.tar.gz: d2c06489c03fc857d1e7e217cdcbf8a841b05bc4c5efb116a6cae2bf250728ada5f3194d0fb5fcdaac171db52a8b1b4b3d11415ee3d9b4d6892fbad6bac03c56
6
+ metadata.gz: 3019a7f038dbdf18476a48e1f7151e0e81b095239f0387d34185f6918128c10522c772c4162572b086ae948f358e4c2df2ba1018d7487a4922786cf76b98f4b4
7
+ data.tar.gz: 9f5b9233d6b5325cba81a839eef9d1b15adb3fee2bd8924654b7615d1703256b45fcc1bf1afb8670466e923a61e22fa51723acd01ee3c5b8cafb381aa54425c5
data/README.md CHANGED
@@ -28,8 +28,7 @@ begin
28
28
  Reco4life.api_key ='your_api_key'
29
29
 
30
30
  Reco4life.devices.each do |sn|
31
- next unless Reco4life.online? sn
32
- Reco4life.turn_on sn
31
+ Reco4life.turn_on(sn) if Reco4life.online?(sn)
33
32
  puts Reco4life.powered_on? sn
34
33
  end
35
34
  rescue => e
@@ -27,13 +27,11 @@ module Reco4life
27
27
  end
28
28
 
29
29
  def turn_on(sn)
30
- return if powered_on?(sn)
31
- switch(sn, 1)
30
+ switch(sn, 1) unless powered_on?(sn)
32
31
  end
33
32
 
34
33
  def turn_off(sn)
35
- return unless powered_on?(sn)
36
- switch(sn, 0)
34
+ switch(sn, 0) if powered_on?(sn)
37
35
  end
38
36
 
39
37
  def online?(sn)
@@ -54,8 +52,11 @@ module Reco4life
54
52
  end
55
53
 
56
54
  def token_valid?
57
- return true if !@token.nil? && !@token_expire_time.nil? && Time.now < @token_expire_time
58
- false
55
+ @token && !token_expired?
56
+ end
57
+
58
+ def token_expired?
59
+ @token_expire_time && @token_expire_time < Time.now
59
60
  end
60
61
 
61
62
  def fetch_devices
@@ -1,3 +1,3 @@
1
1
  module Reco4life
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 1.13'
31
31
  spec.add_development_dependency 'rake', '~> 10.0'
32
- spec.add_development_dependency 'http', '2.1.0'
32
+ spec.add_development_dependency 'http', '~>2.1.0'
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reco4life
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - aaron67
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-15 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: http
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.1.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.1.0
55
55
  description: Reco4life提供HTTP API来管理智能插座,封装这些接口