Kouhei Sutou
null+****@clear*****
Tue Jan 28 18:27:10 JST 2014
Kouhei Sutou 2014-01-28 18:27:10 +0900 (Tue, 28 Jan 2014) New Revision: 3a1e3d0617d24caddcb612a86056d62d8ca72725 https://github.com/ranguba/rroonga/commit/3a1e3d0617d24caddcb612a86056d62d8ca72725 Message: Use meaningful name for here document mark EOS -> SCHEMA Modified files: bin/grndump lib/groonga/dumper.rb test/test-database-dumper.rb Modified: bin/grndump (+8 -1) =================================================================== --- bin/grndump 2014-01-28 18:25:29 +0900 (7ab85eb) +++ bin/grndump 2014-01-28 18:27:10 +0900 (d849b90) @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # -*- coding: utf-8 -*- # -# Copyright (C) 2011-2012 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2014 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -26,6 +26,7 @@ options = OpenStruct.new options.tables = [] options.exclude_tables = [] options.dump_schema = true +options.dump_indexes = true options.dump_tables = true options.order_by = "id" option_parser = OptionParser.new do |parser| @@ -37,6 +38,11 @@ option_parser = OptionParser.new do |parser| options.dump_schema = boolean end + parser.on("--no-dump-indexes", + "don't dump indexes.") do |boolean| + options.dump_indexes = boolean + end + parser.on("--no-dump-tables", "don't dump tables.") do |boolean| options.dump_tables = boolean @@ -88,6 +94,7 @@ dumper_options = { :output => $stdout, :error_output => $stderr, :dump_schema => options.dump_schema, + :dump_indexes => options.dump_indexes, :dump_tables => options.dump_tables, :tables => options.tables, :exclude_tables => options.exclude_tables, Modified: lib/groonga/dumper.rb (+7 -3) =================================================================== --- lib/groonga/dumper.rb 2014-01-28 18:25:29 +0900 (43f6288) +++ lib/groonga/dumper.rb 2014-01-28 18:27:10 +0900 (4854eba) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2011-2012 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2011-2014 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -55,11 +55,15 @@ module Groonga options[:database] = options[:context].database end options[:dump_schema] = true if options[:dump_schema].nil? + options[:dump_indexes] = true if options[:dump_indexes].nil? options[:dump_tables] = true if options[:dump_tables].nil? + if options[:dump_schema] or options[:dump_indexes] + schema_dumper = SchemaDumper.new(options.merge(:syntax => :command)) + end + if options[:dump_schema] dump_plugins(options) - schema_dumper = SchemaDumper.new(options.merge(:syntax => :command)) schema_dumper.dump_tables if schema_dumper.have_reference_columns? options[:output].write("\n") @@ -67,7 +71,7 @@ module Groonga end end dump_tables(options) if options[:dump_tables] - if options[:dump_schema] and schema_dumper.have_index_columns? + if options[:dump_indexes] and schema_dumper.have_index_columns? options[:output].write("\n") schema_dumper.dump_index_columns end Modified: test/test-database-dumper.rb (+8 -8) =================================================================== --- test/test-database-dumper.rb 2014-01-28 18:25:29 +0900 (40f1206) +++ test/test-database-dumper.rb 2014-01-28 18:27:10 +0900 (ee38fca) @@ -69,17 +69,17 @@ class DatabaseDumperTest < Test::Unit::TestCase end def dumped_schema - <<-EOS + <<-SCHEMA #{dumped_schema_tables} #{dumped_schema_reference_columns} #{dumped_schema_index_columns} -EOS +SCHEMA end def dumped_schema_tables - <<-EOS.chomp + <<-SCHEMA.chomp table_create Posts TABLE_NO_KEY column_create Posts created_at COLUMN_SCALAR Time column_create Posts n_goods COLUMN_SCALAR UInt32 @@ -93,22 +93,22 @@ column_create Tags name COLUMN_SCALAR Text table_create Users TABLE_HASH_KEY --key_type ShortText column_create Users name COLUMN_SCALAR Text -EOS +SCHEMA end def dumped_schema_reference_columns - <<-EOS.chomp + <<-SCHEMA.chomp column_create Posts author COLUMN_SCALAR Users column_create Posts tags COLUMN_VECTOR Tags -EOS +SCHEMA end def dumped_schema_index_columns - <<-EOS.chomp + <<-SCHEMA.chomp column_create Tags Posts_tag_text COLUMN_INDEX Posts tag_text column_create Users Posts_author COLUMN_INDEX Posts author -EOS +SCHEMA end class EmptyTest < self -------------- next part -------------- HTML����������������������������...Download