schema_comments 0.1.4 → 0.2.0.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,18 +3,18 @@ module SchemaComments
3
3
  module SchemaDumper
4
4
  def self.included(mod)
5
5
  # mod.extend(ClassMethods)
6
- # mod.instance_eval do
6
+ # mod.instance_eval do
7
7
  # alias :ignore_tables_without_schema_comments :ignore_tables
8
- # alias :ignore_tables :ignore_tables_with_schema_comments
8
+ # alias :ignore_tables :ignore_tables_with_schema_comments
9
9
  # end
10
- mod.module_eval do
10
+ mod.module_eval do
11
11
  alias_method_chain :tables, :schema_comments
12
12
  alias_method_chain :table, :schema_comments
13
13
  end
14
14
  end
15
-
15
+
16
16
  IGNORED_TABLE = 'schema_comments'
17
-
17
+
18
18
  # module ClassMethods
19
19
  # def ignore_tables_with_schema_comments
20
20
  # result = ignore_tables_without_schema_comments
@@ -22,7 +22,7 @@ module SchemaComments
22
22
  # result
23
23
  # end
24
24
  # end
25
-
25
+
26
26
  private
27
27
  def tables_with_schema_comments(stream)
28
28
  tables_without_schema_comments(stream)
@@ -36,7 +36,7 @@ module SchemaComments
36
36
  return if IGNORED_TABLE == table.downcase
37
37
  # MySQLは、ビューもテーブルとして扱うので、一個一個チェックします。
38
38
  if adapter_name == 'mysql'
39
- config = ActiveRecord::Base.configurations[RAILS_ENV]
39
+ config = ActiveRecord::Base.configurations[Rails.env]
40
40
  match_count = @connection.select_value(
41
41
  "select count(*) from information_schema.TABLES where TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'" % [
42
42
  config["database"], table])
@@ -60,10 +60,10 @@ module SchemaComments
60
60
  tbl.print ", :id => false"
61
61
  end
62
62
  tbl.print ", :force => true"
63
-
63
+
64
64
  table_comment = @connection.table_comment(table)
65
65
  tbl.print ", :comment => '#{table_comment}'" unless table_comment.blank?
66
-
66
+
67
67
  tbl.puts " do |t|"
68
68
 
69
69
  column_specs = columns.map do |column|
@@ -110,7 +110,7 @@ module SchemaComments
110
110
 
111
111
  tbl.puts " end"
112
112
  tbl.puts
113
-
113
+
114
114
  indexes(table, tbl)
115
115
 
116
116
  tbl.rewind
@@ -120,24 +120,24 @@ module SchemaComments
120
120
  stream.puts "# #{e.message}"
121
121
  stream.puts
122
122
  end
123
-
123
+
124
124
  stream
125
125
  end
126
126
 
127
127
  def adapter_name
128
- config = ActiveRecord::Base.configurations[RAILS_ENV]
128
+ config = ActiveRecord::Base.configurations[Rails.env]
129
129
  config ? config['adapter'] : ActiveRecord::Base.connection.adapter_name
130
130
  end
131
131
 
132
132
  def mysql_views(stream)
133
- config = ActiveRecord::Base.configurations[RAILS_ENV]
133
+ config = ActiveRecord::Base.configurations[Rails.env]
134
134
  view_names = @connection.select_values(
135
135
  "select TABLE_NAME from information_schema.TABLES where TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA = '%s'" % config["database"])
136
136
  view_names.each do |view_name|
137
137
  mysql_view(view_name, stream)
138
138
  end
139
139
  end
140
-
140
+
141
141
  def mysql_view(view_name, stream)
142
142
  ddl = @connection.select_value("show create view #{view_name}")
143
143
  ddl.gsub!(/^CREATE .+? VIEW /i, "CREATE OR REPLACE VIEW ")
@@ -157,6 +157,6 @@ module SchemaComments
157
157
  stream.print(ddl.split(/\n/).map{|line| ' ' << line.strip}.join("\n"))
158
158
  stream.print("\n EOS\n")
159
159
  end
160
-
160
+
161
161
  end
162
162
  end
@@ -1,6 +1,8 @@
1
+ require 'active_support/core_ext/module'
2
+
1
3
  module SchemaComments
2
4
  VERSION = '0.1.0'
3
-
5
+
4
6
  autoload :Base, 'schema_comments/base'
5
7
  autoload :ConnectionAdapters, 'schema_comments/connection_adapters'
6
8
  autoload :Migration, 'schema_comments/migration'
@@ -9,10 +11,10 @@ module SchemaComments
9
11
  autoload :SchemaComment, 'schema_comments/schema_comment'
10
12
  autoload :SchemaDumper, 'schema_comments/schema_dumper'
11
13
 
12
- DEFAULT_YAML_PATH = File.expand_path(File.join(RAILS_ROOT, 'db/schema_comments.yml'))
14
+ # DEFAULT_YAML_PATH = File.expand_path(File.join(RAILS_ROOT, 'db/schema_comments.yml'))
13
15
 
14
16
  mattr_accessor :yaml_path
15
- self.yaml_path = DEFAULT_YAML_PATH
17
+ # self.yaml_path = DEFAULT_YAML_PATH
16
18
 
17
19
  mattr_accessor :quiet
18
20
 
@@ -23,7 +25,7 @@ module SchemaComments
23
25
  def setup
24
26
  base_names = %w(Base Migration Migrator Schema SchemaDumper) +
25
27
  %w(Column ColumnDefinition TableDefinition).map{|name| "ConnectionAdapters::#{name}"}
26
-
28
+
27
29
  base_names.each do |base_name|
28
30
  ar_class = "ActiveRecord::#{base_name}".constantize
29
31
  sc_class = "SchemaComments::#{base_name}".constantize
@@ -31,13 +33,13 @@ module SchemaComments
31
33
  ar_class.__send__(:include, sc_class)
32
34
  end
33
35
  end
34
-
36
+
35
37
  unless ActiveRecord::ConnectionAdapters::AbstractAdapter.ancestors.include?(SchemaComments::ConnectionAdapters::Adapter)
36
38
  ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
37
39
  include SchemaComments::ConnectionAdapters::Adapter
38
40
  end
39
41
  end
40
-
42
+
41
43
  # %w(Mysql PostgreSQL SQLite3 SQLite Firebird DB2 Oracle Sybase Openbase Frontbase)
42
44
  %w(Mysql PostgreSQL SQLite3 SQLite).each do |adapter|
43
45
  begin
@@ -50,7 +52,7 @@ module SchemaComments
50
52
  end
51
53
  end
52
54
  end
53
-
55
+
54
56
  end
55
57
 
56
58
  end
@@ -1,121 +1,117 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{schema_comments}
8
- s.version = "0.1.4"
7
+ s.name = "schema_comments"
8
+ s.version = "0.2.0.alpha1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["akimatter"]
12
- s.date = %q{2010-04-14}
13
- s.description = %q{schema_comments generates extra methods dynamically for attribute which has options}
14
- s.email = %q{akm2000@gmail.com}
12
+ s.date = "2012-04-16"
13
+ s.description = "schema_comments generates extra methods dynamically for attribute which has options"
14
+ s.email = "akm2000@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
- ".gitignore",
21
- "LICENSE.txt",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "autotest/discover.rb",
26
- "init.rb",
27
- "lib/annotate_models.rb",
28
- "lib/hash_key_orderable.rb",
29
- "lib/schema_comments.rb",
30
- "lib/schema_comments/base.rb",
31
- "lib/schema_comments/connection_adapters.rb",
32
- "lib/schema_comments/migration.rb",
33
- "lib/schema_comments/migrator.rb",
34
- "lib/schema_comments/schema.rb",
35
- "lib/schema_comments/schema_comment.rb",
36
- "lib/schema_comments/schema_dumper.rb",
37
- "lib/schema_comments/task.rb",
38
- "schema_comments.gemspec",
39
- "spec/.gitignore",
40
- "spec/annotate_models_spec.rb",
41
- "spec/database.yml",
42
- "spec/fixtures/.gitignore",
43
- "spec/hash_key_orderable_spec.rb",
44
- "spec/i18n_export_spec.rb",
45
- "spec/migration_spec.rb",
46
- "spec/migrations/valid/001_create_products.rb",
47
- "spec/migrations/valid/002_rename_products.rb",
48
- "spec/migrations/valid/003_rename_products_again.rb",
49
- "spec/migrations/valid/004_remove_price.rb",
50
- "spec/migrations/valid/005_change_products_name.rb",
51
- "spec/migrations/valid/006_change_products_name_with_comment.rb",
52
- "spec/migrations/valid/007_change_comments.rb",
53
- "spec/migrations/valid/008_create_users_without_comment.rb",
54
- "spec/rcov.opts",
55
- "spec/resources/models/product.rb",
56
- "spec/resources/models/product_name.rb",
57
- "spec/schema.rb",
58
- "spec/schema_comments/.gitignore",
59
- "spec/schema_comments/connection_adapters_spec.rb",
60
- "spec/schema_comments/schema_comment_spec.rb",
61
- "spec/schema_comments/schema_comments_broken_column_comments.yml",
62
- "spec/schema_comments/schema_comments_broken_column_hash.yml",
63
- "spec/schema_comments/schema_comments_broken_table_comments.yml",
64
- "spec/schema_comments/schema_comments_users_without_column_hash.yml",
65
- "spec/schema_comments/schema_dumper_spec.rb",
66
- "spec/spec.opts",
67
- "spec/spec_helper.rb",
68
- "spec/yaml_export_spec.rb",
69
- "tasks/annotate_models_tasks.rake",
70
- "tasks/schema_comments.rake"
71
- ]
72
- s.homepage = %q{http://github.com/akm/schema_comments}
73
- s.rdoc_options = ["--charset=UTF-8"]
74
- s.require_paths = ["lib"]
75
- s.rubygems_version = %q{1.3.6}
76
- s.summary = %q{schema_comments generates extra methods dynamically}
77
- s.test_files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "autotest/discover.rb",
27
+ "init.rb",
28
+ "lib/annotate_models.rb",
29
+ "lib/hash_key_orderable.rb",
30
+ "lib/schema_comments.rb",
31
+ "lib/schema_comments/base.rb",
32
+ "lib/schema_comments/connection_adapters.rb",
33
+ "lib/schema_comments/migration.rb",
34
+ "lib/schema_comments/migrator.rb",
35
+ "lib/schema_comments/schema.rb",
36
+ "lib/schema_comments/schema_comment.rb",
37
+ "lib/schema_comments/schema_dumper.rb",
38
+ "lib/schema_comments/task.rb",
39
+ "schema_comments.gemspec",
40
+ "spec/.gitignore",
78
41
  "spec/annotate_models_spec.rb",
79
- "spec/hash_key_orderable_spec.rb",
80
- "spec/i18n_export_spec.rb",
81
- "spec/migration_spec.rb",
82
- "spec/migrations/valid/001_create_products.rb",
83
- "spec/migrations/valid/002_rename_products.rb",
84
- "spec/migrations/valid/003_rename_products_again.rb",
85
- "spec/migrations/valid/004_remove_price.rb",
86
- "spec/migrations/valid/005_change_products_name.rb",
87
- "spec/migrations/valid/006_change_products_name_with_comment.rb",
88
- "spec/migrations/valid/007_change_comments.rb",
89
- "spec/migrations/valid/008_create_users_without_comment.rb",
90
- "spec/resources/models/product.rb",
91
- "spec/resources/models/product_name.rb",
92
- "spec/schema.rb",
93
- "spec/schema_comments/connection_adapters_spec.rb",
94
- "spec/schema_comments/schema_comment_spec.rb",
95
- "spec/schema_comments/schema_dumper_spec.rb",
96
- "spec/spec_helper.rb",
97
- "spec/yaml_export_spec.rb",
98
- "spec/database.yml",
99
- "spec/human_readable_schema_comments.yml",
100
- "spec/schema_comments/schema_comments.yml",
101
- "spec/schema_comments/schema_comments_broken_column_comments.yml",
102
- "spec/schema_comments/schema_comments_broken_column_hash.yml",
103
- "spec/schema_comments/schema_comments_broken_table_comments.yml",
104
- "spec/schema_comments/schema_comments_users_without_column_hash.yml",
105
- "spec/schema_comments.yml"
42
+ "spec/database.yml",
43
+ "spec/fake_app.rb",
44
+ "spec/fixtures/.gitignore",
45
+ "spec/hash_key_orderable_spec.rb",
46
+ "spec/i18n_export_spec.rb",
47
+ "spec/migration_spec.rb",
48
+ "spec/migrations/valid/001_create_products.rb",
49
+ "spec/migrations/valid/002_rename_products.rb",
50
+ "spec/migrations/valid/003_rename_products_again.rb",
51
+ "spec/migrations/valid/004_remove_price.rb",
52
+ "spec/migrations/valid/005_change_products_name.rb",
53
+ "spec/migrations/valid/006_change_products_name_with_comment.rb",
54
+ "spec/migrations/valid/007_change_comments.rb",
55
+ "spec/migrations/valid/008_create_users_without_comment.rb",
56
+ "spec/rcov.opts",
57
+ "spec/resources/models/product.rb",
58
+ "spec/resources/models/product_name.rb",
59
+ "spec/schema.rb",
60
+ "spec/schema_comments/.gitignore",
61
+ "spec/schema_comments/connection_adapters_spec.rb",
62
+ "spec/schema_comments/schema_comment_spec.rb",
63
+ "spec/schema_comments/schema_comments_broken_column_comments.yml",
64
+ "spec/schema_comments/schema_comments_broken_column_hash.yml",
65
+ "spec/schema_comments/schema_comments_broken_table_comments.yml",
66
+ "spec/schema_comments/schema_comments_users_without_column_hash.yml",
67
+ "spec/schema_comments/schema_dumper_spec.rb",
68
+ "spec/spec.opts",
69
+ "spec/spec_helper.rb",
70
+ "spec/yaml_export_spec.rb",
71
+ "tasks/annotate_models_tasks.rake",
72
+ "tasks/schema_comments.rake"
106
73
  ]
74
+ s.homepage = "http://github.com/akm/schema_comments"
75
+ s.licenses = ["Ruby License"]
76
+ s.require_paths = ["lib"]
77
+ s.rubygems_version = "1.8.15"
78
+ s.summary = "schema_comments generates extra methods dynamically"
79
+ s.test_files = ["spec/annotate_models_spec.rb", "spec/fake_app.rb", "spec/hash_key_orderable_spec.rb", "spec/i18n_export_spec.rb", "spec/migration_spec.rb", "spec/migrations/valid/001_create_products.rb", "spec/migrations/valid/002_rename_products.rb", "spec/migrations/valid/003_rename_products_again.rb", "spec/migrations/valid/004_remove_price.rb", "spec/migrations/valid/005_change_products_name.rb", "spec/migrations/valid/006_change_products_name_with_comment.rb", "spec/migrations/valid/007_change_comments.rb", "spec/migrations/valid/008_create_users_without_comment.rb", "spec/resources/models/product.rb", "spec/resources/models/product_name.rb", "spec/schema.rb", "spec/schema_comments/connection_adapters_spec.rb", "spec/schema_comments/schema_comment_spec.rb", "spec/schema_comments/schema_dumper_spec.rb", "spec/spec_helper.rb", "spec/yaml_export_spec.rb", "spec/database.yml", "spec/human_readable_schema_comments.yml", "spec/schema_comments/schema_comments.yml", "spec/schema_comments/schema_comments_broken_column_comments.yml", "spec/schema_comments/schema_comments_broken_column_hash.yml", "spec/schema_comments/schema_comments_broken_table_comments.yml", "spec/schema_comments/schema_comments_users_without_column_hash.yml", "spec/schema_comments.yml"]
107
80
 
108
81
  if s.respond_to? :specification_version then
109
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
110
82
  s.specification_version = 3
111
83
 
112
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
113
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
84
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
85
+ s.add_runtime_dependency(%q<activesupport>, ["~> 3.1.0"])
86
+ s.add_runtime_dependency(%q<activerecord>, ["~> 3.1.0"])
87
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
88
+ s.add_development_dependency(%q<rspec-rails>, ["~> 2.8.1"])
89
+ s.add_development_dependency(%q<yard>, ["~> 0.7"])
90
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
91
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
92
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
93
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
114
94
  else
115
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
95
+ s.add_dependency(%q<activesupport>, ["~> 3.1.0"])
96
+ s.add_dependency(%q<activerecord>, ["~> 3.1.0"])
97
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
98
+ s.add_dependency(%q<rspec-rails>, ["~> 2.8.1"])
99
+ s.add_dependency(%q<yard>, ["~> 0.7"])
100
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
101
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
102
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
103
+ s.add_dependency(%q<simplecov>, [">= 0"])
116
104
  end
117
105
  else
118
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
106
+ s.add_dependency(%q<activesupport>, ["~> 3.1.0"])
107
+ s.add_dependency(%q<activerecord>, ["~> 3.1.0"])
108
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
109
+ s.add_dependency(%q<rspec-rails>, ["~> 2.8.1"])
110
+ s.add_dependency(%q<yard>, ["~> 0.7"])
111
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
112
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
113
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
114
+ s.add_dependency(%q<simplecov>, [">= 0"])
119
115
  end
120
116
  end
121
117
 
@@ -15,10 +15,10 @@ describe AnnotateModels do
15
15
  ActiveRecord::Base.connection.initialize_schema_migrations_table
16
16
  ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}"
17
17
  end
18
-
18
+
19
19
  it "get_schema_info" do
20
20
  (ActiveRecord::Base.connection.tables - %w(schema_migrations)).should == []
21
-
21
+
22
22
  ActiveRecord::Schema.define(:version => "20090721185959") do
23
23
  drop_table("books") rescue nil
24
24
 
@@ -52,5 +52,5 @@ describe AnnotateModels do
52
52
  #
53
53
  }
54
54
  end
55
-
55
+
56
56
  end
data/spec/fake_app.rb ADDED
@@ -0,0 +1,17 @@
1
+
2
+ # see https://github.com/amatsuda/kaminari/blob/master/spec/fake_app.rb
3
+
4
+ require 'active_record'
5
+ require 'action_controller/railtie'
6
+ require 'action_view/railtie'
7
+
8
+ # database
9
+ ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
10
+ ActiveRecord::Base.establish_connection('test')
11
+
12
+ # config
13
+ app = Class.new(Rails::Application)
14
+ app.config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
15
+ app.config.session_store :cookie_store, :key => "_myapp_session"
16
+ app.config.active_support.deprecation = :log
17
+ app.initialize!
@@ -47,4 +47,4 @@ describe HashKeyOrderable do
47
47
  end
48
48
 
49
49
  end
50
- end
50
+ end
@@ -13,32 +13,32 @@ describe SchemaComments::Base do
13
13
  ActiveRecord::Base.connection.initialize_schema_migrations_table
14
14
  ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}"
15
15
  end
16
-
16
+
17
17
  it "test_valid_migration" do
18
18
  (ActiveRecord::Base.connection.tables - %w(schema_migrations)).should == []
19
-
19
+
20
20
  migration_path = File.join(MIGRATIONS_ROOT, 'valid')
21
21
  Dir.glob('*.rb').each do |file|
22
22
  require(file) if /^\d+?_.*/ =~ file
23
23
  end
24
-
24
+
25
25
  Product.reset_table_comments
26
26
  Product.reset_column_comments
27
27
 
28
28
  ActiveRecord::Migrator.up(migration_path, 1)
29
29
  ActiveRecord::Migrator.current_version.should == 1
30
-
30
+
31
31
  ActiveRecord::Base.export_i18n_models.keys.include?('product').should == true
32
32
  ActiveRecord::Base.export_i18n_models['product'].should == '商品'
33
-
33
+
34
34
  ActiveRecord::Base.export_i18n_attributes.keys.include?('product').should == true
35
35
  ActiveRecord::Base.export_i18n_attributes['product'].should == {
36
- 'product_type_cd' => '種別コード',
36
+ 'product_type_cd' => '種別コード',
37
37
  "price" => "価格",
38
38
  "name" => "商品名",
39
39
  "created_at" => "登録日時",
40
40
  "updated_at" => "更新日時"
41
41
  }
42
42
  end
43
-
43
+
44
44
  end
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  class CreateProducts < ActiveRecord::Migration
3
-
3
+
4
4
  def self.up
5
5
  create_table "products", :comment => '商品' do |t|
6
6
  t.string "product_type_cd", :comment => '種別コード'
@@ -8,7 +8,7 @@ describe SchemaComments::ConnectionAdapters do
8
8
  before(:each) do
9
9
  SchemaComments.yaml_path = File.expand_path(File.join(File.dirname(__FILE__), 'schema_comments.yml'))
10
10
  FileUtils.rm(SchemaComments.yaml_path, :verbose => true) if File.exist?(SchemaComments.yaml_path)
11
-
11
+
12
12
  (ActiveRecord::Base.connection.tables - IGNORED_TABLES).each do |t|
13
13
  ActiveRecord::Base.connection.drop_table(t) rescue nil
14
14
  end
@@ -16,31 +16,31 @@ describe SchemaComments::ConnectionAdapters do
16
16
  ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}"
17
17
 
18
18
  (ActiveRecord::Base.connection.tables - %w(schema_migrations)).should == []
19
-
19
+
20
20
  migration_path = File.join(MIGRATIONS_ROOT, 'valid')
21
21
  Dir.glob('*.rb').each do |file|
22
22
  require(file) if /^\d+?_.*/ =~ file
23
23
  end
24
-
24
+
25
25
  Product.reset_table_comments
26
26
  Product.reset_column_comments
27
-
27
+
28
28
  ActiveRecord::Migrator.up(migration_path, 1)
29
29
  ActiveRecord::Migrator.current_version.should == 1
30
30
 
31
31
  ActiveRecord::Base.export_i18n_models.keys.include?('product').should == true
32
32
  ActiveRecord::Base.export_i18n_models['product'].should == '商品'
33
-
33
+
34
34
  ActiveRecord::Base.export_i18n_attributes.keys.include?('product').should == true
35
35
  ActiveRecord::Base.export_i18n_attributes['product'].should == {
36
- 'product_type_cd' => '種別コード',
36
+ 'product_type_cd' => '種別コード',
37
37
  "price" => "価格",
38
38
  "name" => "商品名",
39
39
  "created_at" => "登録日時",
40
40
  "updated_at" => "更新日時"
41
41
  }
42
42
  end
43
-
43
+
44
44
  describe SchemaComments::ConnectionAdapters::Column do
45
45
  describe :comment do
46
46
  it "should return comment" do
@@ -8,7 +8,7 @@ describe SchemaComments::SchemaComment do
8
8
  before(:each) do
9
9
  SchemaComments.yaml_path = File.expand_path(File.join(File.dirname(__FILE__), 'schema_comments.yml'))
10
10
  FileUtils.rm(SchemaComments.yaml_path, :verbose => true) if File.exist?(SchemaComments.yaml_path)
11
-
11
+
12
12
  (ActiveRecord::Base.connection.tables - IGNORED_TABLES).each do |t|
13
13
  ActiveRecord::Base.connection.drop_table(t) rescue nil
14
14
  end
@@ -45,7 +45,7 @@ describe SchemaComments::SchemaComment do
45
45
  ActiveRecord::Migrator.up(migration_path, 8)
46
46
  ActiveRecord::Migrator.current_version.should == 8
47
47
 
48
- SchemaComments.yaml_path =
48
+ SchemaComments.yaml_path =
49
49
  File.expand_path(File.join(
50
50
  File.dirname(__FILE__), "schema_comments_users_without_column_hash.yml"))
51
51
  SchemaComments::SchemaComment.yaml_access do |db|
@@ -64,7 +64,7 @@ describe SchemaComments::SchemaComment do
64
64
  ActiveRecord::Migrator.up(migration_path, 8)
65
65
  ActiveRecord::Migrator.current_version.should == 8
66
66
 
67
- SchemaComments.yaml_path =
67
+ SchemaComments.yaml_path =
68
68
  File.expand_path(File.join(
69
69
  File.dirname(__FILE__), "schema_comments_broken_#{broken_type}.yml"))
70
70
  lambda{
@@ -72,7 +72,7 @@ describe SchemaComments::SchemaComment do
72
72
  }.should raise_error(SchemaComments::YamlError)
73
73
  end
74
74
  end
75
-
75
+
76
76
  end
77
77
 
78
78
  end
@@ -3,7 +3,8 @@ table_comments:
3
3
  products: "商品"
4
4
  column_comments:
5
5
  products:
6
- product_type_cd: "カテゴリコード"
7
- name: "商品名称"
6
+ product_type_cd: "種別コード"
7
+ price: "価格"
8
+ name: "商品名"
8
9
  created_at: "登録日時"
9
10
  updated_at: "更新日時"
@@ -8,14 +8,14 @@ describe ActiveRecord::SchemaDumper do
8
8
  before(:each) do
9
9
  SchemaComments.yaml_path = File.expand_path(File.join(File.dirname(__FILE__), 'schema_comments.yml'))
10
10
  FileUtils.rm(SchemaComments.yaml_path, :verbose => true) if File.exist?(SchemaComments.yaml_path)
11
-
11
+
12
12
  (ActiveRecord::Base.connection.tables - IGNORED_TABLES).each do |t|
13
13
  ActiveRecord::Base.connection.drop_table(t) rescue nil
14
14
  end
15
15
  ActiveRecord::Base.connection.initialize_schema_migrations_table
16
16
  ActiveRecord::Base.connection.execute "DELETE FROM #{ActiveRecord::Migrator.schema_migrations_table_name}"
17
17
  end
18
-
18
+
19
19
  describe :dump do
20
20
  it "products" do
21
21
  (ActiveRecord::Base.connection.tables - %w(schema_migrations)).should == []
@@ -34,7 +34,7 @@ describe ActiveRecord::SchemaDumper do
34
34
 
35
35
  ActiveRecord::Base.export_i18n_attributes.keys.include?('product').should == true
36
36
  ActiveRecord::Base.export_i18n_attributes['product'].should == {
37
- 'product_type_cd' => '種別コード',
37
+ 'product_type_cd' => '種別コード',
38
38
  "price" => "価格",
39
39
  "name" => "商品名",
40
40
  "created_at" => "登録日時",
@@ -45,13 +45,15 @@ describe ActiveRecord::SchemaDumper do
45
45
  ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, dest)
46
46
  dest.rewind
47
47
  dest.read.should == <<EOS
48
- # This file is auto-generated from the current state of the database. Instead of editing this file,
49
- # please use the migrations feature of Active Record to incrementally modify your database, and
50
- # then regenerate this schema definition.
48
+ # encoding: UTF-8
49
+ # This file is auto-generated from the current state of the database. Instead
50
+ # of editing this file, please use the migrations feature of Active Record to
51
+ # incrementally modify your database, and then regenerate this schema definition.
51
52
  #
52
- # Note that this schema.rb definition is the authoritative source for your database schema. If you need
53
- # to create the application database on another system, you should be using db:schema:load, not running
54
- # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
53
+ # Note that this schema.rb definition is the authoritative source for your
54
+ # database schema. If you need to create the application database on another
55
+ # system, you should be using db:schema:load, not running all the migrations
56
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
55
57
  # you'll amass, the slower it'll run and the greater likelihood for issues).
56
58
  #
57
59
  # It's strongly recommended to check this file into your version control system.