active_table 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ autotest_styles = {
22
22
 
23
23
  desc "Run all specs against Rspec 1 and 2"
24
24
  task "spec" do
25
- in_environment.call('rspec1', 'spec spec') if major == 1 && minor < 9
25
+ in_environment.call('rspec1', 'spec spec')
26
26
  in_environment.call('rspec2', 'rspec spec')
27
27
  end
28
28
 
@@ -1,5 +1,6 @@
1
1
  module ActiveTable
2
2
  class Base < ActiveRecord::Base
3
+ @@detected_files = []
3
4
  @@insert_statements = []
4
5
  @@table_list = []
5
6
 
@@ -26,6 +27,14 @@ module ActiveTable
26
27
  @@table_list
27
28
  end
28
29
 
30
+ def self.add_detected_file(file)
31
+ @@detected_files << file
32
+ end
33
+
34
+ def self.detected_files
35
+ @@detected_files
36
+ end
37
+
29
38
  def self.create_table!
30
39
  connection = ActiveRecord::Base.connection
31
40
  connection.execute "DROP TABLE IF EXISTS #{connection.quote_table_name(@table[:name])}"
@@ -1,9 +1,14 @@
1
+ require "pathname"
2
+
1
3
  module ActiveTable
2
4
  class Railtie < Rails::Railtie
3
5
  initializer "active_table", :after => "casebook2_extensions" do
6
+ model_path = Pathname.new("#{Rails.root}/app/models")
4
7
  Dir.glob("#{Rails.root}/app/models/**/*.rb").each do |file|
5
8
  File.open(file).readlines.each do |line|
6
9
  if (line =~ /ActiveTable::Base/)
10
+ file_path = Pathname.new(file)
11
+ ActiveTable::Base.add_detected_file(file_path.relative_path_from(model_path).to_s)
7
12
  require file if Rails.env.dev?
8
13
  next
9
14
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveTable
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -70,6 +70,16 @@ describe "a model created with active_table" do
70
70
  end
71
71
  end
72
72
 
73
+ context "#detected_files" do
74
+ it "should return a list of model files detected during initialization" do
75
+ ActiveTable::Base.add_detected_file("awesome/model.rb")
76
+ ActiveTable::Base.add_detected_file("foo/bar.rb")
77
+
78
+ ActiveTable::Base.detected_files.size.should == 2
79
+ ActiveTable::Base.detected_files.should include("awesome/model.rb", "foo/bar.rb")
80
+ end
81
+ end
82
+
73
83
  context "#seed!" do
74
84
  it "should attempt to re-insert all rows" do
75
85
  class AwesomeModel < ActiveTable::Base
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_table
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: