Skip to content

Commit cf222a7

Browse files
committed
➕ version_gem (extracted from oauth2)
1 parent 4faa233 commit cf222a7

File tree

8 files changed

+26
-13
lines changed

8 files changed

+26
-13
lines changed

CHANGELOG.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Removed
1515

16-
## [0.6.0] 2022-05-04
16+
## [0.6.0] 2022-08-23
1717
### Added
18-
* Made a new option `body_hash_enabled` which defaults to true to maintain backward compatibility with prior releases. Setting to `false` disables generation of a `oauth_body_hash` component as part of the signature computation.
19-
* Improved documentation of support policy
18+
* New option `body_hash_enabled` which defaults to true to maintain backward compatibility with prior releases. Setting to `false` disables generation of a `oauth_body_hash` component as part of the signature computation.
19+
* Improved documentation of support policy via Tidelift
2020
* Stop testing against active_support v2
2121

22+
### Changed
23+
* Utilize version_gem extracted from oauth2 gem for VERSION
24+
* Added new `OAuth::Version` namespace
25+
* VERSION constant now at `OAuth::Version::VERSION`
26+
2227
### Removed
2328
* Ruby 2.0, 2.1, 2.2, and 2.3 are no longer valid install targets
2429

@@ -297,7 +302,7 @@ The "Can it be the end of the line for 0.5.x?" Release
297302

298303
## [0.3.4] 2009-05-06
299304
### Changed
300-
* OAuth::Client::Helper uses OAuth::VERSION (chadisfaction)
305+
* OAuth::Client::Helper uses OAuth::Version::VERSION (chadisfaction)
301306

302307
### Fixed
303308
* Fix OAuth::RequestProxy::ActionControllerRequest's handling of params (Tristan Groléat)

lib/oauth.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

3-
root = File.dirname(__FILE__)
4-
$LOAD_PATH << root unless $LOAD_PATH.include?(root)
3+
# third party gems
4+
require "version_gem"
55

66
require "oauth/version"
77

@@ -13,3 +13,7 @@
1313
require "oauth/signature/hmac/sha256"
1414
require "oauth/signature/rsa/sha1"
1515
require "oauth/request_proxy/mock_request"
16+
17+
OAuth::Version.class_eval do
18+
extend VersionGem::Basic
19+
end

lib/oauth/cli/version_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module OAuth
44
class CLI
55
class VersionCommand < BaseCommand
66
def run
7-
puts "OAuth Gem #{OAuth::VERSION}"
7+
puts "OAuth Gem #{OAuth::Version::VERSION}"
88
end
99
end
1010
end

lib/oauth/client/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def hash_body
7171
end
7272

7373
def amend_user_agent_header(headers)
74-
@oauth_ua_string ||= "OAuth gem v#{OAuth::VERSION}"
74+
@oauth_ua_string ||= "OAuth gem v#{OAuth::Version::VERSION}"
7575
# Net::HTTP in 1.9 appends Ruby
7676
if headers["User-Agent"] && headers["User-Agent"] != "Ruby"
7777
headers["User-Agent"] += " (#{@oauth_ua_string})"

lib/oauth/version.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

33
module OAuth
4-
VERSION = "0.6.0"
4+
module Version
5+
VERSION = "0.6.0"
6+
end
57
end

oauth.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
require_relative "lib/oauth/version"
44

55
Gem::Specification.new do |spec|
6+
spec.add_dependency("version_gem", "~> 1.1")
7+
68
spec.name = "oauth"
7-
spec.version = OAuth::VERSION
9+
spec.version = OAuth::Version::VERSION
810
spec.license = "MIT"
911

1012
spec.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby",

test/units/cli_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_help
6969
def test_version
7070
out = run_command(%w[version])
7171

72-
assert_equal "OAuth Gem #{OAuth::VERSION}\n", out
72+
assert_equal "OAuth Gem #{OAuth::Version::VERSION}\n", out
7373
end
7474

7575
def test_query_empty

test/units/net_http_client_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ def test_that_version_is_added_to_existing_user_agent
9191
request.set_form_data(@request_parameters)
9292
request.oauth!(@http, @consumer, @token, { nonce: @nonce, timestamp: @timestamp })
9393

94-
assert_equal "MyApp (OAuth gem v#{OAuth::VERSION})", request["User-Agent"]
94+
assert_equal "MyApp (OAuth gem v#{OAuth::Version::VERSION})", request["User-Agent"]
9595
end
9696

9797
def test_that_version_is_set_when_no_user_agent
9898
request = Net::HTTP::Post.new(@request_uri.path)
9999
request.set_form_data(@request_parameters)
100100
request.oauth!(@http, @consumer, @token, { nonce: @nonce, timestamp: @timestamp })
101101

102-
assert_equal "OAuth gem v#{OAuth::VERSION}", request["User-Agent"]
102+
assert_equal "OAuth gem v#{OAuth::Version::VERSION}", request["User-Agent"]
103103
end
104104

105105
def test_that_using_get_params_works

0 commit comments

Comments
 (0)