creative_rails_utilities 0.4.3 → 0.4.4

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
  SHA1:
3
- metadata.gz: 05cb9d231a2ce10ff623f11bfb2c279e509bf1c3
4
- data.tar.gz: e420b4d185fb32b3567dfd704ba161e7401deae1
3
+ metadata.gz: da8068ff68669af009b9d001ca3309828b2738f6
4
+ data.tar.gz: 05ce3d57ff7b16fd5d725cf93910c60b72a1079d
5
5
  SHA512:
6
- metadata.gz: 25e3bef44073c8256869afff81c3e146460706f3aee318c5241592ae6b04c4300babb77a14bc57be360f031185b356b796134aee370a8f6eb07ab2de3f9ba44a
7
- data.tar.gz: 9cd6e337b76da4aff9333ac3095b421bd9ea3eca92fee610f485ea2ea7ee385d6f417dc1d2323d1c83d31bdd6efc51a024bd841f487c348eff65856b5167af48
6
+ metadata.gz: a215145db575639703d62321060a8996d5d9e82ce1a8875bc3a230192fb1de281fcd36fc259bf29383846226107c4c274148e5595835fbc34f335e4f59e0630a
7
+ data.tar.gz: cc0f9c257f44d171405902ddaa4d90b9a2db40e87c2ea15cdfb73609e8fdd1af3209a8f80c45849ea01d31e77ee67fa5828a6aa826389393dd4076a31af9bc44
data/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
8
8
  -
9
9
  ```
10
10
 
11
+ ## [0.4.4] - 2016-07-18
12
+ ### Added
13
+ - URI#build
14
+
11
15
  ## [0.4.3] - 2016-07-13
12
16
  ### Added
13
17
  - Array#histogram
data/README.md CHANGED
@@ -22,7 +22,7 @@ Feel free to read the source under `/lib/creative_rails_utilities/` and peruse t
22
22
 
23
23
  ```ruby
24
24
  # Array#by_popularity # returns a semi-histogram array of unique elements sorted by most numerous element first
25
- %i|c a b a a b|.histogram
25
+ %i|c a b a a b|.by_popularity
26
26
  # => [:a, :b, :c]}
27
27
  ```
28
28
 
@@ -126,7 +126,7 @@ __Object.chain_if(switch, operator, *args)__
126
126
  __Object#chain_if(switch, operator, *args)__
127
127
  ```rb
128
128
  # Allows smart conditional chaining of method calls or Procs
129
- # Works on any type of object, class or instance
129
+ # Works on Object and its descendants, class or instance
130
130
 
131
131
  String.chain_if(true, :new, "abc") #=> "abc"
132
132
  String.chain_if(false, :new, "abc") #=> String
@@ -173,6 +173,20 @@ string #=> "1..." instead of " 1..."
173
173
  "y".to_bool #=> true
174
174
  ```
175
175
 
176
+ ##### URI
177
+
178
+ ```ruby
179
+ # URI#build(scheme: "http", domain:, path: "/", query: "", fragment: "") # builds an uri from components
180
+ URI.build(domain: "www.example.com")
181
+ #=> "http://www.example.com/"
182
+
183
+ URI.build(scheme: "https", domain: "example.com", path: "/some/path", query: "test=true&fake=false", fragment: "#fragment")
184
+ #=> "https://example.com/some/path?test=true&fake=false#fragment"
185
+
186
+ URI.build(scheme: "https", domain: "example.com", path: "/some/path", query: {test: "true", fake: false})
187
+ #=> "https://example.com/some/path?fake=false&test=true"
188
+ ```
189
+
176
190
  #### View Helpers
177
191
  Rails-only (via railtie) view helpers have been added, they are automagically loaded and usable upon gem inclusion.
178
192
 
@@ -0,0 +1,14 @@
1
+ module URI
2
+ def build(scheme: "http", domain:, path: "/", query: "", fragment: "")
3
+ if !query.is_a?(String)
4
+ query = query.to_query # handles non-string argument, a Hash, for example
5
+ end
6
+
7
+ query = query.present? ? "?#{query.gsub(/\A\?/, "")}" : ""
8
+ fragment = fragment.present? ? "##{fragment.gsub(/\A\#/, "")}" : ""
9
+
10
+ return "#{scheme}://#{domain}#{path}#{query}#{fragment}"
11
+ end
12
+
13
+ module_function :build
14
+ end
@@ -1,3 +1,3 @@
1
1
  module CreativeRailsUtilities
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -12,6 +12,7 @@ require "creative_rails_utilities/hash"
12
12
  require "creative_rails_utilities/numeric"
13
13
  require "creative_rails_utilities/object"
14
14
  require "creative_rails_utilities/string"
15
+ require "creative_rails_utilities/uri"
15
16
  require "creative_rails_utilities/version"
16
17
 
17
18
  require 'creative_rails_utilities/railtie' if defined?(Rails)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creative_rails_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Creative
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -179,6 +179,7 @@ files:
179
179
  - lib/creative_rails_utilities/object.rb
180
180
  - lib/creative_rails_utilities/railtie.rb
181
181
  - lib/creative_rails_utilities/string.rb
182
+ - lib/creative_rails_utilities/uri.rb
182
183
  - lib/creative_rails_utilities/version.rb
183
184
  - lib/creative_rails_utilities/view_helpers.rb
184
185
  homepage: https://github.com/CreativePublisher/creative_rails_utilities