phc_string_format 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +1 -1
- data/lib/phc_string_format/phc_string.rb +20 -17
- data/lib/phc_string_format/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 74aad184bd05ef181197a6511faf147117419a36
|
4
|
+
data.tar.gz: 67d273fc6645159868754577049e5c6161454831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 727d3a0d2e0d0803f0331b897175cd79e36f17feccee6e0b91a02b0ebef6e9e75b083472b527b5ff04939c135696a620fae06b22159222b775d386c69c27771b
|
7
|
+
data.tar.gz: f1a8cf1788ace3f1ed3c4ad777492d53daf16782f88f4c539b8c3752895c0172dd8673d247cd046d6b74fd2e2052f6f8a5954f891f3ac3745c5a54457b8594c9
|
data/Gemfile.lock
CHANGED
@@ -23,23 +23,24 @@ module PhcStringFormat
|
|
23
23
|
that
|
24
24
|
end
|
25
25
|
|
26
|
-
private_class_method :validates, :validate
|
27
|
-
|
28
|
-
# :reek:DuplicateMethodCall { allow_calls: ['elements.shift', 'elements.first'] }
|
29
26
|
def self.parse(string)
|
30
27
|
string ||= ''
|
28
|
+
PhcString.new(*split(string))
|
29
|
+
rescue StandardError => exception
|
30
|
+
raise ParseError, exception.message
|
31
|
+
end
|
32
|
+
|
33
|
+
# :reek:DuplicateMethodCall { allow_calls: ['elements.shift', 'elements.first'] }
|
34
|
+
def self.split(string)
|
31
35
|
elements = string.split(/\$/, 6)
|
32
36
|
elements.shift
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
rescue ArgumentError
|
41
|
-
raise ParseError
|
42
|
-
end
|
37
|
+
[
|
38
|
+
elements.shift,
|
39
|
+
(elements.shift if (elements.first || '').start_with?('v=')),
|
40
|
+
(elements.shift if (elements.first || '').include?('=')),
|
41
|
+
elements.shift,
|
42
|
+
elements.shift
|
43
|
+
]
|
43
44
|
end
|
44
45
|
|
45
46
|
def self.create(id:, version: nil, params: nil, salt: nil, hash: nil, hint: {})
|
@@ -52,6 +53,8 @@ module PhcStringFormat
|
|
52
53
|
)
|
53
54
|
end
|
54
55
|
|
56
|
+
private_class_method :validates, :validate, :split
|
57
|
+
|
55
58
|
validates :@id, message: 'id is non-compliant', format: { with: /\A[a-z0-9-]{1,32}\z/ }
|
56
59
|
validates \
|
57
60
|
:@version_string,
|
@@ -63,12 +66,12 @@ module PhcStringFormat
|
|
63
66
|
:@encoded_salt,
|
64
67
|
message: 'encoded salt is non-compliant',
|
65
68
|
allow_nil: true,
|
66
|
-
format: { with: %r{\A[a-zA-Z0-9/+.-]
|
69
|
+
format: { with: %r{\A[a-zA-Z0-9/+.-]*\z} }
|
67
70
|
validates \
|
68
71
|
:@encoded_hash,
|
69
72
|
message: 'encoded hash is non-compliant',
|
70
73
|
allow_nil: true,
|
71
|
-
format: { with: %r{\A[a-zA-Z0-9/+]
|
74
|
+
format: { with: %r{\A[a-zA-Z0-9/+]*\z} }
|
72
75
|
validate :validate_salt_and_hash, message: 'hash needs salt'
|
73
76
|
|
74
77
|
def initialize(id, version_string, params_string, encoded_salt, encoded_hash)
|
@@ -88,7 +91,7 @@ module PhcStringFormat
|
|
88
91
|
@params_string,
|
89
92
|
@encoded_salt,
|
90
93
|
@encoded_hash
|
91
|
-
].
|
94
|
+
].compact.join('$')
|
92
95
|
end
|
93
96
|
|
94
97
|
def to_h(pick: nil, hint: {})
|
@@ -118,7 +121,7 @@ module PhcStringFormat
|
|
118
121
|
end
|
119
122
|
|
120
123
|
def validate_salt_and_hash
|
121
|
-
|
124
|
+
@encoded_salt || !@encoded_hash
|
122
125
|
end
|
123
126
|
|
124
127
|
def parse_version(version_string)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phc_string_format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- naokikimura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.5.2.3
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: PHC string format implemented by Ruby.
|