rest_uri 1.0.0 → 1.0.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 +4 -4
- data/lib/rest_uri.rb +6 -4
- data/lib/rest_uri/resource.rb +3 -2
- data/lib/rest_uri/uri.rb +1 -1
- data/lib/rest_uri/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 828358b680f601e05ce0c047dcbd5decbb46d0ea
|
4
|
+
data.tar.gz: 7d5373018ad4cbd47a83cdefb9b615a429dc3fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04145d2dd38291353521bd1fc668b650bc753f8e7ed511a52471d7afe078b6dfb3a6da5ab4d2238aa18280e90e55eb8ced014d88fe6f0f5998ed7ea1ae99ce5e
|
7
|
+
data.tar.gz: 7649686b7a434cd2f5267269c8776f11d802523319da6b10face801b3cf1dfe4d412e55bab9e8e1c0012bb21d6358962233ed4d1bad98b2eb7849ef397d25c48
|
data/lib/rest_uri.rb
CHANGED
@@ -11,6 +11,11 @@ module RestUri
|
|
11
11
|
class Base
|
12
12
|
include Resource
|
13
13
|
attr_accessor :uri, :parser, :identifier
|
14
|
+
|
15
|
+
# @param uri [String, URI]
|
16
|
+
# @param parser [Object] :parser URI parser such as Addressable::URI
|
17
|
+
# @param identifier [Symbol] :identifier Suffix of method name to specify resource
|
18
|
+
# @raise ArgumentError if `identifier` is empty
|
14
19
|
def initialize(uri, parser: DEFAULT_PARSER, identifier: DEFAULT_IDENTIFIER)
|
15
20
|
raise ArgumentError, 'Empty identifier' if not identifier.respond_to? :empty? or identifier.empty?
|
16
21
|
@uri = uri
|
@@ -20,10 +25,7 @@ module RestUri
|
|
20
25
|
end
|
21
26
|
|
22
27
|
# Parse REST URI
|
23
|
-
# @
|
24
|
-
# @param
|
25
|
-
# @option options [Object] :parser URI parser such as Addressable::URI
|
26
|
-
# @option options [Symbol] :identifier Suffix of method name to specify resource
|
28
|
+
# @see RestUri::Base#initialize
|
27
29
|
# @example
|
28
30
|
# require 'addressable/uri'
|
29
31
|
# require 'rest_uri'
|
data/lib/rest_uri/resource.rb
CHANGED
@@ -4,10 +4,11 @@ module RestUri
|
|
4
4
|
module Resource
|
5
5
|
# Take a URI string or URI object and return its ID
|
6
6
|
# @example
|
7
|
-
#
|
8
|
-
#
|
7
|
+
# RestUri::Resource.resource_id('status', https://twitter.com/sferik/status/540897316908331009/')
|
8
|
+
# #=> 540897316908331009
|
9
9
|
# @param name [String] Resource name
|
10
10
|
# @param object [Integer, String, URI] An ID, URI, or object.
|
11
|
+
# @param
|
11
12
|
# @option parser [Integer, String, URI] An ID, URI, or object.
|
12
13
|
# @return [Integer, NilClass]
|
13
14
|
def self.resource_id(name, object, parser: DEFAULT_PARSER)
|
data/lib/rest_uri/uri.rb
CHANGED
@@ -12,7 +12,7 @@ module RestUri
|
|
12
12
|
target.nil? ? target : target.to_i
|
13
13
|
end
|
14
14
|
|
15
|
-
# To support
|
15
|
+
# To support hashbang style URL like http://twitter.com/#!/status/759813164686938117
|
16
16
|
# @param object [URI]
|
17
17
|
# @return [String]
|
18
18
|
def self.hashbang_path_or_path(object)
|
data/lib/rest_uri/version.rb
CHANGED