sun-times 0.1.4 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/{COPYING → LICENSE.txt} +4 -2
- data/README.md +26 -23
- data/Rakefile +3 -4
- data/lib/sun-times/version.rb +3 -0
- data/lib/{sun_times.rb → sun-times.rb} +6 -40
- data/sun-times.gemspec +22 -0
- data/test/calculate_test.rb +1 -1
- metadata +54 -18
- data/test/test_all.rb +0 -3
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/{COPYING → LICENSE.txt}
RENAMED
@@ -1,4 +1,6 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2013 Timo Schilling
|
2
|
+
|
3
|
+
MIT License
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
6
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
21
|
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.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,38 +1,41 @@
|
|
1
1
|
# SunTimes
|
2
2
|
[![Build Status](https://secure.travis-ci.org/timoschilling/sun-times.png?branch=master)](http://travis-ci.org/timoschilling/sun-times)
|
3
3
|
|
4
|
-
|
4
|
+
_This is a Fork of [joeyates/ruby-sun-times](https://github.com/joeyates/ruby-sun-times) and is avalible as [sun-times gem](https://rubygems.org/gems/sun-times) so there is no explicit `require` necessary in rails projects._
|
5
5
|
|
6
6
|
Calculates sunrise and sunset times.
|
7
7
|
|
8
8
|
An implementation of the algorithm described at http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
|
9
9
|
|
10
|
-
##
|
10
|
+
## Installation
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'sun-times'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
15
19
|
|
16
|
-
|
20
|
+
Or install it yourself as:
|
17
21
|
|
18
|
-
|
22
|
+
$ gem install sun-times
|
19
23
|
|
20
|
-
|
24
|
+
## Usage
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
deal in the Software without restriction, including without limitation the
|
25
|
-
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
26
|
-
sell copies of the Software, and to permit persons to whom the Software is
|
27
|
-
furnished to do so, subject to the following conditions:
|
26
|
+
SunTimes.rise(Date.new(2010, 3, 8), 51.506318, 7.460659)
|
27
|
+
SunTimes.set(Date.new(2010, 3, 8), 51.506318, 7.460659)
|
28
28
|
|
29
|
-
|
30
|
-
all copies or substantial portions of the Software.
|
29
|
+
## Contributing
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
36
|
+
|
37
|
+
## References
|
38
|
+
|
39
|
+
* http://www.astro.uu.nl/~strous/AA/en/reken/zonpositie.html - Calculations
|
40
|
+
* http://williams.best.vwh.net/sunrise_sunset_algorithm.htm - Algorithm
|
41
|
+
* http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/264573 - Ken Bloom's implementation
|
data/Rakefile
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require 'rubygems/package_task'
|
1
|
+
require "bundler/gem_tasks"
|
3
2
|
require 'rdoc/task'
|
4
3
|
require 'rake/testtask'
|
5
4
|
require 'rake/clean'
|
6
5
|
|
7
6
|
$:.unshift(File.dirname(__FILE__) + '/lib')
|
8
|
-
require '
|
7
|
+
require 'sun-times'
|
9
8
|
|
10
9
|
RDOC_OPTS = ['--quiet', '--title', 'Sun Times Calculator', '--main', 'README.md', '--inline-source']
|
11
10
|
CLEAN.include 'doc'
|
@@ -18,7 +17,7 @@ Rake::TestTask.new do |t|
|
|
18
17
|
t.verbose = true
|
19
18
|
end
|
20
19
|
|
21
|
-
|
20
|
+
RDoc::Task.new do |rdoc|
|
22
21
|
rdoc.rdoc_dir = 'doc/rdoc'
|
23
22
|
rdoc.options += RDOC_OPTS
|
24
23
|
rdoc.main = "README.md"
|
@@ -1,51 +1,17 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2010 Joe Yates
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
# Algorithm from http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
|
25
|
-
|
26
1
|
require 'date'
|
27
2
|
|
28
3
|
module SunTimes
|
29
|
-
|
30
|
-
module VERSION #:nodoc:
|
31
|
-
MAJOR = 0
|
32
|
-
MINOR = 1
|
33
|
-
TINY = 4
|
34
|
-
|
35
|
-
STRING = [MAJOR, MINOR, TINY].join('.')
|
36
|
-
end
|
37
|
-
|
38
4
|
DEFAULT_ZENITH = 90.83333
|
39
5
|
KNOWN_EVENTS = [:rise, :set]
|
40
6
|
DEGREES_PER_HOUR = 360.0 / 24.0
|
41
7
|
|
42
8
|
# Helper method: calculates sunrise, with the same parameters as calculate
|
43
|
-
def
|
9
|
+
def self.rise(date, latitude, longitude, options = {})
|
44
10
|
calculate(:rise, date, latitude, longitude, options)
|
45
11
|
end
|
46
12
|
|
47
13
|
# Helper method: calculates sunset, with the same parameters as calculate
|
48
|
-
def
|
14
|
+
def self.set(date, latitude, longitude, options = {})
|
49
15
|
calculate(:set, date, latitude, longitude, options)
|
50
16
|
end
|
51
17
|
|
@@ -61,7 +27,7 @@ module SunTimes
|
|
61
27
|
# ==== Example
|
62
28
|
# SunTimes.calculate(:rise, Date.new(2010, 3, 8), 43.779, 11.432)
|
63
29
|
# > Mon Mar 08 05:39:53 UTC 2010
|
64
|
-
def
|
30
|
+
def self.calculate(event, date, latitude, longitude, options = {})
|
65
31
|
raise "Unknown event '#{ event }'" if KNOWN_EVENTS.find_index(event).nil?
|
66
32
|
zenith = options.delete(:zenith) || DEFAULT_ZENITH
|
67
33
|
|
@@ -136,15 +102,15 @@ module SunTimes
|
|
136
102
|
|
137
103
|
private
|
138
104
|
|
139
|
-
def
|
105
|
+
def self.degrees_to_radians(d)
|
140
106
|
d.to_f / 360.0 * 2.0 * Math::PI
|
141
107
|
end
|
142
108
|
|
143
|
-
def
|
109
|
+
def self.radians_to_degrees(r)
|
144
110
|
r.to_f * 360.0 / (2.0 * Math::PI)
|
145
111
|
end
|
146
112
|
|
147
|
-
def
|
113
|
+
def self.coerce_degrees(d)
|
148
114
|
if d < 0
|
149
115
|
d += 360
|
150
116
|
return coerce_degrees(d)
|
data/sun-times.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sun-times/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "sun-times"
|
8
|
+
gem.version = SunTimes::VERSION
|
9
|
+
gem.authors = ["Timo Schilling", "Joe Yates"]
|
10
|
+
gem.email = ["timo@schilling.io", "joe.g.yates@gmail.com"]
|
11
|
+
gem.description = %q{Module which calculates sunrise and sunset times.}
|
12
|
+
gem.summary = %q{Module which calculates sunrise and sunset times.}
|
13
|
+
gem.homepage = "http://github.com/timoschilling/sun-times"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}){ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "rake"
|
21
|
+
gem.add_development_dependency "rdoc"
|
22
|
+
end
|
data/test/calculate_test.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sun-times
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0.beta1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Joe Yates
|
9
8
|
- Timo Schilling
|
9
|
+
- Joe Yates
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
14
|
-
dependencies:
|
15
|
-
|
13
|
+
date: 2013-01-07 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rdoc
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: Module which calculates sunrise and sunset times.
|
16
48
|
email:
|
17
|
-
- joe.g.yates@gmail.com
|
18
49
|
- timo@schilling.io
|
50
|
+
- joe.g.yates@gmail.com
|
19
51
|
executables: []
|
20
52
|
extensions: []
|
21
|
-
extra_rdoc_files:
|
22
|
-
- README.md
|
23
|
-
- COPYING
|
53
|
+
extra_rdoc_files: []
|
24
54
|
files:
|
55
|
+
- .gitignore
|
56
|
+
- .travis.yml
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE.txt
|
25
59
|
- README.md
|
26
|
-
- COPYING
|
27
60
|
- Rakefile
|
28
|
-
- lib/
|
61
|
+
- lib/sun-times.rb
|
62
|
+
- lib/sun-times/version.rb
|
63
|
+
- sun-times.gemspec
|
29
64
|
- test/calculate_test.rb
|
30
|
-
- test/test_all.rb
|
31
65
|
homepage: http://github.com/timoschilling/sun-times
|
32
66
|
licenses: []
|
33
67
|
post_install_message:
|
@@ -40,18 +74,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
74
|
- - ! '>='
|
41
75
|
- !ruby/object:Gem::Version
|
42
76
|
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: -4449308383123247796
|
43
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
81
|
none: false
|
45
82
|
requirements:
|
46
|
-
- - ! '
|
83
|
+
- - ! '>'
|
47
84
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
85
|
+
version: 1.3.1
|
49
86
|
requirements: []
|
50
87
|
rubyforge_project:
|
51
88
|
rubygems_version: 1.8.24
|
52
89
|
signing_key:
|
53
90
|
specification_version: 3
|
54
|
-
summary: Module which calculates sunrise and sunset times
|
91
|
+
summary: Module which calculates sunrise and sunset times.
|
55
92
|
test_files:
|
56
|
-
- test/
|
57
|
-
has_rdoc: true
|
93
|
+
- test/calculate_test.rb
|
data/test/test_all.rb
DELETED