ur 0.2.4 → 0.2.5

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: b856342339ad2804ef44731304ee8ecc7801bf090ce019d00751bb8b491df4ff
4
- data.tar.gz: 75095d90b5e6e4ebff5020fff905a2b52348be06aa2495b8dfe79c730f6e8cc0
3
+ metadata.gz: 8a9b51f120da021be44f14991d4dc1d726fb58b5b70a4bd595ad29ca8af12fff
4
+ data.tar.gz: 373234337bf222a869de55a7bf5bd9ccda0ccf54b469e109832f6962856937ea
5
5
  SHA512:
6
- metadata.gz: 5934007c613d667498a52cc36238b9d7ff378381945a4d1fceaeb87f4be73cf93af4336701a4a076aea8c1e47de377ada03071a6e0cb52ebf30764bcfd1d1dd5
7
- data.tar.gz: b6a86b4deac6c7d452aaa46bd828d4695ef954bf085a94d0d86bcbf290e4dcc9759a31eb7b726471f09c8999981a3e455349e07be062411762e3899de6c344a2
6
+ metadata.gz: 916a05043d591e85b189b364550eca8944302a88b35402d8f46b1a588489cd756039e3dc226c2f3940aa77116d6f3669481f74c9bf620c11766a3dbc09f4ca7e
7
+ data.tar.gz: a6e10766c94d53c3c8a2f87e7d2b911f808cb1ee32a04732e8058c98822a8674b5e1bcd7471f83102a642bc3d5a5767f4e4263b68fe0257d10d7fd04b32bb009
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.2.5
2
+
3
+ - Request and Response #links
4
+ - JSI ~> v0.8.1
5
+
1
6
  # v0.2.4
2
7
 
3
8
  - JSI = v0.8.0
@@ -41,6 +41,14 @@ module Ur
41
41
  content_type ? content_type.media_type : nil
42
42
  end
43
43
 
44
+ # @return [Enumerable<Weblink>]
45
+ def links
46
+ headers.each do |k, v|
47
+ return(Weblink.parse_link_value(v, ur.request.uri)) if k =~ /\Alink\z/i
48
+ end
49
+ [].freeze
50
+ end
51
+
44
52
  # is our content type JSON?
45
53
  # @return [Boolean]
46
54
  def json?
data/lib/ur/version.rb CHANGED
@@ -1 +1 @@
1
- UR_VERSION = "0.2.4".freeze
1
+ UR_VERSION = "0.2.5".freeze
data/lib/ur/weblink.rb CHANGED
@@ -46,24 +46,25 @@ module Ur
46
46
  while !ss.eos?
47
47
  # get the target_uri, within some angle brackets
48
48
  ss.scan(/\s*<([^>]+)>/) || parse_fail.call
49
- target_uri = ss[1]
49
+ target_uri = JSI::Util.uri(ss[1].freeze)
50
50
  attributes = {}
51
51
  while ss.scan(ATTRIBUTE_PAIR)
52
- attributes[ss[1]] = ss[2] || ss[3]
52
+ attributes[ss[1].freeze] = (ss[2] || ss[3]).freeze
53
53
  end
54
- links << new(target_uri, attributes, context_uri)
54
+ links << new(target_uri, attributes.freeze, context_uri)
55
55
  unless ss.eos?
56
56
  # either the string ends or has a comma followed by another link
57
57
  ss.scan(/\s*,\s*/) || parse_fail.call
58
58
  end
59
59
  end
60
- links
60
+ links.freeze
61
61
  end
62
62
 
63
63
  def initialize(target_uri, attributes, context_uri=nil)
64
- @target_uri = to_addressable_uri(target_uri)
64
+ @target_uri = JSI::Util.uri(target_uri)
65
65
  @attributes = attributes
66
- @context_uri = to_addressable_uri(context_uri)
66
+ @context_uri = JSI::Util.uri(context_uri)
67
+ freeze
67
68
  end
68
69
 
69
70
  # the context uri of the link, as an Addressable URI. this URI must be absolute, and the target_uri
@@ -117,11 +118,16 @@ module Ur
117
118
  "<#{target_uri}>" + attributes.map { |k,v| %Q(; #{k}="#{v}") }.join('')
118
119
  end
119
120
 
120
- private
121
+ include(JSI::Util::Private::FingerprintHash::Immutable)
121
122
 
122
- # if uri is nil, returns nil; otherwise, tries to return a Addressable::URI
123
- def to_addressable_uri(uri)
124
- uri.nil? || uri.is_a?(Addressable::URI) ? uri : Addressable::URI.parse(uri)
123
+ # @private
124
+ def jsi_fingerprint
125
+ {
126
+ class: Weblink,
127
+ target_uri: @target_uri,
128
+ attributes: @attributes,
129
+ context_uri: @context_uri,
130
+ }.freeze
125
131
  end
126
132
  end
127
133
  end
data/lib/ur.rb CHANGED
@@ -96,7 +96,7 @@ module Ur
96
96
 
97
97
  # Ur#logger_tags applies tags from a tagged logger to this ur's metadata.
98
98
  # note: ur does not log anything and this logger is not stored.
99
- # @param [logger] a tagged logger
99
+ # @param logger a tagged logger
100
100
  # @return [void]
101
101
  def logger_tags(logger)
102
102
  if logger && logger.formatter.respond_to?(:current_tags)
data/ur.gemspec CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency "jsi", "= 0.8.0"
26
+ spec.add_dependency "jsi", "~> 0.8.1"
27
27
  spec.add_dependency "addressable", "~> 2.0"
28
28
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ur
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
11
+ date: 2024-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.0
19
+ version: 0.8.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.0
26
+ version: 0.8.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement