coligny 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3295057f0fb4fced0262abd1d2f72676cdceb877
4
- data.tar.gz: aba880f151f9c0526cb008ac13ea21498cf5d9de
3
+ metadata.gz: fc67a66c3f3e877286a04f186e084f23b623b119
4
+ data.tar.gz: 19382a3acbd89a2a94011b99a3fa915ad511235f
5
5
  SHA512:
6
- metadata.gz: 2e34fd03ca6baccf5b06b7ebeec7809d8f20e621bb14b03d4bd8c8ee36d0a518e42be340bc4cced3ed31f03fac994d3e27a562a86412ce01292c6e040f48ccd1
7
- data.tar.gz: 8b7392dca2b263b5f735d32ce6f23121a25ab2fd720dd10f4b4a727a262027c03e08eb49e84bd7e9347c5c121911fbe4656348bb6a4cfd9e47040bca2d824b34
6
+ metadata.gz: e376cb7ce3dbcdf27d0be87a60aa4e8bfb66d327760041b0974a2cc75fbca9f84624704eba4c4dab09d22c26d8ae81c7f9a1e146e394711ae47a56825aaa85d8
7
+ data.tar.gz: 6286e7124c78c07898f41a6ea309be3363866b3337774c90397414dfab2a45fa70f6681ed4c1d8bc147d7deddb43d636ef82ddf00886d5e648eda5c37fe4ab64
data/.travis.yml CHANGED
@@ -5,3 +5,6 @@ rvm:
5
5
  - 2.2
6
6
  - 2.1
7
7
  before_install: gem install bundler
8
+ addons:
9
+ code_climate:
10
+ repo_token: 10f028bb1baf916f23d507d00141194d9cdba69543fb01e556e906e8a5287988
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in coligny.gemspec
4
4
  gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Coligny
2
2
 
3
- [![Build Status](https://travis-ci.org/shanekrusen/coligny.svg?branch=master)](https://travis-ci.org/shanekrusen/coligny) [![Code Climate](https://codeclimate.com/github/shanekrusen/coligny/badges/gpa.svg)](https://codeclimate.com/github/shanekrusen/coligny)
3
+ [![Gem Version](https://badge.fury.io/rb/coligny.svg)](https://badge.fury.io/rb/coligny) [![Build Status](https://travis-ci.org/shanekrusen/coligny.svg?branch=master)](https://travis-ci.org/shanekrusen/coligny) [![Code Climate](https://codeclimate.com/github/shanekrusen/coligny/badges/gpa.svg)](https://codeclimate.com/github/shanekrusen/coligny) [![Test Coverage](https://codeclimate.com/github/shanekrusen/coligny/badges/coverage.svg)](https://codeclimate.com/github/shanekrusen/coligny/coverage) [![Dependency Status](https://gemnasium.com/badges/github.com/shanekrusen/coligny.svg)](https://gemnasium.com/github.com/shanekrusen/coligny)
4
4
 
5
5
  Welcome!
6
6
  Swáel!
@@ -9,7 +9,7 @@ This gem is intended to provide a resource for the use of the Coligny Calendar,
9
9
 
10
10
  ##To-DO
11
11
 
12
- - Finish long-term adjustments for slippage.
12
+ - Refactor populate methods for 30-year cycle
13
13
  - Add Inscriptions for dates
14
14
  - Comments
15
15
 
@@ -129,5 +129,7 @@ The gem is available as open source under the terms of the [MIT License](http://
129
129
  ## Credit
130
130
 
131
131
  Developer - Shane Krusen
132
- The model of the Coligny Calendar used for this project is the product of the work of the brilliant and lovely Helen McKay.
132
+
133
+ The model of the Coligny Calendar used for this project is the product of the work of the brilliant and lovely Helen McKay, the leading expert on the calendar.
134
+
133
135
  Support and feedback from the Modern Gaulish Community, Steve Hansen, Helen McKay, and my mentor, Klint Thrasher.
data/coligny.gemspec CHANGED
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.12"
23
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rake', '~> 11.2', '>= 11.2.2'
24
24
  spec.add_development_dependency "minitest", "~> 5.0"
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module Coligny
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/coligny.rb CHANGED
@@ -1,20 +1,11 @@
1
+ # Copyright 2016 @shanekrusen
2
+ # License MIT (https://opensource.org/licenses/MIT)
3
+
1
4
  require "./lib/coligny/version"
2
5
 
3
6
  module Coligny
4
7
  require 'date'
5
8
 
6
- def to_bg(ce)
7
- return ce + 1019
8
- end
9
-
10
- module_function :to_bg
11
-
12
- def to_ce(bg)
13
- return bg - 1019
14
- end
15
-
16
- module_function :to_ce
17
-
18
9
  class ColignyMonth
19
10
  attr_reader :name
20
11
  attr_accessor :days
@@ -27,11 +18,11 @@ module Coligny
27
18
 
28
19
  class ColignyYear
29
20
  attr_accessor :months, :days
21
+ attr_reader :is_early
30
22
 
31
23
  def initialize(year, is_metonic=false)
32
24
  @is_metonic = is_metonic
33
- @year = year
34
- @working_year = Coligny.to_ce(@year)
25
+ @year = year
35
26
  @months = [ColignyMonth.new("Samonios", 30),
36
27
  ColignyMonth.new("Dumanios", 29),
37
28
  ColignyMonth.new("Rivros", 30),
@@ -44,6 +35,8 @@ module Coligny
44
35
  ColignyMonth.new("Aedrinni", 30),
45
36
  ColignyMonth.new("Cantlos", 29)]
46
37
 
38
+ is_early?
39
+
47
40
  if !is_metonic
48
41
  populate_saturn_months
49
42
  else
@@ -53,18 +46,24 @@ module Coligny
53
46
 
54
47
  private
55
48
 
56
- def is_early
49
+ def is_early?
57
50
  if @is_metonic
58
- return true if (@year < 3035)
59
- return false
51
+ if (@year < 3035)
52
+ @is_early = true
53
+ else
54
+ @is_early = false
55
+ end
60
56
  else
61
- return true if (@year < 3034)
62
- return false
57
+ if (@year < 3034)
58
+ @is_early = true
59
+ else
60
+ @is_early = false
61
+ end
63
62
  end
64
63
  end
65
64
 
66
65
  def populate_saturn_earlier_equos
67
- if ((2015 - @working_year) % 5 == 1) || ((2015 - @working_year) % 5 == 0)
66
+ if ((3034 - @year) % 5 == 1) || ((3034 - @year) % 5 == 0)
68
67
  @months.insert(8, ColignyMonth.new("Equos", 30))
69
68
  else
70
69
  @months.insert(8, ColignyMonth.new("Equos", 29))
@@ -72,15 +71,15 @@ module Coligny
72
71
  end
73
72
 
74
73
  def populate_saturn_earlier_int
75
- if ((2015 - @working_year) % 5 == 0) && ((2015 - @working_year) % 30 != 5)
74
+ if ((3034 - @year) % 5 == 0) && ((3034 - @year) % 30 != 5)
76
75
  @months.unshift(ColignyMonth.new("Intercalary One", 29))
77
- elsif ((2015 - @working_year) % 5 == 3)
76
+ elsif ((3034 - @year) % 5 == 3)
78
77
  @months.insert(6, ColignyMonth.new("Intercalary Two", 30))
79
78
  end
80
79
  end
81
80
 
82
81
  def populate_saturn_later_equos
83
- if ((@working_year - 2015) % 5 == 0) || ((@working_year - 2015) % 5 == 4)
82
+ if ((@year - 3034) % 5 == 0) || ((@year - 3034) % 5 == 4)
84
83
  @months.insert(8, ColignyMonth.new("Equos", 30))
85
84
  else
86
85
  @months.insert(8, ColignyMonth.new("Equos", 29))
@@ -88,26 +87,49 @@ module Coligny
88
87
  end
89
88
 
90
89
  def populate_saturn_later_int
91
- if ((@working_year - 2015) % 5 == 0)
90
+ if ((@year - 3034) % 5 == 0)
92
91
  @months.unshift(ColignyMonth.new("Intercalary One", 29))
93
- elsif ((@working_year - 2015) % 5 == 2) && ((@working_year - 2015) % 30 != 27)
92
+ elsif ((@year - 3034) % 5 == 2) && ((@year - 3034) % 30 != 27)
93
+ @months.insert(6, ColignyMonth.new("Intercalary Two", 30))
94
+ end
95
+ end
96
+
97
+ def saturn_cycle_check(difference, years_between_instances, cycle, cycle_remainder)
98
+ if ((@year - 3034) % difference <= years_between_instances) && ((@year - 3034) >= difference) && ((@year - 3034) & cycle == cycle_remainder)
99
+ return true
100
+ else
101
+ return false
102
+ end
103
+ end
104
+
105
+ def saturn_longcycle_equos_check
106
+ if saturn_cycle_check(198, 4, 5, 4)
107
+ equos = @months.find { |s| s.name == "Equos" }
108
+ equos.days = 29
109
+ end
110
+ end
111
+
112
+ def saturn_longcycle_int2_check
113
+ if saturn_cycle_check(635, 29, 30, 27)
94
114
  @months.insert(6, ColignyMonth.new("Intercalary Two", 30))
95
115
  end
96
116
  end
97
117
 
98
118
  def populate_saturn_months
99
- if (@year < 3034)
119
+ if @is_early
100
120
  populate_saturn_earlier_equos
101
121
  populate_saturn_earlier_int
102
122
  else
103
123
  populate_saturn_later_equos
104
124
  populate_saturn_later_int
125
+ saturn_longcycle_equos_check
126
+ saturn_longcycle_int2_check
105
127
  end
106
128
  end
107
129
 
108
130
  def test_against_cases(cases)
109
131
  cases.each do |test|
110
- if ((@working_year - 2016) % 19) == test
132
+ if ((@year - 3035) % 19) == test
111
133
  return true
112
134
  end
113
135
  end
@@ -117,24 +139,24 @@ module Coligny
117
139
  def test_equos_days_metonic
118
140
  cases = [3,4,8,9,13,14,18]
119
141
 
120
- test_against_cases(cases)
142
+ return test_against_cases(cases)
121
143
  end
122
144
 
123
145
  def test_intone_metonic
124
146
  cases = [4,9,14]
125
147
 
126
- test_against_cases(cases)
148
+ return test_against_cases(cases)
127
149
  end
128
150
 
129
151
  def test_inttwo_metonic
130
152
  cases = [1,6,11,16]
131
153
 
132
- test_against_cases(cases)
154
+ return test_against_cases(cases)
133
155
  end
134
156
 
135
157
  def earlier_than_start_date_test_cases(cases)
136
158
  cases.each do |test|
137
- if ((2016 - @working_year) % 19) == test
159
+ if ((3035 - @year) % 19) == test
138
160
  return true
139
161
  end
140
162
  end
@@ -144,23 +166,23 @@ module Coligny
144
166
  def test_earlier_than_start_equos_days_metonic
145
167
  cases = [1,5,6,10,11,15,16]
146
168
 
147
- earlier_than_start_date_test_cases(cases)
169
+ return earlier_than_start_date_test_cases(cases)
148
170
  end
149
171
 
150
172
  def test_earlier_than_start_date_intone_metonic
151
173
  cases = [5,10,15]
152
174
 
153
- earlier_than_start_date_test_cases(cases)
175
+ return earlier_than_start_date_test_cases(cases)
154
176
  end
155
177
 
156
178
  def test_earlier_than_start_date_inttwo_metonic
157
179
  cases = [3,8,13,18]
158
180
 
159
- earlier_than_start_date_test_cases(cases)
181
+ return earlier_than_start_date_test_cases(cases)
160
182
  end
161
183
 
162
184
  def populate_metonic_equos
163
- if ((@year < 3035) && (test_earlier_than_start_equos_days_metonic)) || ((@year >= 3035) && (test_equos_days_metonic))
185
+ if (@is_early && (test_earlier_than_start_equos_days_metonic)) || (!@is_early && (test_equos_days_metonic))
164
186
  @months.insert(8, ColignyMonth.new("Equos", 30))
165
187
  else
166
188
  @months.insert(8, ColignyMonth.new("Equos", 29))
@@ -168,25 +190,25 @@ module Coligny
168
190
  end
169
191
 
170
192
  def populate_metonic_int1
171
- if (is_early && test_earlier_than_start_date_intone_metonic) || (!is_early && test_intone_metonic)
193
+ if (@is_early && test_earlier_than_start_date_intone_metonic) || (!@is_early && test_intone_metonic)
172
194
  @months.unshift(ColignyMonth.new("Intercalary One", 29))
173
195
  end
174
196
  end
175
197
 
176
198
  def populate_metonic_int2
177
- if (is_early && test_earlier_than_start_date_inttwo_metonic) || (!is_early && test_inttwo_metonic)
199
+ if (@is_early && test_earlier_than_start_date_inttwo_metonic) || (!@is_early && test_inttwo_metonic)
178
200
  @months.insert(6, ColignyMonth.new("Intercalary Two", 30))
179
201
  end
180
202
  end
181
203
 
182
204
  def metonic_longcycle_int2_check
183
- if ((@working_year - 2016) % 6569 <= 4) && ((@working_year - 2016) >= 6569) && (@months[6].name = "Intercalary Two")
205
+ if ((@year - 3035) % 6569 <= 4) && ((@year - 3035) >= 6569) && (@months[6].name = "Intercalary Two")
184
206
  @months.delete_at(6)
185
207
  end
186
208
  end
187
209
 
188
210
  def metonic_longcycle_equos_check
189
- if ((@working_year - 2016) % 61 <= 4) && ((@working_year - 2016) >= 61) && ((@working_year - 2016) % 5 == 4)
211
+ if ((@year - 3035) % 61 <= 4) && ((@year - 3035) >= 61) && test_equos_days_metonic
190
212
  @months.find { |s| s.name == "Equos" }.days = 29
191
213
  end
192
214
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coligny
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Krusen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-06 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '11.2'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 11.2.2
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '10.0'
43
+ version: '11.2'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 11.2.2
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: minitest
43
49
  requirement: !ruby/object:Gem::Requirement