davidtrogers-steamer 0.1.3.1 → 0.1.3.2

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.
Files changed (4) hide show
  1. data/README +14 -2
  2. data/lib/steamer.rb +33 -14
  3. data/steamer.gemspec +1 -1
  4. metadata +1 -1
data/README CHANGED
@@ -1,8 +1,20 @@
1
+ Manifesto:
2
+ - create a database for testing that is easily created, is pre-populated with minimal configuration, whose tables are associated correctly, is quickly rolled back between tests, and is correct, every time.
3
+ - should have a way of doing it all by hand but should default to populating the db for you.
1
4
  ToDo:
2
5
  - Done - get it working with sqlite3
3
- - read in all models
4
- - record attribute information
6
+ - Done - read in all models
7
+ - record attribute information in a test db
8
+ - need a method to open the database
9
+ - need a method to create/write to the database table generic data
5
10
  - record association information
11
+ - for each association (habtm, has_many, has_one, belongs_to, etc.),
12
+ - if it uses a join table, or is owned/owns another model
13
+ - find the join table, or child table
14
+ - make sure id's and foreign keys line up.
15
+ - write it to the database with a function call?
16
+ - reset the database with a function call?
17
+ - drop the database with a function call?
6
18
 
7
19
  Discussion:
8
20
  There are definitely a couple of different ways I can go with this:
data/lib/steamer.rb CHANGED
@@ -5,7 +5,8 @@ class Steamer
5
5
 
6
6
  attr_accessor :source_db_connection,
7
7
  :source_db, :models,
8
- :model_files
8
+ :model_files,
9
+ :model_reflections
9
10
 
10
11
  def initialize
11
12
  connect
@@ -24,22 +25,40 @@ class Steamer
24
25
  def setup_models
25
26
  # get all of the models, store in an Array
26
27
  @models = []
27
- @model_files = get_model_files #Dir[File.join(RAILS_ROOT + "/app/models/*/*")]
28
+ # @model_files = get_model_files #Dir[File.join(RAILS_ROOT + "/app/models/*/*")]
28
29
 
29
- # for each one, get file name
30
- #@models.push File.basename(file,"*.rb").camelize
31
- @model_files.each do |file|
32
- file.sub!("./app/models/","")
33
- if file.split("/").size>1
34
- @models.push "#{file.split('/')[0].camelize}::#{file.split('/')[1].camelize.chomp(".rb")}"
35
- else
36
- @models.push file.camelize.chomp(".rb")
30
+ ## for each one, get file name
31
+ ##@models.push File.basename(file,"*.rb").camelize
32
+ #@model_files.each do |file|
33
+ # file.sub!("./app/models/","")
34
+ # if file.split("/").size>1
35
+ # @models.push "#{file.split('/')[0].camelize}::#{file.split('/')[1].camelize.chomp(".rb")}"
36
+ # else
37
+ # @models.push file.camelize.chomp(".rb")
38
+ # end
39
+ #end
40
+
41
+ ## now I have all the models by name... construct a datastructure to hold them all
42
+ ## once that is done, I can write them to the database...
43
+ Kernel.subclasses_of(ActiveRecord::Base).each do |cl|
44
+ if !cl.to_s.include?('ActiveRecord')
45
+ @models.push cl
37
46
  end
47
+ # Kernel.subclasses_of(ActiveRecord::Base).to_s.include?('user'.camelize)
38
48
  end
39
-
40
- # now I have all the models by name... construct a datastructure to hold them all
41
- # once that is done, I can write them to the database...
42
-
49
+ @model_reflections = {}
50
+ begin
51
+ @models.each do |model|
52
+ # if (Kernel.subclasses_of(ActiveRecord::Base).member?(model))
53
+ @model_reflections[:model] = eval("#{model}.reflections")
54
+ # end
55
+ end
56
+ rescue NameError => msg
57
+ puts "sorry, #{msg}"
58
+ end
59
+
60
+ # s.models.each {|a| if Kernel.const_defined?(a); puts a; else puts "couldnt find #{a}; end"}
61
+
43
62
  # This shows the columns for a particular table
44
63
  # >> puts s.source_db_connection.columns("work_efforts").each {|a| puts a.inspect}
45
64
 
data/steamer.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{steamer}
5
- s.version = "0.1.3.1"
5
+ s.version = "0.1.3.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Dave Rogers"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: davidtrogers-steamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.1
4
+ version: 0.1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Rogers