Class: RareMap::Mapper
- Inherits:
-
Object
- Object
- RareMap::Mapper
- Includes:
- ConfigLoader, ModelBuilder, ModelGenerator, RailsLocator, SchemaParser, SchemaReader
- Defined in:
- lib/rare_map.rb
Constant Summary
Constants included from ConfigLoader
Instance Method Summary collapse
-
#initialize ⇒ Mapper
constructor
A new instance of Mapper.
- #mapping ⇒ Object
Methods included from RailsLocator
Methods included from ConfigLoader
Methods included from SchemaReader
Methods included from SchemaParser
Methods included from ModelBuilder
Methods included from ModelGenerator
Constructor Details
#initialize ⇒ Mapper
Returns a new instance of Mapper.
16 17 18 |
# File 'lib/rare_map.rb', line 16 def initialize @rails_root = locate_rails_root end |
Instance Method Details
#mapping ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rare_map.rb', line 20 def mapping @db_profiles = load_config @rails_root ? @rails_root + 'config/' : './' @db_profiles.each do |profile| profile.schema = read_schema profile profile.tables = parse_schema profile.schema end @models = build_models @db_profiles generate_models @models, @rails_root if @rails_root puts '*****************************************************************' puts ' Activerecord models are generated. Enjoy it!' puts '*****************************************************************' else puts '*****************************************************************' puts ' A demo.rb is generated.' puts '*****************************************************************' generate_demo unless File.exist?('demo.rb') end @models rescue ConfigNotFoundError => e puts "Please put your database config in `#{'config/' if @rails_root}rare_map.yml`." end |