solcal 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/solcal/location.rb +12 -1
- data/lib/solcal/version.rb +1 -1
- data/spec/date_pair_spec.rb +18 -0
- data/spec/location_spec.rb +3 -3
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 848951985cdcf0671f66fdc25b2ef4a4785acc76
|
|
4
|
+
data.tar.gz: 3097df8b686ac93f491e0e4a5b45797a2e3cb05e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1abbd6f9aaa58a259a44c85c1a668cace5751c719ed818d55df6857f2a46b493556d3a6c713fb5052c92312726aabbaf4edb29be72d6ff1336840817fd330b3c
|
|
7
|
+
data.tar.gz: 218bf343db317d62d310896a31642a756a7a7629954725d6e8b8dd00f9f35f800415ba55eff32e89b4a0705d7cf48fedc4eeced6e26dc7641c475f174ab20a49
|
data/.gitignore
CHANGED
data/lib/solcal/location.rb
CHANGED
|
@@ -5,7 +5,6 @@ module SolCal
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def method_missing(name, *args, &block)
|
|
8
|
-
puts "Location calling [#{name}] with (#{args.inspect})"
|
|
9
8
|
Commands.run(name, create_data(args[0],args[1],args[2],args[3]))
|
|
10
9
|
end
|
|
11
10
|
|
|
@@ -17,6 +16,18 @@ module SolCal
|
|
|
17
16
|
results
|
|
18
17
|
end
|
|
19
18
|
|
|
19
|
+
def date_pair(year, month, day, time_zone)
|
|
20
|
+
results = create_data(year,month,day, time_zone)
|
|
21
|
+
Commands.run(:duration, results)
|
|
22
|
+
date = Date.new(year, month, day)
|
|
23
|
+
while(date <= Date.new(year+1, month, day))
|
|
24
|
+
date += 1
|
|
25
|
+
next_results = create_data(date.year, date.month, date.day, time_zone)
|
|
26
|
+
Commands.run(:duration, next_results)
|
|
27
|
+
return next_results if (results[:duration]-next_results[:duration]).abs <= 0.3
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
20
31
|
protected
|
|
21
32
|
def create_data(year, month, day, time_zone)
|
|
22
33
|
{
|
data/lib/solcal/version.rb
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "DatePair" do
|
|
4
|
+
before :each do
|
|
5
|
+
@edmonton = SolCal::Location.new(53.5333, -113.5)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should calculate the date pair for January 14 in Edmonton" do
|
|
9
|
+
expect(@edmonton.date_pair(2015,01,14,-7)[:date]).to eql(Date.new(2015,11,28))
|
|
10
|
+
expect(@edmonton.date_pair(2015,01,15,-7)[:date]).to eql(Date.new(2015,11,27))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should calculate the date pair for winter solstice in Edmonton" do
|
|
14
|
+
expect(@edmonton.date_pair(2014,12,21,-7)[:date]).to eql(Date.new(2014,12,22))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
data/spec/location_spec.rb
CHANGED
|
@@ -9,17 +9,17 @@ describe "Location" do
|
|
|
9
9
|
|
|
10
10
|
it "should calculate the sunrise for an arbitrary day in Edmonton" do
|
|
11
11
|
expect(SolCal::Commands).to receive(:run).and_return({sunrise:SolCal::TimeOfDay.new(0.25)})
|
|
12
|
-
expect(@edmonton.sunrise(2014,12,21,-7).to_s).to eql("06:00")
|
|
12
|
+
expect(@edmonton.sunrise(2014,12,21,-7)[:sunrise].to_s).to eql("06:00")
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should calculate the sunset for an arbitrary day in Edmonton" do
|
|
16
16
|
expect(SolCal::Commands).to receive(:run).and_return({sunset:SolCal::TimeOfDay.new(0.75)})
|
|
17
|
-
expect(@edmonton.sunset(2014,12,21,-7).to_s).to eql("18:00")
|
|
17
|
+
expect(@edmonton.sunset(2014,12,21,-7)[:sunset].to_s).to eql("18:00")
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it "should calculate the duration of sunlight for an arbitrary day in Edmonton" do
|
|
21
21
|
expect(SolCal::Commands).to receive(:run).and_return({duration:500})
|
|
22
|
-
expect(@edmonton.duration(2014,12,21,-7)).to eql(500)
|
|
22
|
+
expect(@edmonton.duration(2014,12,21,-7)[:duration]).to eql(500)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "should calculate daylight information for edmonton" do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solcal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Neil Bourgeois
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-01-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -100,6 +100,7 @@ files:
|
|
|
100
100
|
- spec/commands/sunset_command_spec.rb
|
|
101
101
|
- spec/commands/true_longitude_command_spec.rb
|
|
102
102
|
- spec/commands/var_y_command_spec.rb
|
|
103
|
+
- spec/date_pair_spec.rb
|
|
103
104
|
- spec/location_spec.rb
|
|
104
105
|
- spec/spec.opts
|
|
105
106
|
- spec/spec_helper.rb
|
|
@@ -151,6 +152,7 @@ test_files:
|
|
|
151
152
|
- spec/commands/sunset_command_spec.rb
|
|
152
153
|
- spec/commands/true_longitude_command_spec.rb
|
|
153
154
|
- spec/commands/var_y_command_spec.rb
|
|
155
|
+
- spec/date_pair_spec.rb
|
|
154
156
|
- spec/location_spec.rb
|
|
155
157
|
- spec/spec.opts
|
|
156
158
|
- spec/spec_helper.rb
|