Sha256: b34bdbcedf2d1631f3a1e867d1530bd73c6dc1eb6e6c0df8fd43c2b5a03f8c70
Contents?: true
Size: 826 Bytes
Versions: 1
Compression:
Stored size: 826 Bytes
Contents
class SimpleAuditGenerator < Rails::Generator::NamedBase def manifest record do |m| m.migration_template 'migration.rb', 'db/migrate', :assigns => { :migration_name => "CreateAudits" }, :migration_file_name => "create_audits" sentinel = 'ActionController::Routing::Routes.draw do |map|' logger.route "map.resources :audits" gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| "#{match}\n map.resources :audits\n map.resources :users, :has_many => 'audits'\n" end end end def gsub_file(relative_destination, regexp, *args, &block) path = destination_path(relative_destination) content = File.read(path).gsub(regexp, *args, &block) File.open(path, 'wb') { |file| file.write(content) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alfuken-simple_audit-0.0.1 | generators/simple_audit/simple_audit_generator.rb |