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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbb0696fd9a72205d44e499a2151e80d00cb03c9
4
- data.tar.gz: 840b58f7e25334393aa3ff7558a9b44f1bbc27ed
3
+ metadata.gz: 848951985cdcf0671f66fdc25b2ef4a4785acc76
4
+ data.tar.gz: 3097df8b686ac93f491e0e4a5b45797a2e3cb05e
5
5
  SHA512:
6
- metadata.gz: 928706e7b32852e0db59b0aea5c6d8105a12536d13f4294d03d92f070189740ac766d922298dec17e23786d38e01728ff52b954b3aa07349f395b1e69d9cd663
7
- data.tar.gz: 08adc087f2f69516e6f8ccef6e63a592f4c722bed58e90c000bc34dfba8c05e69740f4e4ed80459717d5d701410a24096a46c85c0aa46c90d2957c00b9eeae53
6
+ metadata.gz: 1abbd6f9aaa58a259a44c85c1a668cace5751c719ed818d55df6857f2a46b493556d3a6c713fb5052c92312726aabbaf4edb29be72d6ff1336840817fd330b3c
7
+ data.tar.gz: 218bf343db317d62d310896a31642a756a7a7629954725d6e8b8dd00f9f35f800415ba55eff32e89b4a0705d7cf48fedc4eeced6e26dc7641c475f174ab20a49
data/.gitignore CHANGED
@@ -14,4 +14,5 @@
14
14
  mkmf.log
15
15
  .vagrant
16
16
  bootstrap.sh
17
- Vagrantfile
17
+ Vagrantfile
18
+ solcal*.gem
@@ -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
  {
@@ -1,3 +1,3 @@
1
1
  module Solcal
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
+
@@ -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.1
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: 2014-12-20 00:00:00.000000000 Z
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