akatosh_bot 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +2 -0
- data/akatosh_bot.gemspec +30 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/lib/akatosh_bot.rb +53 -0
- data/lib/akatosh_bot/version.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 37e91a14c5f54eafde785407c1755886542708e6
|
4
|
+
data.tar.gz: c21911cba4d26ce6909713134fb1319a1e091ad2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb20375ab9f23bdaf6dfefafc6698279a3d1d64a7e4ea4c4949bc24965d1d6e29613393b06c26e95196f587df303084ec38fe8d261f9c32355a4d6238af4f729
|
7
|
+
data.tar.gz: 20649c2e63e02f1433dcd9717e590d6df0d0155411c174bacb4bbaaaeac568aabda34e1d37f03f77c41a34eeff1ab961fa42f7d4e3cf910d98b44607b14693ca
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 myrrlyn
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# AkatoshBot
|
2
|
+
|
3
|
+
AkatoshBot provides a mechanism for translating Earthly `Time` objects into
|
4
|
+
their corresponding Tamrielic name. It only emits the calendar half of the name,
|
5
|
+
as we know nothing about Tamrielic clocks at this time.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'akatosh_bot'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install akatosh_bot
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
In your project, make an instance of `Time` and call `tamriel` on it. `tamriel`
|
26
|
+
supports two options in an implicit hash, `year` and `era`.
|
27
|
+
|
28
|
+
The `year` option has multiple allowed possibilities.
|
29
|
+
- string: the given string is printed verbatim as the year
|
30
|
+
- integer: the year is printed as `"4E#{year}"`
|
31
|
+
- Boolean: prints or suppresses the calculated year
|
32
|
+
|
33
|
+
The `era` option alters the era prefix of the year. It currently defaults to 4.
|
34
|
+
If `year` is a string, `era` is ignored.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
t = Time.now
|
38
|
+
puts t.tamriel
|
39
|
+
puts t.tamriel year: true
|
40
|
+
puts t.tamriel year: true, era: 3
|
41
|
+
|
42
|
+
t = Time.new 2011, 11, 11
|
43
|
+
puts t.tamriel #=> Fredas, 11th of Sun's Dusk
|
44
|
+
puts t.tamriel year: true #=> Fredas, 11th of Sun's Dusk, 4E201
|
45
|
+
puts t.tamriel year: "Dawn Era" #=> Fredas, 11th of Sun's Dusk, Dawn Era
|
46
|
+
puts t.tamriel era: 3, year: 327 #=> Fredas, 11th of Sun's Dusk, 3E327
|
47
|
+
```
|
48
|
+
|
49
|
+
To test the only dicey part, open a REPL and then run this snippet:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
(1..31).each do |d|
|
53
|
+
# Taken from akatosh_bot.rb:20
|
54
|
+
puts "#{d}#{%w[th st nd rd][d / 10 != 1 && d % 10 < 4 ? d % 10 : 0]}"
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
It should emit the proper ordinals of all 31 days, with 'st' for 1, 21, and 31;
|
59
|
+
'nd' for 2 and 22; 'rd' for 3 and 23, and 'th' for everything else.
|
60
|
+
|
61
|
+
## Development
|
62
|
+
|
63
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
64
|
+
|
65
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/myrrlyn/akatosh_bot.
|
70
|
+
|
71
|
+
|
72
|
+
## License
|
73
|
+
|
74
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/akatosh_bot.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'akatosh_bot/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "akatosh_bot"
|
8
|
+
spec.version = AkatoshBot::VERSION
|
9
|
+
spec.authors = ["myrrlyn"]
|
10
|
+
spec.email = ["myrrlyn@outlook.com"]
|
11
|
+
|
12
|
+
spec.summary = <<-EOS
|
13
|
+
Prints a UTC date in Tamrielic time, according to the latest main-series game.
|
14
|
+
EOS
|
15
|
+
spec.description = <<-EOS
|
16
|
+
Adds a method `self.tamriel` to the Time module that translates Time objects
|
17
|
+
into their corresponding name in the Tamrielic calendar.
|
18
|
+
EOS
|
19
|
+
spec.homepage = "https://rubygems.org/gems/akatosh_bot"
|
20
|
+
spec.license = "MIT"
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "pry"
|
30
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/akatosh_bot.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "akatosh_bot/version"
|
2
|
+
|
3
|
+
module AkatoshBot
|
4
|
+
module Time
|
5
|
+
def tamriel opts = {}
|
6
|
+
d = mday
|
7
|
+
e = opts[:era].is_a?(Fixnum) ? opts[:era] : 4
|
8
|
+
i = opts[:year]
|
9
|
+
m = month
|
10
|
+
w = wday
|
11
|
+
y = year
|
12
|
+
# Time.wday is (0..7)
|
13
|
+
tam_wday = %w[
|
14
|
+
Sundas
|
15
|
+
Morndas
|
16
|
+
Tirdas
|
17
|
+
Middas
|
18
|
+
Turdas
|
19
|
+
Fredas
|
20
|
+
Loredas
|
21
|
+
][w]
|
22
|
+
datesuf = %w[th st nd rd][d / 10 != 1 && d % 10 < 4 ? d % 10 : 0]
|
23
|
+
# Time.month is (1..12)
|
24
|
+
tam_month = [
|
25
|
+
"Morning Star",
|
26
|
+
"Sun's Dawn",
|
27
|
+
"First Seed",
|
28
|
+
"Rain's Hand",
|
29
|
+
"Second Seed",
|
30
|
+
"Midyear",
|
31
|
+
"Sun's Height",
|
32
|
+
"Last Seed",
|
33
|
+
"Hearthfire",
|
34
|
+
"Frostfall",
|
35
|
+
"Sun's Dusk",
|
36
|
+
"Evening Star"
|
37
|
+
][m - 1]
|
38
|
+
# If passed a string, print it verbatim
|
39
|
+
# Elsif passed a number, print it in the current (4th) era
|
40
|
+
# Elsif passed a boolean, use it to determine whether to print the year
|
41
|
+
tam_year = i.is_a?(String) ? ", #{i}" : i ? ", #{e}E#{i.is_a?(Fixnum) ? i : y - 1810}" : ""
|
42
|
+
"#{tam_wday}, #{d}#{datesuf} of #{tam_month}#{tam_year}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.tamriel time = self.utc, opts = {}
|
46
|
+
time.tamriel opts
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Include the contents of our Time module in the stdlib's, so that it can be
|
51
|
+
# accessed simply with Time#tamriel
|
52
|
+
::Time.include Time
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: akatosh_bot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- myrrlyn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: |
|
56
|
+
Adds a method `self.tamriel` to the Time module that translates Time objects
|
57
|
+
into their corresponding name in the Tamrielic calendar.
|
58
|
+
email:
|
59
|
+
- myrrlyn@outlook.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- akatosh_bot.gemspec
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/akatosh_bot.rb
|
73
|
+
- lib/akatosh_bot/version.rb
|
74
|
+
homepage: https://rubygems.org/gems/akatosh_bot
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.5.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Prints a UTC date in Tamrielic time, according to the latest main-series
|
98
|
+
game.
|
99
|
+
test_files: []
|