active_table 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/active_table/base.rb +16 -3
- data/lib/active_table/extensions/rails.rb +11 -0
- data/lib/active_table/railtie.rb +2 -2
- data/lib/active_table/version.rb +1 -1
- data/lib/active_table.rb +1 -0
- metadata +58 -31
data/lib/active_table/base.rb
CHANGED
@@ -7,9 +7,22 @@ module ActiveTable
|
|
7
7
|
def self.active_table(&block)
|
8
8
|
@table = {}
|
9
9
|
block.call
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
unless model_loaded?
|
11
|
+
create_table!
|
12
|
+
self.reset_column_information
|
13
|
+
self.define_attribute_methods
|
14
|
+
model_loaded!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.model_loaded!
|
19
|
+
return unless defined?(Rails)
|
20
|
+
Rails.active_table_loaded_model_names << self.name
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.model_loaded?
|
24
|
+
return false unless defined?(Rails)
|
25
|
+
Rails.active_table_loaded_model_names.include?(self.name)
|
13
26
|
end
|
14
27
|
|
15
28
|
def self.create_table(name, options = {}, &block)
|
data/lib/active_table/railtie.rb
CHANGED
@@ -2,14 +2,14 @@ require "pathname"
|
|
2
2
|
|
3
3
|
module ActiveTable
|
4
4
|
class Railtie < Rails::Railtie
|
5
|
-
initializer "active_table"
|
5
|
+
initializer "active_table" do
|
6
6
|
model_path = Pathname.new("#{Rails.root}/app/models")
|
7
7
|
Dir.glob("#{Rails.root}/app/models/**/*.rb").each do |file|
|
8
8
|
File.open(file).readlines.each do |line|
|
9
9
|
if (line =~ /ActiveTable::Base/)
|
10
10
|
file_path = Pathname.new(file)
|
11
11
|
ActiveTable::Base.add_detected_file(file_path.relative_path_from(model_path).to_s)
|
12
|
-
require file if Rails.env.
|
12
|
+
require file if Rails.env.development?
|
13
13
|
next
|
14
14
|
end
|
15
15
|
end
|
data/lib/active_table/version.rb
CHANGED
data/lib/active_table.rb
CHANGED
metadata
CHANGED
@@ -1,38 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_table
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Case Commons LLC
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
17
|
+
|
18
|
+
date: 2011-07-11 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
16
21
|
name: activerecord
|
17
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
24
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 9
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 3
|
32
|
+
- 5
|
22
33
|
version: 2.3.5
|
23
34
|
- - <
|
24
|
-
- !ruby/object:Gem::Version
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
hash: 63
|
37
|
+
segments:
|
38
|
+
- 4
|
39
|
+
- 0
|
40
|
+
- 0
|
25
41
|
version: 4.0.0
|
26
42
|
type: :runtime
|
27
|
-
|
28
|
-
version_requirements: *2164666700
|
43
|
+
version_requirements: *id001
|
29
44
|
description: Dynamically-populated ActiveRecord models based on static data
|
30
|
-
email:
|
45
|
+
email:
|
31
46
|
- casecommons-dev@googlegroups.com
|
32
47
|
executables: []
|
48
|
+
|
33
49
|
extensions: []
|
50
|
+
|
34
51
|
extra_rdoc_files: []
|
35
|
-
|
52
|
+
|
53
|
+
files:
|
36
54
|
- .gitignore
|
37
55
|
- Gemfile
|
38
56
|
- README.md
|
@@ -43,35 +61,44 @@ files:
|
|
43
61
|
- gemfiles/rspec2/Gemfile
|
44
62
|
- lib/active_table.rb
|
45
63
|
- lib/active_table/base.rb
|
64
|
+
- lib/active_table/extensions/rails.rb
|
46
65
|
- lib/active_table/railtie.rb
|
47
66
|
- lib/active_table/version.rb
|
48
67
|
- spec/active_table_spec.rb
|
49
68
|
- spec/spec_helper.rb
|
50
|
-
has_rdoc: true
|
51
69
|
homepage: https://github.com/Casecommons/active_table
|
52
70
|
licenses: []
|
71
|
+
|
53
72
|
post_install_message:
|
54
73
|
rdoc_options: []
|
55
|
-
|
74
|
+
|
75
|
+
require_paths:
|
56
76
|
- lib
|
57
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
78
|
none: false
|
59
|
-
requirements:
|
60
|
-
- -
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
|
63
|
-
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 3
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
87
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
69
95
|
requirements: []
|
96
|
+
|
70
97
|
rubyforge_project: active_table
|
71
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.8.5
|
72
99
|
signing_key:
|
73
100
|
specification_version: 3
|
74
101
|
summary: Dynamically-populated ActiveRecord models based on static data
|
75
|
-
test_files:
|
102
|
+
test_files:
|
76
103
|
- spec/active_table_spec.rb
|
77
104
|
- spec/spec_helper.rb
|