dashing-weather 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ require 'thor'
2
+
3
+ module Dashing
4
+ class Weather < Thor
5
+ include Thor::Actions
6
+
7
+ attr_accessor :name
8
+ attr_accessor :woe_id
9
+ attr_accessor :format
10
+
11
+ def self.source_root
12
+ File.expand_path('../../templates', __FILE__)
13
+ end
14
+
15
+ desc "weather:install (widget|job) NAME WOE_ID FORMAT", "installs jobs or widgets"
16
+ def install(type, name, woe_id, format)
17
+ @name = Thor::Util.snake_case(name)
18
+ case type
19
+ when 'widget'
20
+ directory :widgets
21
+ when 'job'
22
+ @format = format
23
+ @woe_id = woe_id
24
+ directory :jobs
25
+ else
26
+ puts "invalid install type. Please use widget or job."
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,19 @@
1
+ require 'net/http'
2
+ require 'xmlsimple'
3
+
4
+ # Get a WOEID (Where On Earth ID)
5
+ # for your location from here:
6
+ # http://woeid.rosselliot.co.nz/
7
+ woe_id = <%= woe_id %>
8
+
9
+ # Temerature format:
10
+ # 'c' for Celcius
11
+ # 'f' for Fahrenheit
12
+ format = '<%= format %>'
13
+
14
+ SCHEDULER.every '15m', :first_in => 0 do |job|
15
+ http = Net::HTTP.new('weather.yahooapis.com')
16
+ response = http.request(Net::HTTP::Get.new("/forecastrss?w=#{woe_id}&u=#{format}"))
17
+ weather_data = XmlSimple.xml_in(response.body, { 'ForceArray' => false })['channel']['item']['condition']
18
+ send_event('<%= name %>', { :temp => "#{weather_data['temp']}&deg;#{format.upcase}", :condition => weather_data['text'] })
19
+ end
@@ -0,0 +1,9 @@
1
+ class Dashing.<%= Thor::Util.camel_case(name) %> extends Dashing.Widget
2
+
3
+ ready: ->
4
+ # This is fired when the widget is done being rendered
5
+
6
+ onData: (data) ->
7
+ # Handle incoming data
8
+ # You can access the html node of this widget with `@node`
9
+ # Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in.
@@ -0,0 +1,7 @@
1
+ <h1 class="title" data-bind="title"></h1>
2
+
3
+ <h2 class="temp" data-bind="temp | raw"></h2>
4
+
5
+ <p class="condition" data-bind="condition"></p>
6
+
7
+ <p class="updated-at" data-bind="updatedAtMessage"></p>
@@ -0,0 +1,35 @@
1
+ // ----------------------------------------------------------------------------
2
+ // Sass declarations
3
+ // ----------------------------------------------------------------------------
4
+ $background-color: #47bbb3;
5
+ $value-color: #fff;
6
+
7
+ $title-color: rgba(255, 255, 255, 0.7);;
8
+ $moreinfo-color: rgba(255, 255, 255, 0.7);;
9
+
10
+ // ----------------------------------------------------------------------------
11
+ // Widget-<%= name %> styles
12
+ // ----------------------------------------------------------------------------
13
+ .widget-<%= name %> {
14
+
15
+ background-color: $background-color;
16
+
17
+ .title {
18
+ color: $title-color;
19
+ }
20
+
21
+ .temp {
22
+ color: $value-color;
23
+ }
24
+
25
+ .condition {
26
+ font-weight: 500;
27
+ font-size: 30px;
28
+ color: $value-color;
29
+ }
30
+
31
+ .updated-at {
32
+ color: rgba(0, 0, 0, 0.3);
33
+ }
34
+
35
+ }
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dashing-weather
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - David Underwood
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: xml-simple
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: thor
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Allows you to generate weather widgets and jobs for Dashing, the incredibly
47
+ handsome dashboard framework
48
+ email: davefp@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - templates/jobs/%name%.rb.tt
54
+ - templates/widgets/%name%/%name%.coffee.tt
55
+ - templates/widgets/%name%/%name%.html
56
+ - templates/widgets/%name%/%name%.scss.tt
57
+ - lib/dashing/weather.rb
58
+ homepage: https://github.com/davefp/dashing-weather
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.23
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Weather widgets for Dashing
82
+ test_files: []