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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2266312a1c81b096065b9c49a265614b4fd6266
4
- data.tar.gz: dd6150346601f09c9b42a1a32ef6a99569731414
3
+ metadata.gz: b2ea91510f467ad94058d25b9ba42988fb9a1d43
4
+ data.tar.gz: 00c2b340f808dccea230dc656d76376802aa9d97
5
5
  SHA512:
6
- metadata.gz: 0b59f407ade38daa8f21e76b5af4c6e8a2a8d715724bbcbbe0164c6ad74a2afc337b1567c7bee91347e73107aa08850cf6ffedfe9045313a22ed686d1c72a7e9
7
- data.tar.gz: 1fe839cb648f7a18f3cc4635bb969d74099dcc70ec95947fc6fab09df16bab0b22293dc77c6ebf1895fc1a0180d73dda40a453c235cbeccb576569efd8acdb57
6
+ metadata.gz: e04258f420a95b321cd28b73133dd2e1028af8f70865e5259dae026b7afc1e1e0be5fac4f9f6ad535b9e81c904fbb909f6418ef81ce7f70c12ae54d99515c5fa
7
+ data.tar.gz: 5a42fcc56e8525b78727aa7fec30f48369dc719bda85a19f42e3ae487452011547209077e77bc5c94fb81ccabff689bb33274b6713570e60441f33c6118ee53c
@@ -1,7 +1,5 @@
1
1
  module Roleup
2
2
  module HasRoles
3
- attr_reader :roles
4
-
5
3
  def roles
6
4
  @roles ||= List.new
7
5
  end
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(*roles)
10
- @inner_list = roles.map { |role| standardize(role) }.uniq.sort
9
+ def initialize(*values)
10
+ @inner_list = values.map { |value| standardize(value) }.uniq.sort
11
11
  end
12
12
 
13
- def include?(role)
14
- inner_list.include? standardize(role)
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(role)
22
- role.to_s.downcase.to_sym
32
+ def standardize(value)
33
+ value.to_s.downcase.to_sym
23
34
  end
24
-
25
35
  end
26
36
  end
@@ -1,3 +1,3 @@
1
1
  module Roleup
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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
@@ -1,5 +1,8 @@
1
1
  require "simplecov"
2
+ require 'coveralls'
3
+
2
4
  SimpleCov.start
3
5
  SimpleCov.command_name "mt"
6
+ Coveralls.wear!
4
7
 
5
8
  require_relative "../lib/roleup"
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.1
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-08 00:00:00.000000000 Z
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