active_table 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +8 -0
- data/lib/active_table/base.rb +6 -5
- data/lib/active_table/railtie.rb +4 -9
- data/lib/active_table/version.rb +1 -1
- data/spec/active_table_spec.rb +5 -5
- metadata +4 -3
data/.autotest
ADDED
data/lib/active_table/base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActiveTable
|
2
2
|
class Base < ActiveRecord::Base
|
3
|
-
@@
|
3
|
+
@@detected_classes = []
|
4
4
|
@@insert_statements = []
|
5
5
|
@@table_list = []
|
6
6
|
|
@@ -43,12 +43,13 @@ module ActiveTable
|
|
43
43
|
@@table_list
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
|
46
|
+
def add_detected_class(grep_match)
|
47
|
+
class_name = grep_match[/class\ (.*) < ActiveTable::Base/, 1]
|
48
|
+
@@detected_classes << class_name.constantize
|
48
49
|
end
|
49
50
|
|
50
|
-
def
|
51
|
-
@@
|
51
|
+
def detected_classes
|
52
|
+
@@detected_classes
|
52
53
|
end
|
53
54
|
|
54
55
|
def create_table!
|
data/lib/active_table/railtie.rb
CHANGED
@@ -4,15 +4,10 @@ module ActiveTable
|
|
4
4
|
class Railtie < Rails::Railtie
|
5
5
|
initializer "active_table" do
|
6
6
|
model_path = Pathname.new("#{Rails.root}/app/models")
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
ActiveTable::Base.add_detected_file(file_path.relative_path_from(model_path).to_s)
|
12
|
-
require file if Rails.env.development?
|
13
|
-
next
|
14
|
-
end
|
15
|
-
end
|
7
|
+
matches = `grep -R ActiveTable::Base #{model_path}`.split("\n")
|
8
|
+
|
9
|
+
matches.each do |match|
|
10
|
+
ActiveTable::Base.add_detected_class(match)
|
16
11
|
end
|
17
12
|
end
|
18
13
|
end
|
data/lib/active_table/version.rb
CHANGED
data/spec/active_table_spec.rb
CHANGED
@@ -147,13 +147,13 @@ describe "a model created with active_table" do
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
-
context "#
|
150
|
+
context "#detected_classes" do
|
151
151
|
it "should return a list of model files detected during initialization" do
|
152
|
-
ActiveTable::Base.
|
153
|
-
ActiveTable::Base.
|
152
|
+
ActiveTable::Base.add_detected_class("/path/to/process/gid.rb:class Process::GID < ActiveTable::Base")
|
153
|
+
ActiveTable::Base.add_detected_class("/path/to/string.rb:class String < ActiveTable::Base")
|
154
154
|
|
155
|
-
ActiveTable::Base.
|
156
|
-
ActiveTable::Base.
|
155
|
+
ActiveTable::Base.detected_classes.size.should == 2
|
156
|
+
ActiveTable::Base.detected_classes.should include(Process::GID, String)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Case Commons LLC
|
@@ -51,6 +51,7 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
|
53
53
|
files:
|
54
|
+
- .autotest
|
54
55
|
- .gitignore
|
55
56
|
- Gemfile
|
56
57
|
- README.md
|