frozen-filters 0.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 +7 -0
- data/lib/frozen-filters.rb +49 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b165a0212aff0bea581304fd91dcd2e476f4d4492c2f20a0b1dc121b00942513
|
4
|
+
data.tar.gz: 93e6a6ee246da962eeb235eadfdf2a11579de1bbe5b51538e11cb63315edd885
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 914179ec309c8fdc9f18876f5d17c02f0c242ea2051a05091b133ae79ebc37cf6c4faef7e708b064a6f3d4251f7e18c375822bacd2f5054c297e09456d8bb98e
|
7
|
+
data.tar.gz: a2aed00604fe7531a19cd29776991ade4568f2b8c2e0fb612242517056d8354aa9cc4aefadd159287347b46719dad771d8e078545b447ad2df5b5b94731cd73a
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# uuid: 705d8f39-63cf-4b12-af68-36c2ed42fd34
|
2
|
+
|
3
|
+
# ------------------------------------------------------------------------
|
4
|
+
# Copyright (c) 2018 Alexandre Bento Freire. All rights reserved.
|
5
|
+
# Licensed under the MIT License+uuid License. See License.txt for details
|
6
|
+
# ------------------------------------------------------------------------
|
7
|
+
|
8
|
+
require 'liquid'
|
9
|
+
|
10
|
+
module FrozenFilters
|
11
|
+
|
12
|
+
# Removes the extension part of an url.
|
13
|
+
# e.g. `http://www.example.com/first/second/index?param1=value1¶m2=value2`.
|
14
|
+
def remove_ext(input)
|
15
|
+
input.to_s.gsub(/\.[^\.\?]+(\?[^\?]*)?$/, '\1')
|
16
|
+
end
|
17
|
+
|
18
|
+
# Removes the query string part of an url. e.g. `http://www.example.com/first/second/index.html`.
|
19
|
+
def remove_qs(input)
|
20
|
+
input.to_s.gsub(/\?[^\?]+$/, '')
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns the basename of an url. e.g. `index.html`.
|
24
|
+
def extract_basename(input)
|
25
|
+
input.to_s.gsub(/^.*\/([^\/\?]+).*$/, '\1')
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the dirname of an url. e.g. `first/second`.
|
29
|
+
def extract_dirname(input)
|
30
|
+
input_s = input.to_s
|
31
|
+
if /^(\w+):/.match(input_s)
|
32
|
+
input_s.gsub(/^\w+:[^\/]*\/\/[^\/]+(\/[^\?]+)\/.*$/, '\1')
|
33
|
+
else
|
34
|
+
input_s.gsub(/\/[^\/]+$/, '')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the protocol. e.g. `http`.
|
39
|
+
def extract_protocol(input)
|
40
|
+
matches = input.to_s.match(/^(\w+):/)
|
41
|
+
if matches
|
42
|
+
matches[1]
|
43
|
+
else
|
44
|
+
""
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Liquid::Template.register_filter(FrozenFilters)
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: frozen-filters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexandre Bento Freire
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: liquid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
description:
|
28
|
+
email: devpieces@a-bentofreire.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/frozen-filters.rb
|
34
|
+
homepage: https://github.com/a-bentofreire/frozen-filters
|
35
|
+
licenses:
|
36
|
+
- MIT+uuid
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.7.6
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Liquid filters for shopify template engine
|
58
|
+
test_files: []
|