absolutely 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f16f86035665614b32d4fa91b9f87095c567bf62c4905bf08281f9dc06f9b00
4
- data.tar.gz: affcb6d3a59693727e4354cea0d52ff7813332ddd006d1370ab15c8253cfebca
3
+ metadata.gz: 7795781f33ec7faa95aaf0613898d77b0b154bd32afd497a98e35bd2911557ac
4
+ data.tar.gz: aeccbc8532f4eb04ecc9ca3cf55f00a674de774bc6d4a19c00cf278f5d79d973
5
5
  SHA512:
6
- metadata.gz: 43f2451ce53d29070180c5889fdfce3f31c542db7508c0a50d7f4e195deab3a58b14f6bb9b08fca8e6b7e739ff453849561deaded3b543b6b78ae83692a0f397
7
- data.tar.gz: 14411e64c9ca529968c2333b90db9f306a119af0049e3e96ec3c7aee45a25633e57b37c1fd0a4bc3673dbf643f0655bfd62b81025518e010e997150adecb9a2d
6
+ metadata.gz: 560912d16ae79115377345d95351304f019c501da26891e327fa7472e681aedd57441129865b9e851c25c2a1337bb6746b573fa035109437746e2bb4d6fdb00a
7
+ data.tar.gz: c65f10379621cc39973d34b39d58b76fc036d07fbc3aac346ac1d5b3d64732d2fe93c41e8b8a976e962d1f26d52b49d1e4569319cd47cafad45850b3f50e8836
data/.reek.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  detectors:
2
2
  IrresponsibleModule:
3
3
  enabled: false
4
+ TooManyStatements:
5
+ exclude:
6
+ - Absolutely::URI#set_instance_vars
4
7
 
5
8
  exclude_paths:
6
9
  - vendor/
data/.rubocop.yml CHANGED
@@ -2,6 +2,10 @@ require:
2
2
  - rubocop-performance
3
3
  - rubocop-rspec
4
4
 
5
+ Layout/AlignHash:
6
+ EnforcedColonStyle: table
7
+ EnforcedHashRocketStyle: table
8
+
5
9
  Metrics/BlockLength:
6
10
  Exclude:
7
11
  - spec/**/*.rb
@@ -12,6 +16,9 @@ Metrics/LineLength:
12
16
  Naming/RescuedExceptionsVariableName:
13
17
  PreferredName: exception
14
18
 
19
+ Style/Alias:
20
+ EnforcedStyle: prefer_alias_method
21
+
15
22
  Style/Documentation:
16
23
  Enabled: false
17
24
 
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.4.6
4
4
  - 2.5.5
5
- - 2.6.2
5
+ - 2.6.3
6
6
  cache:
7
7
  - bundler
8
8
  before_install:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0 / 2019-05-01
4
+
5
+ - Rename `to_absolute_uri` method to `to_abs` ([d14e33f](https://github.com/jgarber623/absolutely/commit/d14e33f)).
6
+ - Add `inspect` instance method to `Absolutely::URI` ([e4e7e5a](https://github.com/jgarber623/absolutely/commit/e4e7e5a)).
7
+
3
8
  ## 2.0.0 / 2019-04-25
4
9
 
5
10
  - The `URI` class' `base` and `relative` methods are now read-only ([7879f78](https://github.com/jgarber623/absolutely/commit/7879f78)).
data/CONTRIBUTING.md CHANGED
@@ -8,7 +8,7 @@ There are a couple ways you can help improve Absolutely:
8
8
 
9
9
  ## Getting Started
10
10
 
11
- Absolutely is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.2 using [Travis CI](https://travis-ci.com/jgarber623/absolutely).
11
+ Absolutely is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.3 using [Travis CI](https://travis-ci.com/jgarber623/absolutely).
12
12
 
13
13
  Before making changes to Absolutely, you'll want to install Ruby 2.4.6. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm). Once you've installed Ruby 2.4.6 using your method of choice, install the project's gems by running:
14
14
 
data/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  Before installing and using Absolutely, you'll want to have [Ruby](https://www.ruby-lang.org) 2.4 (or newer) installed. It's recommended that you use a Ruby version managment tool like [rbenv](https://github.com/rbenv/rbenv), [chruby](https://github.com/postmodern/chruby), or [rvm](https://github.com/rvm/rvm).
20
20
 
21
- Absolutely is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.2 using [Travis CI](https://travis-ci.com/jgarber623/absolutely).
21
+ Absolutely is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.3 using [Travis CI](https://travis-ci.com/jgarber623/absolutely).
22
22
 
23
23
  ## Installation
24
24
 
@@ -45,9 +45,9 @@ With Absolutely added to your project's `Gemfile` and installed, you may convert
45
45
  ```ruby
46
46
  require 'absolutely'
47
47
 
48
- uri = Absolutely.uri(base: 'https://example.com', relative: '/foo').to_absolute_uri
48
+ uri = Absolutely.uri(base: 'https://example.com', relative: '/foo').to_abs
49
49
 
50
- puts uri # returns String: 'https://example.com/foo'
50
+ puts uri # => String: 'https://example.com/foo'
51
51
  ```
52
52
 
53
53
  This example combines the supplied `base` value (`https://example.com`) and combines it with the supplied `relative` value (`/foo`), returning the string `https://example.com/foo`.
@@ -57,9 +57,9 @@ You may obtain the same results using this slightly shorter version:
57
57
  ```ruby
58
58
  require 'absolutely'
59
59
 
60
- uri = Absolutely.to_absolute_uri(base: 'https://example.com', relative: '/foo')
60
+ uri = Absolutely.to_abs(base: 'https://example.com', relative: '/foo')
61
61
 
62
- puts uri # returns String: 'https://example.com/foo'
62
+ puts uri # => 'https://example.com/foo'
63
63
  ```
64
64
 
65
65
  Note that if the value passed as `relative` is determined to be an absolute URI, Absolutely will return the value of `relative` regardless of the value passed as `base`:
@@ -67,9 +67,9 @@ Note that if the value passed as `relative` is determined to be an absolute URI,
67
67
  ```ruby
68
68
  require 'absolutely'
69
69
 
70
- uri = Absolute.to_absolute_uri(base: 'https://example.com', relative: 'https://example.com/foo')
70
+ uri = Absolute.to_abs(base: 'https://example.com', relative: 'https://example.com/foo')
71
71
 
72
- puts uri # returns String: 'https://example.com/foo'
72
+ puts uri # => 'https://example.com/foo'
73
73
  ```
74
74
 
75
75
  ### Advanced Usage
@@ -81,18 +81,18 @@ require 'absolutely'
81
81
 
82
82
  uri = Absolutely::URI.new(base: 'https://example.com', relative: '/foo')
83
83
 
84
- puts uri # returns Absolutely::URI
84
+ puts uri # => #<Absolutely::URI>
85
85
 
86
- puts uri.base # returns String: 'https://example.com'
87
- puts uri.relative # returns String: '/foo'
86
+ puts uri.base # => 'https://example.com'
87
+ puts uri.relative # => '/foo'
88
88
 
89
- puts uri.base_uri # returns Addressable::URI
90
- puts uri.relative_uri # returns Addressable::URI
89
+ puts uri.base_uri # => #<Addressable::URI URI:https://example.com>
90
+ puts uri.relative_uri # => #<Addressable::URI URI:/foo>
91
91
 
92
- puts uri.to_absolute_uri # returns String: 'https://example.com/foo'
92
+ puts uri.to_abs # => 'https://example.com/foo'
93
93
  ```
94
94
 
95
- The `base_uri` and `relative_uri` methods return instances of `Addressable::URI` for convenience. For more on this class' available methods, see [the Addressable Ruby gem's source code](https://github.com/sporkmonger/addressable).
95
+ For convenience, the `base_uri` and `relative_uri` methods return instances of the `Addressable::URI` class. For more on this class' available methods, see [the Addressable Ruby gem's source code](https://github.com/sporkmonger/addressable).
96
96
 
97
97
  ## Contributing
98
98
 
data/Rakefile CHANGED
@@ -4,8 +4,14 @@ require 'reek/rake/task'
4
4
  require 'rspec/core/rake_task'
5
5
  require 'rubocop/rake_task'
6
6
 
7
- Reek::Rake::Task.new
7
+ Reek::Rake::Task.new do |task|
8
+ task.fail_on_error = false
9
+ end
10
+
8
11
  RSpec::Core::RakeTask.new
9
- RuboCop::RakeTask.new
12
+
13
+ RuboCop::RakeTask.new do |task|
14
+ task.fail_on_error = false
15
+ end
10
16
 
11
17
  task default: [:rubocop, :reek, :spec]
data/absolutely.gemspec CHANGED
@@ -20,10 +20,15 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.require_paths = ['lib']
22
22
 
23
+ spec.metadata = {
24
+ 'bug_tracker_uri' => "#{spec.homepage}/issues",
25
+ 'changelog_uri' => "#{spec.homepage}/blob/v#{spec.version}/CHANGELOG.md"
26
+ }
27
+
23
28
  spec.add_development_dependency 'rake', '~> 12.3'
24
29
  spec.add_development_dependency 'reek', '~> 5.4'
25
30
  spec.add_development_dependency 'rspec', '~> 3.8'
26
- spec.add_development_dependency 'rubocop', '~> 0.67.2'
31
+ spec.add_development_dependency 'rubocop', '~> 0.68.1'
27
32
  spec.add_development_dependency 'rubocop-performance', '~> 1.1'
28
33
  spec.add_development_dependency 'rubocop-rspec', '~> 1.32'
29
34
  spec.add_development_dependency 'simplecov', '~> 0.16.1'
data/lib/absolutely.rb CHANGED
@@ -7,9 +7,10 @@ require 'absolutely/uri'
7
7
 
8
8
  module Absolutely
9
9
  class << self
10
- def to_absolute_uri(base:, relative:)
11
- uri(base: base, relative: relative).to_absolute_uri
10
+ def to_abs(base:, relative:)
11
+ uri(base: base, relative: relative).to_abs
12
12
  end
13
+ alias_method :to_absolute_uri, :to_abs
13
14
 
14
15
  def uri(base:, relative:)
15
16
  URI.new(base: base, relative: relative)
@@ -1,7 +1,7 @@
1
1
  module Absolutely
2
- class Error < StandardError; end
2
+ class AbsolutelyError < StandardError; end
3
3
 
4
- class ArgumentError < Error; end
4
+ class ArgumentError < AbsolutelyError; end
5
5
 
6
- class InvalidURIError < Error; end
6
+ class InvalidURIError < AbsolutelyError; end
7
7
  end
@@ -1,36 +1,39 @@
1
1
  module Absolutely
2
2
  class URI
3
- attr_reader :base, :relative
3
+ attr_reader :base, :base_uri, :relative, :relative_uri
4
4
 
5
5
  def initialize(base:, relative:)
6
6
  raise ArgumentError, "base must be a String (given #{base.class.name})" unless base.is_a?(String)
7
7
  raise ArgumentError, "relative must be a String (given #{relative.class.name})" unless relative.is_a?(String)
8
8
 
9
- @base = base
10
- @relative = relative
11
-
12
- base_uri
13
- relative_uri
14
-
15
- raise ArgumentError, 'base must be an absolute URI (e.g. https://example.com)' unless base_uri.absolute?
16
- rescue Addressable::URI::InvalidURIError => exception
17
- raise InvalidURIError, exception
18
- end
9
+ set_instance_vars(base, relative)
19
10
 
20
- def base_uri
21
- @base_uri ||= Addressable::URI.parse(base)
11
+ raise ArgumentError, 'base must be an absolute URL (e.g. https://example.com)' unless base_uri.absolute?
22
12
  end
23
13
 
24
- def relative_uri
25
- @relative_uri ||= Addressable::URI.parse(relative)
14
+ def inspect
15
+ format("#<#{self.class.name}:%#0x>", object_id)
26
16
  end
27
17
 
28
- def to_absolute_uri
18
+ def to_abs
29
19
  return relative_uri.to_s if relative_uri.absolute?
30
20
 
31
- base_uri.path = '/' if base_uri.path.empty?
21
+ base_uri.path = base_uri.normalized_path
32
22
 
33
23
  (base_uri + relative_uri).to_s
34
24
  end
25
+ alias_method :to_absolute_uri, :to_abs
26
+
27
+ private
28
+
29
+ def set_instance_vars(base, relative)
30
+ @base = base
31
+ @relative = relative
32
+
33
+ @base_uri = Addressable::URI.parse(base)
34
+ @relative_uri = Addressable::URI.parse(relative)
35
+ rescue Addressable::URI::InvalidURIError => exception
36
+ raise InvalidURIError, exception
37
+ end
35
38
  end
36
39
  end
@@ -1,3 +1,3 @@
1
1
  module Absolutely
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: absolutely
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-26 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.67.2
61
+ version: 0.68.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.67.2
68
+ version: 0.68.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-performance
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +166,9 @@ files:
166
166
  homepage: https://github.com/jgarber623/absolutely
167
167
  licenses:
168
168
  - MIT
169
- metadata: {}
169
+ metadata:
170
+ bug_tracker_uri: https://github.com/jgarber623/absolutely/issues
171
+ changelog_uri: https://github.com/jgarber623/absolutely/blob/v2.1.0/CHANGELOG.md
170
172
  post_install_message:
171
173
  rdoc_options: []
172
174
  require_paths: