scrivener-contrib 0.0.1 → 1.0.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 +4 -4
- data/.gems +1 -1
- data/.gitignore +1 -1
- data/LICENSE +19 -0
- data/README.md +44 -0
- data/lib/scrivener/contrib.rb +1 -5
- data/scrivener-contrib.gemspec +7 -7
- data/test/confirmation.rb +0 -7
- data/test/ohm.rb +2 -1
- metadata +9 -7
- data/UNLICENSE +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9909e7ad08610ce637d73a6e7042ed1c78f3f520
|
4
|
+
data.tar.gz: b70b640e41ae7dcf0ba642d827314328242eca79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0df8f451f9f037e8be147685fd321bad834ffe953f0f3c705574db80815ef666f7e473c57fc9b0bab699e28fbbb275bca70d6cdd229577a52032698b59d37124
|
7
|
+
data.tar.gz: ac08a267c75050c979b435369339855b79c3553c774613868aae654cfa4d01910e7ba9f6c08d4bdc05a26815180e231937bb6b75645ca8e0c9d251431711b933
|
data/.gems
CHANGED
data/.gitignore
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
*.gem
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Francesco Rodríguez, Mayn Kjær
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -2,3 +2,47 @@ scrivener-contrib
|
|
2
2
|
=================
|
3
3
|
|
4
4
|
Extra validations for Scrivener
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
|
9
|
+
The extra validations are:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
assert_confirmation(:password)
|
13
|
+
assert_minimum_length(:password, 6)
|
14
|
+
assert_maximum_length(:name, 50)
|
15
|
+
assert_exact_length(:idnum, 8)
|
16
|
+
```
|
17
|
+
|
18
|
+
This is a basic example:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require "scrivener"
|
22
|
+
require "scrivener/contrib"
|
23
|
+
|
24
|
+
class Signup < Scrivener
|
25
|
+
attr_accessor :username
|
26
|
+
attr_accessor :name
|
27
|
+
attr_accessor :idnum
|
28
|
+
attr_accessor :password
|
29
|
+
attr_accessor :password_confirmation
|
30
|
+
|
31
|
+
def validate
|
32
|
+
if assert_present(:password)
|
33
|
+
assert_confirmation(:password)
|
34
|
+
assert_minimum_length(:password, 6)
|
35
|
+
end
|
36
|
+
|
37
|
+
assert_maximum_length(:name, 50)
|
38
|
+
assert_exact_length(:idnum, 8)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
Installation
|
44
|
+
------------
|
45
|
+
|
46
|
+
```
|
47
|
+
$ gem install scrivener-contrib
|
48
|
+
```
|
data/lib/scrivener/contrib.rb
CHANGED
@@ -3,11 +3,7 @@ require_relative "ohm" if defined?(Ohm)
|
|
3
3
|
class Scrivener
|
4
4
|
module Validations
|
5
5
|
def assert_confirmation(att, error = [att, :not_confirmed])
|
6
|
-
|
7
|
-
|
8
|
-
if assert_present(confirmation, error)
|
9
|
-
assert(send(confirmation) == send(att), error)
|
10
|
-
end
|
6
|
+
assert(send(:"#{att}_confirmation") == send(att), error)
|
11
7
|
end
|
12
8
|
|
13
9
|
def assert_minimum_length(att, val, error = [att, :too_short])
|
data/scrivener-contrib.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
s.name
|
3
|
-
s.version
|
4
|
-
s.summary
|
2
|
+
s.name = "scrivener-contrib"
|
3
|
+
s.version = "1.0.0"
|
4
|
+
s.summary = "Extra validation helpers for Scrivener."
|
5
5
|
s.description = s.summary
|
6
|
-
s.authors
|
7
|
-
s.email
|
8
|
-
s.homepage
|
9
|
-
s.license
|
6
|
+
s.authors = ["Francesco Rodríguez", "Mayn Kjær"]
|
7
|
+
s.email = ["frodsan@me.com", "mayn.kjaer@gmail.com"]
|
8
|
+
s.homepage = "https://github.com/harmoni-io/scrivener-contrib"
|
9
|
+
s.license = "MIT"
|
10
10
|
|
11
11
|
s.files = `git ls-files`.split("\n")
|
12
12
|
|
data/test/confirmation.rb
CHANGED
@@ -9,13 +9,6 @@ class Signup < Scrivener
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
test "invalid if confirmation is nil" do
|
13
|
-
signup = Signup.new({})
|
14
|
-
|
15
|
-
assert !(signup.valid?)
|
16
|
-
assert_equal [:not_confirmed], signup.errors[:password]
|
17
|
-
end
|
18
|
-
|
19
12
|
test "invalid if confirmation and attribute are not equal" do
|
20
13
|
signup = Signup.new(password: "!", password_confirmation: "?")
|
21
14
|
|
data/test/ohm.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrivener-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francesco Rodríguez
|
8
|
+
- Mayn Kjær
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: cutest
|
@@ -26,15 +27,16 @@ dependencies:
|
|
26
27
|
version: '0'
|
27
28
|
description: Extra validation helpers for Scrivener.
|
28
29
|
email:
|
29
|
-
-
|
30
|
+
- frodsan@me.com
|
31
|
+
- mayn.kjaer@gmail.com
|
30
32
|
executables: []
|
31
33
|
extensions: []
|
32
34
|
extra_rdoc_files: []
|
33
35
|
files:
|
34
36
|
- ".gems"
|
35
37
|
- ".gitignore"
|
38
|
+
- LICENSE
|
36
39
|
- README.md
|
37
|
-
- UNLICENSE
|
38
40
|
- lib/scrivener/contrib.rb
|
39
41
|
- lib/scrivener/ohm.rb
|
40
42
|
- makefile
|
@@ -43,9 +45,9 @@ files:
|
|
43
45
|
- test/helper.rb
|
44
46
|
- test/length.rb
|
45
47
|
- test/ohm.rb
|
46
|
-
homepage: https://github.com/
|
48
|
+
homepage: https://github.com/harmoni-io/scrivener-contrib
|
47
49
|
licenses:
|
48
|
-
-
|
50
|
+
- MIT
|
49
51
|
metadata: {}
|
50
52
|
post_install_message:
|
51
53
|
rdoc_options: []
|
@@ -63,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
65
|
version: '0'
|
64
66
|
requirements: []
|
65
67
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.2.
|
68
|
+
rubygems_version: 2.2.2
|
67
69
|
signing_key:
|
68
70
|
specification_version: 4
|
69
71
|
summary: Extra validation helpers for Scrivener.
|
data/UNLICENSE
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
This is free and unencumbered software released into the public domain.
|
2
|
-
|
3
|
-
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
-
distribute this software, either in source code form or as a compiled
|
5
|
-
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
-
means.
|
7
|
-
|
8
|
-
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
-
of this software dedicate any and all copyright interest in the
|
10
|
-
software to the public domain. We make this dedication for the benefit
|
11
|
-
of the public at large and to the detriment of our heirs and
|
12
|
-
successors. We intend this dedication to be an overt act of
|
13
|
-
relinquishment in perpetuity of all present and future rights to this
|
14
|
-
software under copyright law.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
|
24
|
-
For more information, please refer to <http://unlicense.org/>
|