VanaTime 1.0.0 → 1.1.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/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ == 1.1.0 / 2007-08-27
2
+
3
+ * rewrote and switched to echoe
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2007 Travis Tilley
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,9 @@
1
+ README
2
+ Manifest
3
+ LICENSE
4
+ lib/vana_time.rb
5
+ lib/Vana/time.rb
6
+ lib/Vana/moon.rb
7
+ lib/Vana/day.rb
8
+ lib/Vana/constants.rb
9
+ CHANGELOG
data/README ADDED
@@ -0,0 +1,97 @@
1
+ VanaTime 1.1.0 README
2
+ =====================
3
+
4
+ This document was last updated on Thu Aug 30 22:58:05 EDT 2007.
5
+
6
+
7
+ Introduction to VanaTime
8
+ ========================
9
+ VanaTime is a group of classes that deal with times, days, and moon phases
10
+ in the MMORPG Final Fantasy Online (aka FFXI). Besides translating earth
11
+ time to game time, you can also convert game time to real time, step forward
12
+ a day, get a time estimate about how long you have left until the next
13
+ optimal moon phase, and a few other useful features.
14
+
15
+ VanaTime is a work in progress and the API may change from time to time...
16
+ you may want to use explicit versioning in any code depending on it.
17
+
18
+
19
+ FFXI::VanaTime API
20
+ ==================
21
+
22
+ * new(Time)
23
+ accepts a Time object to initialize a new VanaTime, using the current
24
+ time if no Time object is passed
25
+ * now
26
+ an alias for new as a convenience method
27
+ * at(VanaTime)
28
+ accepts a VanaTime object, int, or float representing vana time to
29
+ initialize a new VanaTime object
30
+ * earth_time=(Time)
31
+ allows re-initializing a VanaTime object with a new earth time
32
+ * vana_time=(VanaTime)
33
+ allows re-initializing a VanaTime object with a new vana time, given
34
+ as a VanaTime object (why not >_>), or (more useful) an int or float
35
+ * to_i
36
+ returns an integer with the internal representation of vana time
37
+ * to_f
38
+ returns a float with the internal representation of vana time without
39
+ losing any accuracy
40
+ * year
41
+ * month
42
+ * date
43
+ * hour
44
+ * minute
45
+ * second
46
+ these methods return various times, what we're interested in
47
+ * to_s
48
+ returns a string in the format:
49
+ YYYY-MM-DD hh:mm:ss
50
+ * day
51
+ returns a VanaDay object initialized with the current VanaTime
52
+ * moon
53
+ returns a VanaMoon object initialized with the current time
54
+
55
+
56
+ FFXI::VanaDay API
57
+ =================
58
+
59
+ * new(VanaTime)
60
+ accepts a VanaTime object used to initialize the vana day, using a new
61
+ VanaTime initialized to the current time if one isn't passed
62
+ * vana_time=(VanaTime)
63
+ used to reinitialize the vana day object with a new time
64
+ * to_i
65
+ returns a base zero number representing the day of the week
66
+ * to_s
67
+ returns the name of the day of the week
68
+ * weak_element
69
+ returns the element that the current day is weak to
70
+ * day_start
71
+ returns a VanaTime object representing the start of the current day
72
+ * tomorrow
73
+ returns a VanaTime object representing the start of the next vana day
74
+
75
+
76
+ FFXI::VanaMoon API
77
+ ==================
78
+
79
+ * new(Time)
80
+ Unlike VanaDay, VanaMoon is initialized with the current earth time
81
+ * to_i or moon_percent
82
+ returns a number representing the exact position along the progression
83
+ of moon phases
84
+ * moon_phase
85
+ returns a base zero number representing the current moon phase
86
+ * phase_name
87
+ returns the name of the current phase (full, waning gibbous, etc)
88
+ * next_optimal_phase
89
+ returns a base zero number representing the next optimal moon phase
90
+ * to_next_phase
91
+ returns an array with a countdown until the next moon phase
92
+ [day, hour, minute, second]
93
+ * to_optimal_phase
94
+ returns an array with a countdown until the next optimal phase with the
95
+ same format as above
96
+ * to_s
97
+ returns a string in the format: moon_percent.abs phase_name
data/VanaTime.gemspec ADDED
@@ -0,0 +1,42 @@
1
+
2
+ # Gem::Specification for Vanatime-1.1.0
3
+ # Originally generated by Echoe
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{VanaTime}
7
+ s.version = "1.1.0"
8
+ s.date = %q{2007-08-30}
9
+ s.summary = %q{A library for converting realtime to vanadiel time}
10
+ s.email = %q{ttilley@gmail.com}
11
+ s.homepage = %q{http://vanatime.rubyforge.org/}
12
+ s.rubyforge_project = %q{vanatime}
13
+ s.description = %q{A library for converting realtime to vanadiel time}
14
+ s.has_rdoc = true
15
+ s.authors = ["Travis Tilley"]
16
+ s.files = ["README", "Manifest", "LICENSE", "lib/vana_time.rb", "lib/Vana/time.rb", "lib/Vana/moon.rb", "lib/Vana/day.rb", "lib/Vana/constants.rb", "CHANGELOG", "VanaTime.gemspec"]
17
+ end
18
+
19
+
20
+ # # Original Rakefile source (requires the Echoe gem):
21
+ #
22
+ # version = "1.1.0"
23
+ #
24
+ # ENV['RUBY_FLAGS'] = ""
25
+ #
26
+ # begin
27
+ # require 'rubygems'
28
+ # gem 'echoe', '=2.3'
29
+ # require 'echoe'
30
+ #
31
+ # Echoe.new('VanaTime', version) do |p|
32
+ # p.rubyforge_name = 'vanatime'
33
+ # p.summary = "A library for converting realtime to vanadiel time"
34
+ # p.url = "http://vanatime.rubyforge.org/"
35
+ # p.author = 'Travis Tilley'
36
+ # p.email = "ttilley@gmail.com"
37
+ # end
38
+ #
39
+ # rescue LoadError => boom
40
+ # puts "You are missing a dependency required for meta-operations on this gem."
41
+ # puts "#{boom.to_s.capitalize}."
42
+ # end
@@ -0,0 +1,42 @@
1
+ # The following is quoted from http://ffxi.xenoveritas.org/tools/vanaclock/time
2
+
3
+ # Vana'diel time is exactly 25 times faster than normal time. This means that in
4
+ # one Earth hour, exactly 25 Vana'diel hours will have passed. Vana'diel time
5
+ # has 12 months, each of exactly 30 days. This means that a Vana'diel year is
6
+ # 360 days, not 365 like an Earth year. A Vana'diel week consists of eight days,
7
+ # one for each element. The order of days is Firesday, Earthsday, Watersday,
8
+ # Windsday, Iceday, Lightningsday, Lightsday, and Darksday. Note that this means
9
+ # that a Vana'diel month is two days shy of being four Vana'diel weeks. Other
10
+ # than that, Vana'diel time is exactly like Earth time - 24 hours in one day, 60
11
+ # minutes to an hour. I don't know who originally discovered the following, but,
12
+ # the following information can be used to set an "epoch" for Vana'diel time
13
+ # compared to Earth time:
14
+
15
+ # Earth time: 2002/06/23 15:00:00 GMT
16
+ # Vana'diel time: 0898/02/01 00:00:00
17
+
18
+ # Using that, you can take any given Earth time, subtract the starting Earth
19
+ # date to set time to "0", and then multiply that by 25 to convert to Vana'diel
20
+ # time.
21
+
22
+ module FFXI
23
+ module Constants
24
+ MINUTE = 60
25
+ HOUR = MINUTE * 60
26
+ DAY = HOUR * 24
27
+
28
+ MS_SECOND = 1000
29
+ MS_DAY = DAY * MS_SECOND
30
+ MS_HOUR = HOUR * MS_SECOND
31
+ MS_MINUTE = MINUTE * MS_SECOND
32
+
33
+ MS_GAME_DAY = (MS_DAY / 25)
34
+
35
+ BASIS_DATE = Time.utc(2002,6,23,15,0,0,0)
36
+ MOON_DATE = Time.utc(2004,1,25,2,31,12,0)
37
+
38
+ MS_BASIS_VANA = ((898 * 360 + 30) * MS_DAY).to_f
39
+ MS_BASIS_DATE = BASIS_DATE.to_f * MS_SECOND
40
+ MS_MOON_DATE = MOON_DATE.to_f * MS_SECOND
41
+ end
42
+ end
data/lib/Vana/day.rb ADDED
@@ -0,0 +1,52 @@
1
+ module FFXI
2
+ class VanaDay
3
+ include FFXI::Constants
4
+
5
+ VANA_DAYS = ["Firesday", "Earthsday", "Watersday", "Windsday", "Iceday",
6
+ "Lightningday", "Lightsday", "Darksday"]
7
+
8
+ DAY_WEAKNESS = ["Ice", "Lightning", "Fire", "Earth", "Wind", "Water",
9
+ "Darkness", "Light"]
10
+
11
+ def initialize(vana_time=VanaTime.now)
12
+ self.vana_time = vana_time
13
+ end
14
+
15
+ attr_reader :vana_time
16
+
17
+ def vana_time=(vana_time)
18
+ @vana_time = vana_time
19
+
20
+ vana_day = (@vana_time.to_f % (8 * MS_DAY)) / (MS_DAY)
21
+
22
+ if @vana_day.nil?
23
+ @vana_day = vana_day
24
+ elsif @vana_day != vana_day
25
+ @vana_day = vana_day
26
+ @vana_day_start = nil
27
+ @vana_day_tomorrow = nil
28
+ end
29
+ end
30
+
31
+ def to_i
32
+ @vana_day.to_i
33
+ end
34
+
35
+ def to_s
36
+ VANA_DAYS[@vana_day]
37
+ end
38
+
39
+ def weak_element
40
+ DAY_WEAKNESS[@vana_day]
41
+ end
42
+
43
+ def day_start
44
+ @vana_day_start ||=
45
+ VanaTime.at(@vana_time.to_f - (@vana_time.to_f % MS_DAY ))
46
+ end
47
+
48
+ def tomorrow
49
+ @vana_day_tomorrow ||= VanaTime.at(day_start.to_f + MS_DAY)
50
+ end
51
+ end
52
+ end
data/lib/Vana/moon.rb ADDED
@@ -0,0 +1,93 @@
1
+ module FFXI
2
+ class VanaMoon
3
+ include FFXI::Constants
4
+
5
+ MOON_PHASES = ["Full", "Waning Gibbous", "Last Quarter", "Waning Crescent",
6
+ "New Moon", "Waxing Crescent", "First Quarter", "Waxing Gibbous"]
7
+
8
+ def initialize(time = Time.now)
9
+ localtime = (time.to_f * 1000).to_i
10
+ # Each lunar cycle takes exactly 84 game days
11
+ # (3 days, 8 hours, 38 minutes, 24 seconds)
12
+ @moon_days = ((localtime - MS_MOON_DATE.to_i) / MS_GAME_DAY).floor % 84
13
+ @moon_percent = - ((42 - @moon_days).to_f / 42 * 100).round
14
+ @elapsed_time = (localtime - MS_MOON_DATE.to_i) % MS_GAME_DAY
15
+
16
+ case @moon_percent
17
+ when (-100..-94)
18
+ @moon_phase = 0
19
+ @next_phase_target = 3
20
+ when (90..100)
21
+ @moon_phase = 0
22
+ @next_phase_target = 3 + 84
23
+ when (-93..-62)
24
+ @moon_phase = 1
25
+ @next_phase_target = 17
26
+ when (-61..-41)
27
+ @moon_phase = 2
28
+ @next_phase_target = 25
29
+ when (-40..-11)
30
+ @moon_phase = 3
31
+ @next_phase_target = 38
32
+ when (-10..6)
33
+ @moon_phase = 4
34
+ @next_phase_target = 45
35
+ when (7..36)
36
+ @moon_phase = 5
37
+ @next_phase_target = 58
38
+ when (37..56)
39
+ @moon_phase = 6
40
+ @next_phase_target = 66
41
+ when (57..89)
42
+ @moon_phase = 7
43
+ @next_phase_target = 60
44
+ end
45
+
46
+ case @moon_phase
47
+ when (0..3)
48
+ @next_optimal_phase = 4
49
+ @optimal_phase_target = 38
50
+ @optimal_phase_target += 84 if (90..100).include? @moon_percent
51
+ when (4..7)
52
+ @next_optimal_phase = 0
53
+ @optimal_phase_target = 80
54
+ end
55
+ end
56
+
57
+ attr_reader :elapsed_time, :moon_days, :moon_percent, :moon_phase,
58
+ :next_optimal_phase
59
+
60
+ def countdown(time)
61
+ day_left = time.to_f / MS_DAY
62
+ hour_left = (day_left.to_f - day_left.floor) * 24
63
+ min_left = (hour_left.to_f - hour_left.floor) * 60
64
+ sec_left = (min_left.to_f - min_left.floor) * 60
65
+
66
+ [day_left.floor, hour_left.floor, min_left.floor, sec_left.floor]
67
+ end
68
+
69
+ def phase_countdown(target)
70
+ countdown((target - @moon_days) * MS_GAME_DAY - @elapsed_time)
71
+ end
72
+
73
+ def to_next_phase
74
+ phase_countdown(@next_phase_target)
75
+ end
76
+
77
+ def to_optimal_phase
78
+ phase_countdown(@optimal_phase_target)
79
+ end
80
+
81
+ def to_i
82
+ @moon_percent
83
+ end
84
+
85
+ def phase_name
86
+ MOON_PHASES[@moon_phase]
87
+ end
88
+
89
+ def to_s
90
+ "#{@moon_percent.abs}% #{phase_name}"
91
+ end
92
+ end
93
+ end
data/lib/Vana/time.rb ADDED
@@ -0,0 +1,99 @@
1
+ module FFXI
2
+ class VanaTime
3
+ include FFXI::Constants
4
+
5
+ def initialize(time = Time.now)
6
+ self.earth_time = time
7
+ end
8
+
9
+ def update_instance_variables
10
+ # the day object knows how to update only what is necessary, so if there
11
+ # is an existing VanaDay object, update it
12
+ if ! @vDay.nil?
13
+ @vDay.vana_time = @vana_time
14
+ end
15
+
16
+ # nil these until they're used and updated later
17
+ @vYear=@vMon=@vDate=@vHour=@vMin=@vSec=@vana_moon=nil
18
+ end
19
+
20
+ def earth_time=(time)
21
+ raise "input needs to be a Time object" if ! time.is_a? Time
22
+
23
+ @earth_time = time
24
+ ms_earth_time = @earth_time.to_f * MS_SECOND
25
+ @vana_time = ((898 * 360 + 30) * MS_DAY) +
26
+ (ms_earth_time - MS_BASIS_DATE) * 25
27
+
28
+ update_instance_variables
29
+ end
30
+
31
+ attr_reader :earth_time
32
+
33
+ def self.vana_to_earth(vana_time)
34
+ (((vana_time.to_f - ((898 * 360 + 30) * MS_DAY.to_f)) / 25) +
35
+ MS_BASIS_DATE.to_f) / MS_SECOND
36
+ end
37
+
38
+ def vana_time=(vana_time)
39
+ @vana_time = vana_time.to_f
40
+ @earth_time = Time.at(self.class.vana_to_earth(vana_time))
41
+
42
+ update_instance_variables
43
+ end
44
+
45
+ def self.at(vana_time)
46
+ self.new(Time.at(self.vana_to_earth(vana_time)))
47
+ end
48
+
49
+ def to_i
50
+ @vana_time.to_i
51
+ end
52
+
53
+ def to_f
54
+ @vana_time.to_f
55
+ end
56
+
57
+ def year
58
+ @vYear ||= (@vana_time / (360 * MS_DAY)).to_i
59
+ end
60
+
61
+ def month
62
+ @vMon ||= (((@vana_time % (360 * MS_DAY)) / (30 * MS_DAY)) + 1).to_i
63
+ end
64
+
65
+ def date
66
+ @vDate ||= (((@vana_time % (30 * MS_DAY)) / (MS_DAY)) + 1).to_i
67
+ end
68
+
69
+ def hour
70
+ @vHour ||= ((@vana_time % MS_DAY) / MS_HOUR).to_i
71
+ end
72
+
73
+ def minute
74
+ @vMin ||= ((@vana_time % MS_HOUR) / MS_MINUTE).to_i
75
+ end
76
+
77
+ def second
78
+ @vSec ||= ((@vana_time % MS_MINUTE) / MS_SECOND).to_i
79
+ end
80
+
81
+ def day
82
+ @vDay ||= VanaDay.new(@vana_time)
83
+ end
84
+
85
+ def moon
86
+ @vana_moon ||= VanaMoon.new(@earth_time)
87
+ end
88
+
89
+ def self.now
90
+ self.new
91
+ end
92
+
93
+ def to_s
94
+ "#{year}-#{"%02d" % month}-#{"%02d" % date}" +
95
+ " #{"%02d" % hour}:#{"%02d" % minute}:#{"%02d" % second}"
96
+ end
97
+
98
+ end
99
+ end
data/lib/vana_time.rb CHANGED
@@ -1,124 +1,6 @@
1
- class VanaTime
2
- VERSION = '1.0.0'
1
+ $:.unshift File.dirname(__FILE__)
3
2
 
4
- SECONDS_REAL_DAY = (24 * 60 * 60)
5
- BASIS_DATE = Time.utc(2002,6,23,15,0,0,0)
6
-
7
- def initialize(time = Time.now)
8
- self.earth_time = time
9
- end
10
-
11
- def earth_time=(time)
12
- raise "Input was not a Time object" if ! time.is_a?(Time)
13
-
14
- @earth_time = time
15
- @vana_time = ((898 * 360 + 30) * SECONDS_REAL_DAY) +
16
- (@earth_time.to_i - BASIS_DATE.to_i) * 25
17
-
18
- @vDate = @vDay = @vHour = @vMin = @vMon = @vMoon = @vSec = @vYear = nil
19
- end
20
-
21
- attr_reader :earth_time
22
-
23
- def self.vana_to_earth(vana_time)
24
- ((vana_time - ((898 * 360 + 30) * SECONDS_REAL_DAY)) / 25) + BASIS_DATE.to_i
25
- end
26
-
27
- def vana_time=(vana_time)
28
- @vana_time = vana_time
29
- @earth_time = Time.at(self.class.vana_to_earth(vana_time))
30
-
31
- @vDate = @vDay = @vHour = @vMin = @vMon = @vMoon = @vSec = @vYear = nil
32
- end
33
-
34
- def self.at(vana_time)
35
- self.new(Time.at(self.vana_to_earth(vana_time)))
36
- end
37
-
38
- def to_i
39
- @vana_time
40
- end
41
-
42
- def year
43
- @vYear ||= (@vana_time / (360 * SECONDS_REAL_DAY))
44
- end
45
-
46
- def month
47
- @vMon ||= ((@vana_time % (360 * SECONDS_REAL_DAY)) /
48
- (30 * SECONDS_REAL_DAY)) + 1
49
- end
50
-
51
- def date
52
- @vDate ||= ((@vana_time % (30 * SECONDS_REAL_DAY)) /
53
- (SECONDS_REAL_DAY)) + 1
54
- end
55
-
56
- def hour
57
- @vHour ||= ((@vana_time % (SECONDS_REAL_DAY)) / (60 * 60))
58
- end
59
-
60
- def minute
61
- @vMin ||= ((@vana_time % (60 * 60)) / (60))
62
- end
63
-
64
- def second
65
- @vSec ||= (@vana_time % 60)
66
- end
67
-
68
- class VanaDay
69
- VANA_DAYS = ["Firesday", "Earthsday", "Watersday", "Windsday", "Iceday",
70
- "Lightningday", "Lightsday", "Darksday"]
71
- def initialize(vana_time)
72
- @vanaDay = ((vana_time % (8 * SECONDS_REAL_DAY)) / (SECONDS_REAL_DAY))
73
- end
74
- def to_i
75
- @vanaDay
76
- end
77
- def to_s
78
- VANA_DAYS[@vanaDay]
79
- end
80
- end
81
-
82
- def day
83
- @vDay ||= VanaDay.new(@vana_time)
84
- end
85
-
86
- class VanaMoon
87
- SECONDS_GAME_DAY = (24 * 60 * 60 / 25)
88
- MOON_DATE = Time.utc(2004,1,25,2,31,12,0)
89
- def initialize(time)
90
- moon_days = ((time.to_i - MOON_DATE.to_i) / SECONDS_GAME_DAY).floor % 84
91
- moon_days += 84 if moon_days < 0
92
- @moonPercent = - ((42 - moon_days).to_f / 42 * 100).round
93
- end
94
- def to_i
95
- @moonPercent
96
- end
97
- def to_s
98
- if (@moonPercent == -100)
99
- "100% Full Moon"
100
- elsif (@moonPercent == 0)
101
- "0% New Moon"
102
- elsif (@moonPercent < 0)
103
- "#{-@moonPercent}% Waning"
104
- elsif (@moonPercent > 0)
105
- "#{@moonPercent}% Waxing"
106
- end
107
- end
108
- end
109
-
110
- def moon_phase
111
- @vMoon ||= VanaMoon.new(@earth_time)
112
- end
113
-
114
- def self.now
115
- self.new
116
- end
117
-
118
- def to_s
119
- "Vanadiel Time: #{day} #{year}-#{month}-#{date}" +
120
- " #{hour}:#{minute}:#{second}" + "\n" + "Moon Phase: #{moon_phase}" +
121
- "\n" + "Earth Time: #{earth_time.httpdate}"
122
- end
123
-
124
- end
3
+ require 'Vana/constants'
4
+ require 'Vana/day'
5
+ require 'Vana/moon'
6
+ require 'Vana/time'
metadata CHANGED
@@ -3,13 +3,13 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: VanaTime
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2007-08-22 00:00:00 -04:00
8
- summary: Vanadiel time object
6
+ version: 1.1.0
7
+ date: 2007-08-30 00:00:00 -04:00
8
+ summary: A library for converting realtime to vanadiel time
9
9
  require_paths:
10
10
  - lib
11
11
  email: ttilley@gmail.com
12
- homepage: http://vanatime.rubyforge.org
12
+ homepage: http://vanatime.rubyforge.org/
13
13
  rubyforge_project: vanatime
14
14
  description: A library for converting realtime to vanadiel time
15
15
  autorequire:
@@ -29,39 +29,27 @@ post_install_message:
29
29
  authors:
30
30
  - Travis Tilley
31
31
  files:
32
- - History.txt
33
- - Manifest.txt
34
- - README.txt
35
- - Rakefile
32
+ - README
33
+ - Manifest
34
+ - LICENSE
36
35
  - lib/vana_time.rb
37
- - spec
38
- - spec/spec.opts
39
- - spec/spec_helper.rb
40
- - spec/vana_time_spec.rb
41
- - tasks
42
- - tasks/rspec.rake
36
+ - lib/Vana/time.rb
37
+ - lib/Vana/moon.rb
38
+ - lib/Vana/day.rb
39
+ - lib/Vana/constants.rb
40
+ - CHANGELOG
41
+ - VanaTime.gemspec
43
42
  test_files: []
44
43
 
45
- rdoc_options:
46
- - --main
47
- - README.txt
48
- extra_rdoc_files:
49
- - History.txt
50
- - Manifest.txt
51
- - README.txt
44
+ rdoc_options: []
45
+
46
+ extra_rdoc_files: []
47
+
52
48
  executables: []
53
49
 
54
50
  extensions: []
55
51
 
56
52
  requirements: []
57
53
 
58
- dependencies:
59
- - !ruby/object:Gem::Dependency
60
- name: hoe
61
- version_requirement:
62
- version_requirements: !ruby/object:Gem::Version::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 1.3.0
67
- version:
54
+ dependencies: []
55
+
data/History.txt DELETED
@@ -1,5 +0,0 @@
1
- == 1.0.0 / 2007-08-20
2
-
3
- * 1 major enhancement
4
- * Birthday! Yes, I seriously kept the default history entry.
5
-
data/Manifest.txt DELETED
@@ -1,11 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- lib/vana_time.rb
6
- spec
7
- spec/spec.opts
8
- spec/spec_helper.rb
9
- spec/vana_time_spec.rb
10
- tasks
11
- tasks/rspec.rake
data/README.txt DELETED
@@ -1,3 +0,0 @@
1
- This file is required. Like W.T.F. mate.
2
- Seriously though, I fail at documentation. The spec should be pretty descriptive about the
3
- interface to the library.
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
5
- require './lib/vana_time.rb'
6
-
7
- Hoe.new('VanaTime', VanaTime::VERSION) do |p|
8
- p.rubyforge_name = 'vanatime'
9
- p.author = 'Travis Tilley'
10
- p.email = 'ttilley@gmail.com'
11
- p.summary = 'Vanadiel time object'
12
- # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
- p.description = "A library for converting realtime to vanadiel time"
14
- # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
15
- p.url = "http://vanatime.rubyforge.org"
16
- p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
17
- end
18
-
19
- Dir['tasks/**/*.rake'].each { |rake| load rake }
20
-
21
- # vim: syntax=Ruby
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --colour
data/spec/spec_helper.rb DELETED
@@ -1,9 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- gem 'rspec'
6
- require 'spec'
7
- end
8
-
9
- require File.dirname(__FILE__) + '/../lib/vana_time.rb'
@@ -1,86 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe VanaTime do
4
- before(:all) do
5
- # this specific date translates to: seconds since vana epoch date ->
6
- # 32009656750, vana year -> 1029, vana month -> 2, vana date -> 13, vana day
7
- # of the week -> 2 (base 0) or Watersday, vana minute -> 19, vana hour -> 3,
8
- # vana second -> 10, vana moon phase -> 62% waxing
9
- @time = Time.utc(2007,8,23,12,15,10,10)
10
- @vanatime = VanaTime.new(@time)
11
- end
12
-
13
- it "should raise an error when given invalid input" do
14
- lambda {VanaTime.new("COWS")}.should raise_error
15
- end
16
-
17
- it "should provide an accessor for the earth time used to create the object" do
18
- @vanatime.earth_time.should == @time
19
- @vanatime.earth_time.class.should == Time
20
- end
21
-
22
- it "should use the current time if not initialized with a specific time" do
23
- def Time.now
24
- Time.utc(2007,8,23,12,15,10,10)
25
- end
26
- vanatime = VanaTime.new
27
- vanatime.earth_time.should == Time.utc(2007,8,23,12,15,10,10)
28
- end
29
-
30
- it "to_i should return the vana time used in all other calculations as an int" do
31
- @vanatime.to_i.is_a?(Integer).should == true
32
- @vanatime.to_i.should == 32009656750
33
- end
34
-
35
- it "should provide accessor for vana year" do
36
- @vanatime.year.to_i.should == 1029
37
- end
38
-
39
- it "should provide accessor for vana month" do
40
- @vanatime.month.to_i.should == 2
41
- end
42
-
43
- it "should provide accessor for vana date" do
44
- @vanatime.date.to_i.should == 13
45
- end
46
-
47
- it "should provide accessor for vana hour" do
48
- @vanatime.hour.to_i.should == 3
49
- end
50
-
51
- it "should provide accessor for vana minute" do
52
- @vanatime.minute.to_i.should == 19
53
- end
54
-
55
- it "should provide accessor for vana second" do
56
- @vanatime.second.to_i.should == 10
57
- end
58
-
59
- it "should provide accessor for day of week" do
60
- @vanatime.day.to_s.should == "Watersday"
61
- end
62
-
63
- it "should provide accessor for moon percent/phase" do
64
- @vanatime.moon_phase.to_s.should == "62% Waxing"
65
- @vanatime.moon_phase.to_i.should == 62
66
- end
67
-
68
- it "should allow reinitializing with a new earth time" do
69
- vt = VanaTime.new(Time.utc(2007,8,23,12,15,10,10))
70
- vtsec = vt.to_i
71
- vanatwo = vt.earth_time=(Time.new)
72
- vtwosec = vanatwo.to_i
73
- vtsec.should_not == vtwosec
74
- end
75
-
76
- it "should allow reinitializing with a new vana time" do
77
- reinit = VanaTime.new
78
- reinit.vana_time = (@vanatime.to_i)
79
- reinit.earth_time.to_i.should_not == @vanatime.to_i
80
- end
81
-
82
- it "should have a constructor using vana time" do
83
- vt = VanaTime.at(@vanatime.to_i)
84
- vt.earth_time.to_i.should == @vanatime.earth_time.to_i
85
- end
86
- end
data/tasks/rspec.rake DELETED
@@ -1,21 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems'
5
- require 'spec'
6
- end
7
- begin
8
- require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
16
-
17
- desc "Run the specs under spec/models"
18
- Spec::Rake::SpecTask.new do |t|
19
- t.spec_opts = ['--options', "spec/spec.opts"]
20
- t.spec_files = FileList['spec/*_spec.rb']
21
- end