Class: GraphqlMigrateExecution::Migration
- Inherits:
-
Object
- Object
- GraphqlMigrateExecution::Migration
- Defined in:
- lib/graphql_migrate_execution/migration.rb
Overview
A run of this tool, called by ‘bin/graphql_migrate_execution`.
Instance Attribute Summary collapse
-
#action_method ⇒ Object
readonly
Returns the value of attribute action_method.
-
#colorable ⇒ Object
readonly
Returns the value of attribute colorable.
-
#implicit ⇒ Object
readonly
Returns the value of attribute implicit.
Instance Method Summary collapse
-
#initialize(glob, dry_run: false, migrate: false, cleanup: false, implicit: nil, colorable: IRB::Color.colorable?) ⇒ Migration
constructor
A new instance of Migration.
- #run ⇒ Object
Constructor Details
#initialize(glob, dry_run: false, migrate: false, cleanup: false, implicit: nil, colorable: IRB::Color.colorable?) ⇒ Migration
Returns a new instance of Migration.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/graphql_migrate_execution/migration.rb', line 5 def initialize(glob, dry_run: false, migrate: false, cleanup: false, implicit: nil, colorable: IRB::Color.colorable?) @glob = glob if /\/[^.]*$/.match?(@glob) if !@glob.end_with?("/") @glob += "/" end @glob += "*.rb" end @dry_run = dry_run || (migrate == false && cleanup == false) @colorable = colorable @implicit = implicit @action_method = if migrate :migrate elsif cleanup :cleanup else :analyze end end |
Instance Attribute Details
#action_method ⇒ Object (readonly)
Returns the value of attribute action_method.
25 26 27 |
# File 'lib/graphql_migrate_execution/migration.rb', line 25 def action_method @action_method end |
#colorable ⇒ Object (readonly)
Returns the value of attribute colorable.
25 26 27 |
# File 'lib/graphql_migrate_execution/migration.rb', line 25 def colorable @colorable end |
#implicit ⇒ Object (readonly)
Returns the value of attribute implicit.
25 26 27 |
# File 'lib/graphql_migrate_execution/migration.rb', line 25 def implicit @implicit end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/graphql_migrate_execution/migration.rb', line 27 def run files = Dir.glob(@glob) if files.size.zero? warn "No files found for #{@glob.inspect}" end files.each do |filepath| source = File.read(filepath) action = Action.new(self, filepath, source) action.run if !@dry_run File.write(filepath, action.result_source) end puts action. end end |