tikaro-sandex 0.0.0
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.
- data/LICENSE +20 -0
- data/README.rdoc +43 -0
- data/VERSION.yml +4 -0
- data/lib/sandex.rb +25 -0
- data/test/sandex_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +60 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 John Young
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
= sandex
|
|
2
|
+
|
|
3
|
+
* http://github.com/tikaro/sandex
|
|
4
|
+
|
|
5
|
+
== Description
|
|
6
|
+
|
|
7
|
+
The sandex is an index of awesome your weather is, compared to the current weather in San Diego, CA. The highest possible sandex is 100%.
|
|
8
|
+
|
|
9
|
+
This score is used to answer the question: "Is it nice enough to work outside today?" If the sandex is high, yes: go work outside. That's because EVERY day is a work-outside day in San Diego.
|
|
10
|
+
|
|
11
|
+
Thanks to @r38y for the concept and the name.
|
|
12
|
+
|
|
13
|
+
== Features
|
|
14
|
+
|
|
15
|
+
- Given a NOAA station ID, calculate the sandex.
|
|
16
|
+
- Currently, the sandex is a stub: 100% MINUS one percent for every degree difference (positive or negative) between your station and KSAN in San Diego.
|
|
17
|
+
- Defaults to station KILG, near West Chester, Pennsilvania.
|
|
18
|
+
|
|
19
|
+
== Requirements
|
|
20
|
+
|
|
21
|
+
- libxml-ruby >= 0.9.7
|
|
22
|
+
- andre-geokit >= 1.2.0
|
|
23
|
+
- outoftime-noaa >= 0.2.2
|
|
24
|
+
|
|
25
|
+
== Installation
|
|
26
|
+
|
|
27
|
+
Note that the NOAA gem has some separate install requirements, and must update its station list. Once I get that figured out, I'll add that here.
|
|
28
|
+
|
|
29
|
+
* sudo gem sources --add http://gems.github.com (only if you haven't done this before)
|
|
30
|
+
* sudo gem install tikaro-sandex
|
|
31
|
+
|
|
32
|
+
== Usage
|
|
33
|
+
|
|
34
|
+
Get the current sandex score for your location:
|
|
35
|
+
Sandex.calculate(station_id)
|
|
36
|
+
|
|
37
|
+
== Contact
|
|
38
|
+
|
|
39
|
+
John Young (john@tikaro.net)
|
|
40
|
+
|
|
41
|
+
== Copyright
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2009 John Young. See LICENSE for details.
|
data/VERSION.yml
ADDED
data/lib/sandex.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
gem 'libxml-ruby', '>= 0.9.7'
|
|
3
|
+
gem 'andre-geokit', '>= 1.2.0'
|
|
4
|
+
gem 'outoftime-noaa', '>= 0.2.2'
|
|
5
|
+
|
|
6
|
+
require 'time'
|
|
7
|
+
require 'libxml'
|
|
8
|
+
require 'geokit'
|
|
9
|
+
require 'noaa'
|
|
10
|
+
|
|
11
|
+
module Sandex
|
|
12
|
+
def self.calculate(local_station='KILG')
|
|
13
|
+
local_conditions = NOAA.current_conditions_at_station(local_station)
|
|
14
|
+
ksan_conditions = NOAA.current_conditions_at_station('KSAN')
|
|
15
|
+
|
|
16
|
+
local_temperature = local_conditions.temperature
|
|
17
|
+
ksan_temperature = ksan_conditions.temperature
|
|
18
|
+
|
|
19
|
+
temperature_delta = ( ksan_temperature - local_temperature ).abs
|
|
20
|
+
|
|
21
|
+
sandex_score = ( 100 - temperature_delta.to_f ) / 100
|
|
22
|
+
|
|
23
|
+
sandex_score
|
|
24
|
+
end
|
|
25
|
+
end
|
data/test/sandex_test.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tikaro-sandex
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- tikaro
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-03-09 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description:
|
|
17
|
+
email: john@tikaro.net
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- README.rdoc
|
|
24
|
+
- LICENSE
|
|
25
|
+
files:
|
|
26
|
+
- README.rdoc
|
|
27
|
+
- VERSION.yml
|
|
28
|
+
- lib/sandex.rb
|
|
29
|
+
- test/sandex_test.rb
|
|
30
|
+
- test/test_helper.rb
|
|
31
|
+
- LICENSE
|
|
32
|
+
has_rdoc: true
|
|
33
|
+
homepage: http://github.com/tikaro/sandex
|
|
34
|
+
post_install_message:
|
|
35
|
+
rdoc_options:
|
|
36
|
+
- --inline-source
|
|
37
|
+
- --charset=UTF-8
|
|
38
|
+
require_paths:
|
|
39
|
+
- lib
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: "0"
|
|
45
|
+
version:
|
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
|
+
requirements:
|
|
48
|
+
- - ">="
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: "0"
|
|
51
|
+
version:
|
|
52
|
+
requirements: []
|
|
53
|
+
|
|
54
|
+
rubyforge_project:
|
|
55
|
+
rubygems_version: 1.2.0
|
|
56
|
+
signing_key:
|
|
57
|
+
specification_version: 2
|
|
58
|
+
summary: TODO
|
|
59
|
+
test_files: []
|
|
60
|
+
|