better_uri 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a849e6946f0715f5e7892fa480d9c5c221fe3b50fe0b39b3dd486344154c8801
4
- data.tar.gz: 416b7ca94556d681e140d79d9d5b772df9cf1be89d955b6726262b2c792fb30e
3
+ metadata.gz: e2bb8a8c697b978746fad0952aad89c5eb6bea5282c5c289d8f0ee7e6d19587b
4
+ data.tar.gz: '09758672170aed4fce7560f6e35941e63c93ccc4e29f98290a2fe55c549a18c8'
5
5
  SHA512:
6
- metadata.gz: 3ced0f502e074206efcc64ca625d723d8fe91b57c669ccd9259226ff430d01871ef0a55fccecef9f146492e3385314c0620daac1f793eeb4d94c93bac79d1d58
7
- data.tar.gz: e1fb486d9d91d2144c72c9008f90c9055eb2c71f78678b032afc20bdb97c308096736ae7729e73c619cb730b732cbabc9ede3cbfd4a3b7d4c3be1ff84cf3c1ff
6
+ metadata.gz: 19826450ed37b7baf5c4148293eaadc89fcc7bdadbe36aa423ce2e62772a35a01ad37a2d7638a8d804751414ac0e75ba9022a2ea1eaf783d1b2b704fe10880b9
7
+ data.tar.gz: 0efc84cacb2cd043fe51a290b94e62182102dbc534a1101a7e69420d9684378d5d3eaed658efe202cfa6816ba443cac57b3570d5d00dfb6eb75c3bf55d809e6f
data/README.md CHANGED
@@ -86,3 +86,18 @@ uri.query.except(:two, :three).to_s # https://depay.fi?one=1
86
86
 
87
87
  `except!(keys)` - Removes the given keys from the query of the original uri and returns the uri itself.
88
88
 
89
+
90
+ #### Convert queries to_param & to_query
91
+
92
+ ```ruby
93
+ uri = URI('https://depay.fi?one=1&two=2&three=3')
94
+ uri.query.to_param # one=1&three=3&two=2
95
+ uri.query.to_query # one=1&three=3&two=2
96
+ ```
97
+
98
+ #### Queries as_json
99
+
100
+ ```ruby
101
+ uri = URI('https://depay.fi?one=1&two=2&three=3')
102
+ uri.query.as_json # {"one"=>"1", "three"=>"3", "two"=>"2"}
103
+ ```
@@ -1,11 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rack/utils'
4
+ require 'active_support/concern'
4
5
  require 'active_support/core_ext/hash/indifferent_access'
6
+ require 'active_model/serialization'
7
+ require 'active_model/serializers/json'
5
8
 
6
9
  module BetterUri
7
10
  class Query
8
- delegate :[], :dig, to: :parsed_query
11
+ delegate :[], :dig, :to_param, :to_query, :as_json, to: :parsed_query
9
12
 
10
13
  def initialize(uri)
11
14
  @uri = uri
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BetterUri
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/depayfi/better_uri/graphs/contributors
@@ -10,20 +10,46 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2022-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: activesupport
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - ">="
18
38
  - !ruby/object:Gem::Version
19
- version: '0'
39
+ version: '6'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '7'
20
43
  type: :runtime
21
44
  prerelease: false
22
45
  version_requirements: !ruby/object:Gem::Requirement
23
46
  requirements:
24
47
  - - ">="
25
48
  - !ruby/object:Gem::Version
26
- version: '0'
49
+ version: '6'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '7'
27
53
  - !ruby/object:Gem::Dependency
28
54
  name: rack
29
55
  requirement: !ruby/object:Gem::Requirement