warpera 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: bb63ab53e7a723de27ebc92922ed97714743f5f88efdb9029205e8e427685e63
4
- data.tar.gz: c52696cd125809c16a44e58ea6d3df5305a05d4bbdbfa590044d340268cf541b
3
+ metadata.gz: 3643b139db3291db0a36370efa57df460986450bed4d9d143382b09e688d6ee9
4
+ data.tar.gz: 683c91b283a64db1987e0c577edfb01ca3c58cfd25573d3a6bb08541ef69d66a
5
5
  SHA512:
6
- metadata.gz: a982e9ee134b423f4e7c0ef83b0bb0b94b09191eb03fca07e42f9c7a5acd58bd5e675209dd265deec5d4f60878f5a4d074c0eb483f2e44725d01f0df6c660d68
7
- data.tar.gz: bd6e03933665aba14fc5926b6c5f5bfe13a32095f50e1edf32762511c85d4b824194fbd4d2f24e78189078f3e1145c44a9f94838b561ae012c982c54c7a05b20
6
+ metadata.gz: 5925947fbfd8375aec03e94b13c00dbcd3bfd99847e645b808f30ff64f370ca2fb0c0dabdf9ba838ed61c49b473510e215764ace1799ee9fe452a6e6d9871fcd
7
+ data.tar.gz: 42f8865e9650da9946ad1c9d66873ba2e8baca233f0d5bd49fb453744cc047c7c25a6c7692c0e747060062d9e89cd3aef247ac3ece9242b3a2c7ac2e50cecf2a
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in erasmus.gemspec
4
4
  gemspec
5
-
6
- gem 'fivemat'
data/README.md CHANGED
@@ -1,15 +1,13 @@
1
- # Erasmus
1
+ # Warpera
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/erasmus`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ A gem that makes working with years in different eras palatable
6
4
 
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
10
8
 
11
9
  ```ruby
12
- gem 'erasmus'
10
+ gem 'warpera'
13
11
  ```
14
12
 
15
13
  And then execute:
@@ -18,22 +16,45 @@ And then execute:
18
16
 
19
17
  Or install it yourself as:
20
18
 
21
- $ gem install erasmus
19
+ $ gem install warpera
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ Require the gem in your files with:
24
+
25
+ ```ruby
26
+ require 'warpera'
27
+ ```
28
+
29
+ When working directly with the numbers and strings, use the `conv_s` and
30
+ `conv_i` methods.
31
+
32
+ When needing control over the year and era, use the `Warpera::Pair` class. This
33
+ is helpful, for instance, dealing with storing a year in a database. Instead of
34
+ potentially storing two fields for one attribute, use this to store one field
35
+ for the one attribute.
26
36
 
27
37
  ## Development
28
38
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
40
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
41
+ prompt that will allow you to experiment.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`. To
44
+ release a new version, update the version number in `version.rb`, and then run
45
+ `bundle exec rake release`, which will create a git tag for the version, push
46
+ git commits and tags, and push the `.gem` file to [rubygems.org][1].
30
47
 
31
- 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).
48
+ [1]: rubygems.org/gems/warpera
32
49
 
33
50
  ## Contributing
34
51
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/erasmus.
52
+ Bug reports and pull requests are welcome on [the GitHub repo][2].
53
+
54
+ [2]: https://github.com/parmort/warpera
36
55
 
37
56
  ## License
38
57
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
58
+ The gem is available as open source under the terms of the [MIT License][3]
59
+
60
+ [3]: https://opensource.org/licenses/MIT.
data/lib/warpera/pair.rb CHANGED
@@ -1,7 +1,20 @@
1
1
  module Warpera
2
+ # Pairs year and era together for better readability and DRYing
2
3
  class Pair
3
- attr_accessor :year, :era
4
4
 
5
+ # The year as a whole number
6
+ # @return [Integer] the year
7
+ attr_accessor :year
8
+
9
+ # The era
10
+ # @return [:ce, :bce]
11
+ attr_accessor :era
12
+
13
+ ##
14
+ # Sets the attributes
15
+ #
16
+ # @param year [Integer] the year
17
+ # @param era [:ce, :bce] the era
5
18
  def initialize(year:, era:)
6
19
  @year = year
7
20
  @era = era
@@ -10,10 +23,32 @@ module Warpera
10
23
  raise ArgumentError, 'Era is not valid' unless valid_era?
11
24
  end
12
25
 
26
+ ##
27
+ # Format the year and era into a string
28
+ #
29
+ # @example Current Era
30
+ # >> Warpera::Pair.new(year: 2019, era: :ce).to_s
31
+ # => "2019 CE"
32
+ # @example Previous Era
33
+ # >> Warpera::Pair.new(year: 2019, era: :bce).to_s
34
+ # => "2019 BCE"
35
+ #
36
+ # @return [String] the formatted year
13
37
  def to_s
14
38
  "#{@year} #{@era.upcase}"
15
39
  end
16
40
 
41
+ ##
42
+ # Format the year and era into an integer
43
+ #
44
+ # @example Current Era
45
+ # >> Warpera::Pair.new(year: 2019, era: :ce).to_s
46
+ # => 2019
47
+ # @example Previous Era
48
+ # >> Warpera::Pair.new(year: 2019, era: :bce).to_s
49
+ # => -2019
50
+ #
51
+ # @return [Integer] the formatted year
17
52
  def to_i
18
53
  if @era == :bce
19
54
  return -1 * @year
@@ -1,3 +1,3 @@
1
1
  module Warpera
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/warpera.rb CHANGED
@@ -1,8 +1,14 @@
1
+ # Deals with years possibly spanning different eras
1
2
  module Warpera
2
3
  require 'warpera/pair'
3
4
 
5
+ ##
6
+ # Convert an integer-formatted year into a string-formatted year
7
+ #
8
+ # @param year [Integer] the integer-formatted year
9
+ # @return [String] the string-formatted year
4
10
  def self.conv_s(year)
5
- raise ArgumentError, 'Argument is not numeric' unless year.is_a? Numeric
11
+ raise ArgumentError, 'Argument is not an integer' unless year.is_a? Integer
6
12
 
7
13
  if year < 0
8
14
  "#{-1 * year} BCE"
@@ -11,6 +17,11 @@ module Warpera
11
17
  end
12
18
  end
13
19
 
20
+ ##
21
+ # Convert a string-formatted year into an integer-formatted year
22
+ #
23
+ # @param year [String] the string-formatted year
24
+ # @return [Integer] the integer-formatted year
14
25
  def self.conv_i(year)
15
26
  raise ArgumentError, 'Argument is not a string' unless year.is_a? String
16
27
 
data/warpera.gemspec CHANGED
@@ -2,26 +2,39 @@ lib = File.expand_path("../lib", __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require "warpera/version"
4
4
 
5
- Gem::Specification.new do |spec|
6
- spec.name = "warpera"
7
- spec.version = Warpera::VERSION
8
- spec.authors = ["Nolan Prochnau"]
9
- spec.email = ["parvus.mortalis@gmail.com"]
5
+ module GemSpec
6
+ def self.load_git_files
7
+ Dir.chdir(File.expand_path('..', __FILE__)) do
8
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
9
+ end
10
+ end
11
+ end
10
12
 
11
- spec.summary = "A gem that makes working with years in different eras palatable"
12
- spec.homepage = "https://github.com/parmort/warpera"
13
- spec.license = "MIT"
13
+ Gem::Specification.new do |s|
14
+ s.name = "warpera"
15
+ s.version = Warpera::VERSION
16
+ s.author = "Nolan Prochnau"
17
+ s.email = ["parvus.mortalis@gmail.com"]
18
+ s.summary = "A gem that makes working with years in different eras palatable"
19
+ s.homepage = "https://github.com/parmort/warpera"
20
+ s.license = "MIT"
21
+ s.files = GemSpec.load_git_files
22
+ s.bindir = "exe"
23
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ s.required_ruby_version = '~> 2'
26
+ s.extra_rdoc_files = ['README.md']
14
27
 
15
- # Specify which files should be added to the gem when it is released.
16
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- end
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
28
+ s.metadata = {
29
+ "bug_tracker_uri" => "https://github.com/parmort/warpera/issues",
30
+ "changelog_uri" => "https://github.com/parmort/warpera/blob/master/CHANGELOG.md",
31
+ "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1",
32
+ "homepage_uri" => "https://github.com/parmort/warpera",
33
+ "source_code_uri" => "https://github.com/parmort/warpera"
34
+ }
23
35
 
24
- spec.add_development_dependency "bundler", "~> 2.0"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec", "~> 3.0"
36
+ s.add_development_dependency "bundler", "~> 2.0"
37
+ s.add_development_dependency "rake", "~> 10.0"
38
+ s.add_development_dependency "rspec", "~> 3.0"
39
+ s.add_development_dependency "fivemat"
27
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warpera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nolan Prochnau
@@ -52,12 +52,27 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fivemat
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description:
56
70
  email:
57
71
  - parvus.mortalis@gmail.com
58
72
  executables: []
59
73
  extensions: []
60
- extra_rdoc_files: []
74
+ extra_rdoc_files:
75
+ - README.md
61
76
  files:
62
77
  - ".gitignore"
63
78
  - ".rspec"
@@ -81,16 +96,21 @@ files:
81
96
  homepage: https://github.com/parmort/warpera
82
97
  licenses:
83
98
  - MIT
84
- metadata: {}
99
+ metadata:
100
+ bug_tracker_uri: https://github.com/parmort/warpera/issues
101
+ changelog_uri: https://github.com/parmort/warpera/blob/master/CHANGELOG.md
102
+ documentation_uri: https://www.example.info/gems/bestgemever/0.0.1
103
+ homepage_uri: https://github.com/parmort/warpera
104
+ source_code_uri: https://github.com/parmort/warpera
85
105
  post_install_message:
86
106
  rdoc_options: []
87
107
  require_paths:
88
108
  - lib
89
109
  required_ruby_version: !ruby/object:Gem::Requirement
90
110
  requirements:
91
- - - ">="
111
+ - - "~>"
92
112
  - !ruby/object:Gem::Version
93
- version: '0'
113
+ version: '2'
94
114
  required_rubygems_version: !ruby/object:Gem::Requirement
95
115
  requirements:
96
116
  - - ">="