looker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 88e622d4b8a2fbd5684a873a9b3e2c30beefd9fd
4
+ data.tar.gz: ab73433d9e9513e20b5853940b016e8afa0c4c16
5
+ SHA512:
6
+ metadata.gz: 809eb722dfeb22a1ab4785af98d9a77cef28177aadb082b4c1fadfdbc35999e5b436a19262e4480541468d587cc45948dbd074e739ef5610a0b3d9284f961985
7
+ data.tar.gz: 9069a79cdc8b699d0b5691105686c1ad82e7a2c513ba49cbbaf1368191e0699d917f5a2c30891cde517c8abfd4ae244d8d1891f919f6052b50f135947faff99f
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in looker.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ looker (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ binding_of_caller (0.7.2)
10
+ debug_inspector (>= 0.0.1)
11
+ byebug (8.2.2)
12
+ coderay (1.1.1)
13
+ coveralls (0.8.13)
14
+ json (~> 1.8)
15
+ simplecov (~> 0.11.0)
16
+ term-ansicolor (~> 1.3)
17
+ thor (~> 0.19.1)
18
+ tins (~> 1.6.0)
19
+ debug_inspector (0.0.2)
20
+ docile (1.1.5)
21
+ interception (0.5)
22
+ json (1.8.3)
23
+ method_source (0.8.2)
24
+ os (0.9.6)
25
+ pry (0.10.3)
26
+ coderay (~> 1.1.0)
27
+ method_source (~> 0.8.1)
28
+ slop (~> 3.4)
29
+ pry-byebug (3.3.0)
30
+ byebug (~> 8.0)
31
+ pry (~> 0.10)
32
+ pry-rescue (1.4.2)
33
+ interception (>= 0.5)
34
+ pry
35
+ pry-stack_explorer (0.4.9.2)
36
+ binding_of_caller (>= 0.7)
37
+ pry (>= 0.9.11)
38
+ pry-test (0.6.4)
39
+ os
40
+ pry
41
+ pry-byebug
42
+ pry-rescue
43
+ pry-stack_explorer
44
+ rake (10.5.0)
45
+ simplecov (0.11.2)
46
+ docile (~> 1.1.0)
47
+ json (~> 1.8)
48
+ simplecov-html (~> 0.10.0)
49
+ simplecov-html (0.10.0)
50
+ slop (3.6.0)
51
+ term-ansicolor (1.3.2)
52
+ tins (~> 1.0)
53
+ thor (0.19.1)
54
+ tins (1.6.0)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ bundler (~> 1.11)
61
+ coveralls
62
+ looker!
63
+ pry-test
64
+ rake (~> 10.0)
65
+
66
+ BUNDLED WITH
67
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Hopkins
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Looker
2
+
3
+ ## Hash based enumerated types (ENUMS)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task :test do
4
+ exec "bundle exec pry-test"
5
+ end
6
+
7
+ task :default => :test
8
+
data/lib/looker.rb ADDED
@@ -0,0 +1,15 @@
1
+ require "looker/version"
2
+ require "looker/table"
3
+
4
+ module Looker
5
+ def self.create_constants(data={})
6
+ data.each do |name, rows|
7
+ table = Looker::Table.new(name, rows)
8
+ if Looker.const_defined?(table.const_name)
9
+ message = "Looker::#{table.const_name} is already defined!"
10
+ raise ArgumentError.new(message)
11
+ end
12
+ Looker.const_set table.const_name, table
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ require "forwardable"
2
+
3
+ module Looker
4
+ class Table
5
+ extend Forwardable
6
+ include Enumerable
7
+ def_delegators :rows, :each
8
+ def_delegator :dict, :[]
9
+ attr_reader :name, :const_name, :rows
10
+
11
+ def self.constant_name(name)
12
+ name.to_s.gsub(/\s/, "_").gsub(/\W/, "").upcase
13
+ end
14
+
15
+ def initialize(name, rows={})
16
+ @name = name.to_s.dup.freeze
17
+ @const_name = self.class.constant_name(name).freeze
18
+ @rows = rows.dup.freeze
19
+ @dict = rows.invert.merge(rows).freeze
20
+ freeze
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :dict
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Looker
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: looker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Hopkins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
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'
69
+ description:
70
+ email:
71
+ - natehop@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - Gemfile
77
+ - Gemfile.lock
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/looker.rb
82
+ - lib/looker/table.rb
83
+ - lib/looker/version.rb
84
+ homepage: https://github.com/hopsoft/looker
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.5.1
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Hash based enumerated types (ENUMS)
108
+ test_files: []