Skip to content

Commit

Permalink
fix a couple little issues
Browse files Browse the repository at this point in the history
1. don't display warnings when generating schema.rb, since it's just a
   lot of noise with no context
2. don't choke on 1.9 syntax in schema.rb
3. allow create_trigger to be called w/ a name and no options
  • Loading branch information
jenseng committed Apr 1, 2014
1 parent 7418320 commit 799ac5e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/hair_trigger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def current_migrations(options = {})
if previous_schema = (options.has_key?(:previous_schema) ? options[:previous_schema] : File.exist?(schema_rb_path) && File.read(schema_rb_path))
base_triggers = MigrationReader.get_triggers(previous_schema, options)
unless base_triggers.empty?
version = (previous_schema =~ /ActiveRecord::Schema\.define\(:version => (\d+)\)/) && $1.to_i
version = (previous_schema =~ /ActiveRecord::Schema\.define\(.*?(\d+)\)/) && $1.to_i
migrations.unshift [OpenStruct.new({:version => version}), base_triggers]
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/hair_trigger/migration_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def extract_method_call(exp)
def generate_create_trigger(*arguments)
arguments.unshift({}) if arguments.empty?
arguments.unshift(nil) if arguments.first.is_a?(Hash)
arguments.push({}) if arguments.size == 1
arguments[1][:compatibility] ||= HairTrigger::Builder.base_compatibility
::HairTrigger::Builder.new(*arguments)
end
Expand Down
6 changes: 5 additions & 1 deletion lib/hair_trigger/schema_dumper.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module HairTrigger
module SchemaDumper
def trailer_with_triggers(stream)
orig_show_warnings = Builder.show_warnings
Builder.show_warnings = false # we already show them when running the migration
triggers(stream)
trailer_without_triggers(stream)
ensure
Builder.show_warnings = orig_show_warnings
end

def triggers(stream)
Expand Down Expand Up @@ -84,4 +88,4 @@ class << self
end
end
end
end
end

0 comments on commit 799ac5e

Please sign in to comment.