looker 0.2.2 → 0.3.0

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: 60cf223e471dae943f61300eaad5fe790d7ef13b
4
- data.tar.gz: e2201457b8f4d228bbfac23a2fd351c10602d62d
3
+ metadata.gz: 2a5342e20caa742f53a0942966eb4817997e2da5
4
+ data.tar.gz: 7847fcfa2255e1ab7bdcd79dd8a19337f30dbafb
5
5
  SHA512:
6
- metadata.gz: 1b884a0ed8c3eb4d58ff6443cf63937da70165dc827a228d08f191a985536287ee775de13d6a4c46d805c36cf5126d484a4a61ae42f152092a312518e02af574
7
- data.tar.gz: e9226ca595b3e8d96b31b9f79f25b0133c42692798e518fbd4420a6b805b4795449432b4cc04975d714dc124a51faf308eb7bfa56f74586ed9d872a9cda7cf51
6
+ metadata.gz: 442db2eae4c325720af442d14a741fede185810b512b8e148fe7d1febaf6267174e936569dc452685f3b7cfa703b7e130f1ff88ac29238a8f2f56a324fcd298f
7
+ data.tar.gz: ccf69f7eed81d36b3d5295d7a85069e218768faf07b549428180ed34aaeeb817973ee425ec7af79d4fade12fc480f21d4e8a2fae96c579b8efc7d8277e25abf3
data/README.md CHANGED
@@ -25,17 +25,23 @@ Looker.add roles: {
25
25
  # The name (first Hash key) & value is converted
26
26
  # to an upcase named frozen constant on the Looker module
27
27
 
28
- Looker::ROLES[:admin] # => 1
29
- Looker::ROLES[1] # => :admin
28
+ Looker::ROLES[:admin] # => 1
29
+ Looker::ROLES["admin"] # => 1
30
+ Looker::ROLES[1] # => :admin
30
31
 
31
- Looker::ROLES[:reader] # => 2
32
- Looker::ROLES[2] # => :reader
32
+ Looker::ROLES[:reader] # => 2
33
+ Looker::ROLES["reader"] # => 2
34
+ Looker::ROLES[2] # => :reader
33
35
 
36
+ Looker::ROLES[:writer] # => 3
34
37
  Looker::ROLES["writer"] # => 3
35
- Looker::ROLES[3] # => :writer
36
- ```
38
+ Looker::ROLES[3] # => :writer
39
+
40
+ Looker::ROLES.name # => "roles"
41
+ Looker::ROLES.constant_name # => "ROLES"
37
42
 
38
- __NOTE:__ You can perform lookups using both the key & value.
43
+ Looker::ROLES.to_h # => {:admin=>1, :reader=>2, :writer=>3}
44
+ ```
39
45
 
40
46
  ## Multiple Enumerated Types
41
47
 
@@ -9,8 +9,8 @@ module Looker
9
9
  def_delegators :@tables, :each
10
10
 
11
11
  def add(data={})
12
- data.each do |name, rows|
13
- table = Looker::Table.new(name, rows)
12
+ data.each do |name, entries|
13
+ table = Looker::Table.new(name, entries)
14
14
  if Looker.const_defined?(table.constant_name)
15
15
  message = "Looker::#{table.constant_name} is already defined!"
16
16
  raise ArgumentError.new(message)
@@ -4,18 +4,18 @@ module Looker
4
4
  class Table
5
5
  extend Forwardable
6
6
  include Enumerable
7
- def_delegators :rows, :each
8
- attr_reader :name, :constant_name, :rows
7
+ def_delegators :entries, :each
8
+ attr_reader :name, :constant_name, :entries
9
9
 
10
10
  def self.constant_name(name)
11
11
  name.gsub(/\s/, "_").gsub(/\W/, "").upcase
12
12
  end
13
13
 
14
- def initialize(name, rows={})
14
+ def initialize(name, entries={})
15
15
  @name = name.to_s.strip.freeze
16
16
  @constant_name = self.class.constant_name(@name).freeze
17
- @rows = rows.dup.freeze
18
- @dict = rows.invert.merge(rows).freeze
17
+ @entries = entries.dup.freeze
18
+ @dict = entries.invert.merge(entries).freeze
19
19
  freeze
20
20
  end
21
21
 
@@ -24,7 +24,7 @@ module Looker
24
24
  end
25
25
 
26
26
  def to_h
27
- rows
27
+ entries
28
28
  end
29
29
 
30
30
  private
@@ -1,3 +1,3 @@
1
1
  module Looker
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: looker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins