schash 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +7 -6
- data/Rakefile +6 -0
- data/lib/schash/schema/dsl.rb +4 -0
- data/lib/schash/schema/rule.rb +1 -0
- data/lib/schash/schema/rule/match.rb +21 -0
- data/lib/schash/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d901ec92f618c3919a2ef43bc53004cc28a7335f
|
4
|
+
data.tar.gz: 6abf7b2d0812c77fe311433573b652f615450723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10de3bff54d71bd105277f85b6ad75de308d3003cefcf2ff99301b5631cada6c0ca775abba7ca4e35fa38c7e03335c095be51e8cea7b43d8bb4e599a3874fcba
|
7
|
+
data.tar.gz: d82d77a14a7f9525ca9e7947936450d817ce6807fb18b7f08ff1e31d322ad4a07c884ae412fcfb4bc82d102c915ca89cdcc879ddae437c9f416f43c5ced617ae
|
data/README.md
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
# Schash
|
1
|
+
# Schash [](https://travis-ci.org/ryotarai/schash)
|
2
2
|
|
3
3
|
Pronounciation: the same as "squash"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
TODO: Delete this and the text above, and describe your gem
|
5
|
+
Ruby hash validator
|
8
6
|
|
9
7
|
## Installation
|
10
8
|
|
@@ -31,6 +29,7 @@ validator = Schash::Validator.new do
|
|
31
29
|
root: string,
|
32
30
|
allowed_ips: array_of(string),
|
33
31
|
}),
|
32
|
+
listen: match(/^(80|443)$/),
|
34
33
|
},
|
35
34
|
}
|
36
35
|
end
|
@@ -45,6 +44,7 @@ valid = {
|
|
45
44
|
root: "/var/www/itamae",
|
46
45
|
allowed_ips: ["127.0.0.1/32"],
|
47
46
|
}],
|
47
|
+
listen: "80"
|
48
48
|
},
|
49
49
|
}
|
50
50
|
|
@@ -59,11 +59,12 @@ invalid = {
|
|
59
59
|
root: "/var/www/itamae",
|
60
60
|
allowed_ips: ["127.0.0.1/32"],
|
61
61
|
},
|
62
|
+
listen: "8080"
|
62
63
|
},
|
63
64
|
}
|
64
65
|
|
65
66
|
validator.validate(invalid)
|
66
|
-
# => [#<struct Schash::Schema::Error position=["nginx", "user"], message="is not String">, #<struct Schash::Schema::Error position=["nginx", "sites"], message="is not an array">]
|
67
|
+
# => [#<struct Schash::Schema::Error position=["nginx", "user"], message="is not String">, #<struct Schash::Schema::Error position=["nginx", "sites"], message="is not an array">, #<struct Schash::Schema::Error position=["nginx", "listen"], message="does not match /^(80|443)$/">]
|
67
68
|
```
|
68
69
|
|
69
70
|
## Development
|
@@ -74,7 +75,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
74
75
|
|
75
76
|
## Contributing
|
76
77
|
|
77
|
-
1. Fork it ( https://github.com/
|
78
|
+
1. Fork it ( https://github.com/ryotarai/schash/fork )
|
78
79
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
79
80
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
80
81
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
data/lib/schash/schema/dsl.rb
CHANGED
data/lib/schash/schema/rule.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Schash
|
2
|
+
module Schema
|
3
|
+
module Rule
|
4
|
+
class Match < Base
|
5
|
+
def initialize(pattern)
|
6
|
+
@pattern = pattern
|
7
|
+
end
|
8
|
+
|
9
|
+
def validate(target, position = [])
|
10
|
+
errors = []
|
11
|
+
|
12
|
+
unless @pattern.match(target)
|
13
|
+
errors << Error.new(position, "does not match #{@pattern.inspect}")
|
14
|
+
end
|
15
|
+
|
16
|
+
errors
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/schash/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03
|
11
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/schash/schema/rule/array_of.rb
|
77
77
|
- lib/schash/schema/rule/base.rb
|
78
78
|
- lib/schash/schema/rule/hash.rb
|
79
|
+
- lib/schash/schema/rule/match.rb
|
79
80
|
- lib/schash/schema/rule/one_of_types.rb
|
80
81
|
- lib/schash/schema/rule/optional.rb
|
81
82
|
- lib/schash/schema/rule/type.rb
|