lightwaverf 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/lightwaverf.rb +20 -13
  2. metadata +2 -2
data/lib/lightwaverf.rb CHANGED
@@ -30,11 +30,12 @@ class LightWaveRF
30
30
  # Display usage info
31
31
  def usage room = nil
32
32
  rooms = self.class.get_rooms self.get_config
33
- config = 'usage: lightwaverf ' + rooms.values.first['name'] + ' ' + rooms.values.first['device'].keys.first.to_s + ' on # where "' + rooms.keys.first + '" is a room in ' + self.get_config_file
33
+ config = 'usage: lightwaverf ' + rooms.values.first['name'].to_s + ' ' + rooms.values.first['device'].keys.first.to_s + ' on'
34
+ config += ' # where "' + rooms.keys.first.to_s + '" is a room in ' + self.get_config_file.to_s
34
35
  if room and rooms[room]
35
- config += "\ntry: lightwaverf " + rooms[room]['name'] + ' all on'
36
+ config += "\ntry: lightwaverf " + rooms[room]['name'].to_s + ' all on'
36
37
  rooms[room]['device'].each do | device |
37
- config += "\ntry: lightwaverf " + rooms[room]['name'] + ' ' + device.first.to_s + ' on'
38
+ config += "\ntry: lightwaverf " + rooms[room]['name'].to_s + ' ' + device.first.to_s + ' on'
38
39
  end
39
40
  end
40
41
  config
@@ -45,8 +46,8 @@ class LightWaveRF
45
46
  help = self.usage + "\n"
46
47
  help += "your rooms, devices, and sequences, as defined in " + self.get_config_file + ":\n\n"
47
48
  help += YAML.dump self.get_config['room']
48
- room = self.get_config['room'].last['name']
49
- device = self.get_config['room'].last['device'].last
49
+ room = self.get_config['room'].last['name'].to_s
50
+ device = self.get_config['room'].last['device'].last.to_s
50
51
  help += "\n\nso to turn on " + room + " " + device + " type \"lightwaverf " + room + " " + device + " on\"\n"
51
52
  end
52
53
 
@@ -609,15 +610,21 @@ class LightWaveRF
609
610
  # url = LightWaveRF.new.get_config['calendar']
610
611
  url = self.get_config['calendar']
611
612
 
612
- url += '?ctz=' + Time.new.zone
613
- # url += '?ctz=UTC'
614
- if Time.new.zone != 'UTC'
613
+ ctz = 'UTC'
614
+ case Time.new.zone
615
+ when 'BST'
616
+ ctz = 'Europe/London'
617
+ else
615
618
  p 'time zone is ' + Time.new.zone + ' so look out...'
616
619
  end
620
+ url += '?ctz=' + ctz
621
+ if ctz != 'UTC'
622
+ p 'using time zone is ' + ctz + ' so look out...'
623
+ end
617
624
 
618
625
  url += '&singleevents=true'
619
- url += '&start-min=' + query_start.strftime( '%FT%T%:z' ).sub('+', '%2B')
620
- url += '&start-max=' + query_end.strftime( '%FT%T%:z' ).sub('+', '%2B')
626
+ url += '&start-min=' + query_start.strftime( '%FT%T%:z' ).sub( '+', '%2B' )
627
+ url += '&start-max=' + query_end.strftime( '%FT%T%:z' ).sub( '+', '%2B' )
621
628
  debug and ( p url )
622
629
  parsed_url = URI.parse url
623
630
  http = Net::HTTP.new parsed_url.host, parsed_url.port
@@ -749,7 +756,7 @@ class LightWaveRF
749
756
  end_date = start_date
750
757
  end
751
758
 
752
- time_modifier += self.class.variance e.elements['title'].text
759
+ time_modifier += self.class.variance( e.elements['title'].text ).to_i
753
760
  event['annotate'] = ! ( /do not annotate/.match e.elements['title'].text )
754
761
 
755
762
  debug and ( p 'Start date: ' + start_date )
@@ -843,8 +850,8 @@ class LightWaveRF
843
850
  debug and ( p 'randomness is ' + n.to_s )
844
851
  return rand( n ) - ( n / 2 )
845
852
  end
846
- debug and ( p 'no randomness return 0' )
847
- return 0
853
+ debug and ( p 'no randomness return nil' )
854
+ return nil
848
855
  end
849
856
 
850
857
  # Convert a string to seconds, assume it is in minutes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightwaverf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-08-04 00:00:00.000000000 Z
14
+ date: 2013-08-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: htmlentities