roleup 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roleup/has_roles.rb +0 -2
- data/lib/roleup/list.rb +18 -8
- data/lib/roleup/version.rb +1 -1
- data/test/list_test.rb +16 -0
- data/test/test_helper.rb +3 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2ea91510f467ad94058d25b9ba42988fb9a1d43
|
4
|
+
data.tar.gz: 00c2b340f808dccea230dc656d76376802aa9d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e04258f420a95b321cd28b73133dd2e1028af8f70865e5259dae026b7afc1e1e0be5fac4f9f6ad535b9e81c904fbb909f6418ef81ce7f70c12ae54d99515c5fa
|
7
|
+
data.tar.gz: 5a42fcc56e8525b78727aa7fec30f48369dc719bda85a19f42e3ae487452011547209077e77bc5c94fb81ccabff689bb33274b6713570e60441f33c6118ee53c
|
data/lib/roleup/has_roles.rb
CHANGED
data/lib/roleup/list.rb
CHANGED
@@ -4,23 +4,33 @@ module Roleup
|
|
4
4
|
class List
|
5
5
|
extend Forwardable
|
6
6
|
include Enumerable
|
7
|
-
def_delegators :inner_list, :each
|
7
|
+
def_delegators :inner_list, :each, :length, :size
|
8
8
|
|
9
|
-
def initialize(*
|
10
|
-
@inner_list =
|
9
|
+
def initialize(*values)
|
10
|
+
@inner_list = values.map { |value| standardize(value) }.uniq.sort
|
11
11
|
end
|
12
12
|
|
13
|
-
def include?(
|
14
|
-
inner_list.include? standardize(
|
13
|
+
def include?(value)
|
14
|
+
inner_list.include? standardize(value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def push(value)
|
18
|
+
return self if include?(value)
|
19
|
+
inner_list << standardize(value)
|
20
|
+
end
|
21
|
+
|
22
|
+
alias_method :<<, :push
|
23
|
+
|
24
|
+
def delete(value)
|
25
|
+
inner_list.delete standardize(value)
|
15
26
|
end
|
16
27
|
|
17
28
|
protected
|
18
29
|
|
19
30
|
attr_reader :inner_list
|
20
31
|
|
21
|
-
def standardize(
|
22
|
-
|
32
|
+
def standardize(value)
|
33
|
+
value.to_s.downcase.to_sym
|
23
34
|
end
|
24
|
-
|
25
35
|
end
|
26
36
|
end
|
data/lib/roleup/version.rb
CHANGED
data/test/list_test.rb
CHANGED
@@ -23,5 +23,21 @@ module Roleup
|
|
23
23
|
assert @roles.include?("EDITOR")
|
24
24
|
end
|
25
25
|
|
26
|
+
test "push" do
|
27
|
+
assert @roles.push(:other).include?(:other)
|
28
|
+
end
|
29
|
+
|
30
|
+
test "delete" do
|
31
|
+
@roles.delete :admin
|
32
|
+
assert !@roles.include?(:admin)
|
33
|
+
end
|
34
|
+
|
35
|
+
test "uniqueness" do
|
36
|
+
@roles << :other
|
37
|
+
@roles << :other
|
38
|
+
@roles << :other
|
39
|
+
assert @roles.size == @roles.to_a.uniq.size
|
40
|
+
end
|
41
|
+
|
26
42
|
end
|
27
43
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roleup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Hopkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Simple role management
|
56
70
|
email:
|
57
71
|
- natehop@gmail.com
|