Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: 0jonjo/calcpace
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v.1.5.0
Choose a base ref
...
head repository: 0jonjo/calcpace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5,1
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Oct 27, 2024

  1. Add new methods to Readme

    0jonjo committed Oct 27, 2024

    Unverified

    The committer email address is not verified.
    Copy the full SHA
    4374c55 View commit details

Commits on Jan 6, 2025

  1. 47 bump gems january 2025 (#48)

    * [47] Bump gems
    
    * [47] Update the calcpace.gemspec infos to version 1.5.1
    0jonjo authored Jan 6, 2025
    Copy the full SHA
    9ac5a4c View commit details
Showing with 37 additions and 30 deletions.
  1. +3 −3 Gemfile
  2. +21 −17 Gemfile.lock
  3. +5 −5 README.md
  4. +4 −4 calcpace.gemspec
  5. +4 −1 lib/calcpace/checker.rb
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ source 'https://rubygems.org'

ruby '3.2.1'

gem 'minitest', '~> 5.14'
gem 'rake', '~> 13.0'
gem 'minitest', '~> 5.25'
gem 'rake', '~> 13.2'
gem 'rake-compiler', '~> 1.0'
gem 'rdoc', '~> 6.2'
gem 'rubocop', '~> 1.66'
gem 'rubocop', '~> 1.69'
38 changes: 21 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -2,48 +2,52 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.7.4)
date (3.4.1)
json (2.9.1)
language_server-protocol (3.17.0.3)
minitest (5.25.1)
minitest (5.25.4)
parallel (1.26.3)
parser (3.3.5.0)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
psych (5.1.2)
psych (5.2.2)
date
stringio
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
rake-compiler (1.2.8)
rake-compiler (1.2.9)
rake
rdoc (6.7.0)
rdoc (6.10.0)
psych (>= 4.0.0)
regexp_parser (2.9.2)
rubocop (1.67.0)
regexp_parser (2.10.0)
rubocop (1.69.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
stringio (3.1.1)
unicode-display_width (2.6.0)
stringio (3.1.2)
unicode-display_width (3.1.3)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)

PLATFORMS
ruby

DEPENDENCIES
minitest (~> 5.14)
rake (~> 13.0)
minitest (~> 5.25)
rake (~> 13.2)
rake-compiler (~> 1.0)
rdoc (~> 6.2)
rubocop (~> 1.66)
rubocop (~> 1.69)

RUBY VERSION
ruby 3.2.1p31
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ converter.convert(1, :m_s_to_mi_h) # => 2.23694
| :km_h_to_mi_h | Kilometers per Hour to Miles per Hour |
| :mi_h_to_km_h | Miles per Hour to Kilometers per Hour |

You can list all the available units using `list` methods:
You can list all the available units [here](/lib/calcpace/converter.rb), or using `list` methods:

```ruby
converter.list_all
@@ -139,12 +139,12 @@ converter.check_time('01:00:00') # => nil

### Errors

If you input an invalid value, the gem will raise a `RuntimeError` with a message explaining the error. For example:
If you input an invalid value, the gem will raise a `ArgumentError` with a message explaining the error. For example:

```ruby
calculate.pace(945, -1) # => It must be a X.X positive number (RuntimeError)
calculate.checked_time('string', 10) # => It must be a XX:XX:XX time (RuntimeError)
converter.check_time('01-00-00') # => It must be a XX:XX:XX time (RuntimeError)
calculate.pace(945, -1) # => It must be a X.X positive number (ArgumentError)
calculate.checked_time('string', 10) # => It must be a XX:XX:XX time (ArgumentError)
converter.check_time('01-00-00') # => It must be a XX:XX:XX time (ArgumentError)
```

## Contributing
8 changes: 4 additions & 4 deletions calcpace.gemspec
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = 'calcpace'
s.version = '1.5.0'
s.version = '1.5.1'
s.summary = 'Calcpace: calculate total, distance, speed, and convert distances and velocity in an easy way.'
s.description = 'It is designed for calculations related to distance, speed and time. The gem also supports conversion to 42 different units of distance and velocity, including metric, nautical and imperial units.'
s.authors = ['Joao Gilberto Saraiva']
@@ -11,11 +11,11 @@ Gem::Specification.new do |s|
'lib/calcpace/converter.rb']
s.test_files = ['test/calcpace/test_calculator.rb', 'test/calcpace/test_checker.rb',
'test/calcpace/test_converter.rb']
s.add_development_dependency 'minitest', '~> 5.14'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'minitest', '~> 5.25'
s.add_development_dependency 'rake', '~> 13.2'
s.add_development_dependency 'rake-compiler', '~> 1.0'
s.add_development_dependency 'rdoc', '~> 6.2'
s.add_development_dependency 'rubocop', '~> 1.66'
s.add_development_dependency 'rubocop', '~> 1.69'
s.required_ruby_version = '>= 2.7.0'
s.post_install_message = "It's time to calculate! Thank you for installing Calcpace."
s.metadata = { 'source_code_uri' => 'https://github.com/0jonjo/calcpace' }
5 changes: 4 additions & 1 deletion lib/calcpace/checker.rb
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@ def check_positive(number)
end

def check_time(time_string)
raise ArgumentError, 'It must be a valid time in the format XX:XX:XX' unless time_string =~ /\A\d{1,2}:\d{2}:\d{2}\z/
return if time_string =~ /\A\d{1,2}:\d{2}:\d{2}\z/

raise ArgumentError,
'It must be a valid time in the format XX:XX:XX'
end
end