add_symbolic_names 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/add_symbolic_names/store/yaml.rb +6 -2
- data/lib/add_symbolic_names/version.rb +1 -1
- data/test/add_symbolic_names_test.rb +18 -0
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdd00e6815c88b624d573e5716cd893c729701ac
|
4
|
+
data.tar.gz: 6710e0e21dbd704eb5d7b2df1d32bf012fd29b34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7231c58f9919bcbd2cdbfc4d7533e4ec4311a0bff9abc85bad162ba555c73babd64f68ba38402edce4aa1a1e447b7172030928d3e4238ed8746ce740ecab072c
|
7
|
+
data.tar.gz: 8d15bc3a111208b554197b6cad3cace389210087b2e1c39bc129c1b4e5922d9c2ed317bacbaf69704e3c04c1604d221b99c7636a380e5c780da5739f0f87c8c0
|
@@ -6,10 +6,14 @@ module AddSymbolicNames
|
|
6
6
|
mattr_accessor :folder
|
7
7
|
|
8
8
|
def self.define_constants(klass, opts)
|
9
|
-
YAML.load_file(
|
9
|
+
YAML.load_file(yaml_file_name(klass)).each do |datum|
|
10
10
|
klass.const_set(datum['symbolic_name'], datum['id']) unless klass.const_defined?(datum['symbolic_name'])
|
11
11
|
end
|
12
12
|
end
|
13
|
+
|
14
|
+
def self.yaml_file_name(klass)
|
15
|
+
File.join(self.folder, "#{klass.name.tableize}.yml")
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
|
-
end
|
19
|
+
end
|
@@ -19,4 +19,22 @@ class AddSymbolicNamesTest < ActiveSupport::TestCase
|
|
19
19
|
assert_equal 2, User::ADMIN
|
20
20
|
end
|
21
21
|
|
22
|
+
test "generates a yaml file name based off of the class name" do
|
23
|
+
class ClassWithoutModule
|
24
|
+
end
|
25
|
+
yaml_store = AddSymbolicNames::Store::Yaml
|
26
|
+
|
27
|
+
assert_equal "#{yaml_store.folder}/#{self.class.name.underscore}/class_without_modules.yml", yaml_store.yaml_file_name(ClassWithoutModule)
|
28
|
+
end
|
29
|
+
|
30
|
+
test "generates a yaml file name based off of the class name with modules" do
|
31
|
+
module SomeModule
|
32
|
+
class ClassWithModule
|
33
|
+
end
|
34
|
+
end
|
35
|
+
yaml_store = AddSymbolicNames::Store::Yaml
|
36
|
+
|
37
|
+
assert_equal "#{yaml_store.folder}/#{self.class.name.underscore}/some_module/class_with_modules.yml", yaml_store.yaml_file_name(SomeModule::ClassWithModule)
|
38
|
+
end
|
39
|
+
|
22
40
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: add_symbolic_names
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben VandenBos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: ActiveRecord plugin for creating constants from a domain table
|
@@ -44,16 +44,16 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
+
- MIT-LICENSE
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- lib/add_symbolic_names.rb
|
47
51
|
- lib/add_symbolic_names/mixin.rb
|
48
52
|
- lib/add_symbolic_names/railtie.rb
|
53
|
+
- lib/add_symbolic_names/store.rb
|
49
54
|
- lib/add_symbolic_names/store/active_record.rb
|
50
55
|
- lib/add_symbolic_names/store/yaml.rb
|
51
|
-
- lib/add_symbolic_names/store.rb
|
52
56
|
- lib/add_symbolic_names/version.rb
|
53
|
-
- lib/add_symbolic_names.rb
|
54
|
-
- MIT-LICENSE
|
55
|
-
- Rakefile
|
56
|
-
- README.md
|
57
57
|
- test/add_symbolic_names_test.rb
|
58
58
|
homepage: http://github.com/avvo/add_symbolic_names
|
59
59
|
licenses:
|
@@ -65,17 +65,17 @@ require_paths:
|
|
65
65
|
- lib
|
66
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.6.2
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: ActiveRecord plugin for creating constants from a domain table
|