schema_comments 0.2.0.alpha2 → 0.2.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/VERSION +1 -1
- data/lib/schema_comments/base.rb +1 -1
- data/lib/schema_comments/connection_adapters.rb +5 -5
- data/lib/schema_comments/schema_comment.rb +17 -40
- data/lib/schema_comments/schema_dumper.rb +39 -50
- data/lib/schema_comments.rb +3 -5
- data/schema_comments.gemspec +6 -3
- data/tasks/schema_comments.rake +27 -63
- metadata +33 -22
- data/autotest/discover.rb +0 -10
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
ZenTest (4.7.0)
|
4
5
|
actionmailer (3.2.3)
|
5
6
|
actionpack (= 3.2.3)
|
6
7
|
mail (~> 2.4.4)
|
@@ -109,6 +110,7 @@ PLATFORMS
|
|
109
110
|
ruby
|
110
111
|
|
111
112
|
DEPENDENCIES
|
113
|
+
ZenTest
|
112
114
|
activerecord (>= 3.0.0)
|
113
115
|
activesupport (>= 3.0.0)
|
114
116
|
bundler (~> 1.0.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.0.
|
1
|
+
0.2.0.alpha3
|
data/lib/schema_comments/base.rb
CHANGED
@@ -42,7 +42,7 @@ module SchemaComments
|
|
42
42
|
klass.respond_to?(:table_exists?) and klass.table_exists?
|
43
43
|
end
|
44
44
|
subclasses.inject({}) do |d, m|
|
45
|
-
comment = m.table_comment
|
45
|
+
comment = m.table_comment || ''
|
46
46
|
comment.gsub!(ignore_pattern_to_export_i18n, '') if ignore_pattern_to_export_i18n
|
47
47
|
d[m.name.underscore] = comment
|
48
48
|
d
|
@@ -83,12 +83,12 @@ module SchemaComments
|
|
83
83
|
module ConcreteAdapter
|
84
84
|
def self.included(mod)
|
85
85
|
mod.module_eval do
|
86
|
-
alias_method_chain :columns, :schema_comments
|
87
|
-
alias_method_chain :create_table, :schema_comments
|
88
|
-
alias_method_chain :drop_table, :schema_comments
|
89
|
-
alias_method_chain :rename_table, :schema_comments
|
86
|
+
alias_method_chain :columns , :schema_comments
|
87
|
+
alias_method_chain :create_table , :schema_comments
|
88
|
+
alias_method_chain :drop_table , :schema_comments
|
89
|
+
alias_method_chain :rename_table , :schema_comments
|
90
90
|
alias_method_chain :remove_column, :schema_comments
|
91
|
-
alias_method_chain :add_column, :schema_comments
|
91
|
+
alias_method_chain :add_column , :schema_comments
|
92
92
|
alias_method_chain :change_column, :schema_comments
|
93
93
|
alias_method_chain :rename_column, :schema_comments
|
94
94
|
end
|
@@ -4,46 +4,28 @@ require 'hash_key_orderable'
|
|
4
4
|
|
5
5
|
module SchemaComments
|
6
6
|
|
7
|
-
|
8
|
-
# 時点で、ActiveRecord::Baseの継承をやめます。
|
9
|
-
#
|
10
|
-
# それまではDBからのロードは可能ですが、YAMLにのみ保存します。
|
11
|
-
class SchemaComment < ActiveRecord::Base
|
12
|
-
set_table_name('schema_comments')
|
7
|
+
class SchemaComment
|
13
8
|
|
14
9
|
TABLE_KEY = 'table_comments'
|
15
10
|
COLUMN_KEY = 'column_comments'
|
16
11
|
|
17
12
|
class << self
|
18
13
|
def table_comment(table_name)
|
19
|
-
|
20
|
-
|
21
|
-
return @table_names[table_name.to_s]
|
22
|
-
end
|
23
|
-
return nil unless table_exists?
|
24
|
-
connection.select_value(sanitize_conditions("select descriptions from schema_comments where table_name = '%s' and column_name is null" % table_name))
|
14
|
+
@table_names ||= yaml_access{|db| db[TABLE_KEY]}.dup
|
15
|
+
@table_names[table_name.to_s]
|
25
16
|
end
|
26
17
|
|
27
18
|
def column_comment(table_name, column_name)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
return column_hash[column_name.to_s]
|
32
|
-
end
|
33
|
-
return nil unless table_exists?
|
34
|
-
connection.select_value(sanitize_conditions("select descriptions from schema_comments where table_name = '%s' and column_name = '%s'" % [table_name, column_name]))
|
19
|
+
@column_names ||= yaml_access{|db| db[COLUMN_KEY] }.dup
|
20
|
+
column_hash = @column_names[table_name.to_s] || {}
|
21
|
+
column_hash[column_name.to_s]
|
35
22
|
end
|
36
23
|
|
37
24
|
def column_comments(table_name)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
return result || {}
|
43
|
-
end
|
44
|
-
return {} unless table_exists?
|
45
|
-
hash_array = connection.select_all(sanitize_conditions("select column_name, descriptions from schema_comments where table_name = '%s' and column_name is not null" % table_name))
|
46
|
-
hash_array.inject({}){|dest, r| dest[r['column_name']] = r['descriptions']; dest}
|
25
|
+
result = nil
|
26
|
+
@column_names ||= yaml_access{|db| db[COLUMN_KEY] }.dup
|
27
|
+
result = @column_names[table_name.to_s]
|
28
|
+
result || {}
|
47
29
|
end
|
48
30
|
|
49
31
|
def save_table_comment(table_name, comment)
|
@@ -70,23 +52,19 @@ module SchemaComments
|
|
70
52
|
end
|
71
53
|
|
72
54
|
def update_table_name(table_name, new_name)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
db[COLUMN_KEY][new_name.to_s] = db[COLUMN_KEY].delete(table_name.to_s)
|
77
|
-
end
|
55
|
+
yaml_access do |db|
|
56
|
+
db[TABLE_KEY][new_name.to_s] = db[TABLE_KEY].delete(table_name.to_s)
|
57
|
+
db[COLUMN_KEY][new_name.to_s] = db[COLUMN_KEY].delete(table_name.to_s)
|
78
58
|
end
|
79
59
|
@table_names = nil
|
80
60
|
@column_names = nil
|
81
61
|
end
|
82
62
|
|
83
63
|
def update_column_name(table_name, column_name, new_name)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
table_cols[new_name.to_s] = table_cols.delete(column_name.to_s)
|
89
|
-
end
|
64
|
+
yaml_access do |db|
|
65
|
+
table_cols = db[COLUMN_KEY][table_name.to_s]
|
66
|
+
if table_cols
|
67
|
+
table_cols[new_name.to_s] = table_cols.delete(column_name.to_s)
|
90
68
|
end
|
91
69
|
end
|
92
70
|
@table_names = nil
|
@@ -118,7 +96,6 @@ module SchemaComments
|
|
118
96
|
result
|
119
97
|
end
|
120
98
|
end
|
121
|
-
|
122
99
|
end
|
123
100
|
|
124
101
|
class SortedStore < YAML::Store
|
@@ -1,55 +1,38 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
module SchemaComments
|
3
|
-
|
4
|
-
def self.included(mod)
|
5
|
-
# mod.extend(ClassMethods)
|
6
|
-
# mod.instance_eval do
|
7
|
-
# alias :ignore_tables_without_schema_comments :ignore_tables
|
8
|
-
# alias :ignore_tables :ignore_tables_with_schema_comments
|
9
|
-
# end
|
10
|
-
mod.module_eval do
|
11
|
-
alias_method_chain :tables, :schema_comments
|
12
|
-
alias_method_chain :table, :schema_comments
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
IGNORED_TABLE = 'schema_comments'
|
17
|
-
|
18
|
-
# module ClassMethods
|
19
|
-
# def ignore_tables_with_schema_comments
|
20
|
-
# result = ignore_tables_without_schema_comments
|
21
|
-
# result << IGNORED_TABLE unless result.include?(IGNORED_TABLE)
|
22
|
-
# result
|
23
|
-
# end
|
24
|
-
# end
|
3
|
+
class SchemaDumper < ActiveRecord::SchemaDumper
|
25
4
|
|
26
5
|
private
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
6
|
+
def tables(stream)
|
7
|
+
result = super(stream)
|
8
|
+
# ビューはtableの後に実行するようにしないと rake db:schema:load で失敗します。
|
9
|
+
mysql_views(stream) if adapter_name == "mysql"
|
10
|
+
result
|
33
11
|
end
|
34
12
|
|
35
|
-
def
|
36
|
-
return
|
13
|
+
def mysql_view?(table)
|
14
|
+
return false unless adapter_name == 'mysql'
|
15
|
+
config = ActiveRecord::Base.configurations[Rails.env]
|
16
|
+
match_count = @connection.select_value(
|
17
|
+
"select count(*) from information_schema.TABLES where TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'" % [
|
18
|
+
config["database"], table])
|
19
|
+
match_count.to_i > 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def table(table, stream)
|
37
23
|
# MySQLは、ビューもテーブルとして扱うので、一個一個チェックします。
|
38
|
-
if
|
39
|
-
|
40
|
-
match_count = @connection.select_value(
|
41
|
-
"select count(*) from information_schema.TABLES where TABLE_TYPE = 'VIEW' AND TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'" % [
|
42
|
-
config["database"], table])
|
43
|
-
return if match_count.to_i > 0
|
44
|
-
end
|
24
|
+
return if mysql_view?(table)
|
25
|
+
|
45
26
|
columns = @connection.columns(table)
|
46
27
|
begin
|
47
28
|
tbl = StringIO.new
|
48
29
|
|
30
|
+
# first dump primary key column
|
49
31
|
if @connection.respond_to?(:pk_and_sequence_for)
|
50
|
-
pk,
|
32
|
+
pk, _ = @connection.pk_and_sequence_for(table)
|
33
|
+
elsif @connection.respond_to?(:primary_key)
|
34
|
+
pk = @connection.primary_key(table)
|
51
35
|
end
|
52
|
-
pk ||= 'id'
|
53
36
|
|
54
37
|
tbl.print " create_table #{table.inspect}"
|
55
38
|
if columns.detect { |c| c.name == pk }
|
@@ -66,32 +49,38 @@ module SchemaComments
|
|
66
49
|
|
67
50
|
tbl.puts " do |t|"
|
68
51
|
|
52
|
+
# then dump all non-primary key columns
|
69
53
|
column_specs = columns.map do |column|
|
70
54
|
raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" if @types[column.type].nil?
|
71
55
|
next if column.name == pk
|
72
56
|
spec = {}
|
73
57
|
spec[:name] = column.name.inspect
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
spec[:
|
78
|
-
|
79
|
-
|
58
|
+
|
59
|
+
# AR has an optimization which handles zero-scale decimals as integers. This
|
60
|
+
# code ensures that the dumper still dumps the column as a decimal.
|
61
|
+
spec[:type] = if column.type == :integer && [/^numeric/, /^decimal/].any? { |e| e.match(column.sql_type) }
|
62
|
+
'decimal'
|
63
|
+
else
|
64
|
+
column.type.to_s
|
65
|
+
end
|
66
|
+
spec[:limit] = column.limit.inspect if column.limit != @types[column.type][:limit] && spec[:type] != 'decimal'
|
67
|
+
spec[:precision] = column.precision.inspect if column.precision
|
68
|
+
spec[:scale] = column.scale.inspect if column.scale
|
69
|
+
spec[:null] = 'false' unless column.null
|
70
|
+
spec[:default] = default_string(column.default) if column.has_default?
|
80
71
|
spec[:comment] = '"' << (column.comment || '').gsub(/\"/, '\"') << '"' # ここでinspectを使うと最後の文字だけ文字化け(UTF-8のコード)になっちゃう
|
81
72
|
(spec.keys - [:name, :type]).each{ |k| spec[k].insert(0, "#{k.inspect} => ")}
|
82
73
|
spec
|
83
74
|
end.compact
|
84
75
|
|
85
76
|
# find all migration keys used in this table
|
86
|
-
keys = [:name, :limit, :precision, :scale, :default, :null, :comment] & column_specs.map
|
77
|
+
keys = [:name, :limit, :precision, :scale, :default, :null, :comment] & column_specs.map{ |k| k.keys }.flatten
|
87
78
|
|
88
79
|
# figure out the lengths for each column based on above keys
|
89
|
-
lengths = keys.map{ |key|
|
90
|
-
column_specs.map{ |spec| spec[key] ? spec[key].length + 2 : 0 }.max
|
91
|
-
}
|
80
|
+
lengths = keys.map{ |key| column_specs.map{ |spec| spec[key] ? spec[key].length + 2 : 0 }.max }
|
92
81
|
|
93
82
|
# the string we're going to sprintf our values against, with standardized column widths
|
94
|
-
format_string = lengths.map{|len|
|
83
|
+
format_string = lengths.map{ |len| "%-#{len}s" }
|
95
84
|
|
96
85
|
# find the max length for the 'type' column, which is special
|
97
86
|
type_length = column_specs.map{ |column| column[:type].length }.max
|
data/lib/schema_comments.rb
CHANGED
@@ -11,10 +11,8 @@ module SchemaComments
|
|
11
11
|
autoload :SchemaComment, 'schema_comments/schema_comment'
|
12
12
|
autoload :SchemaDumper, 'schema_comments/schema_dumper'
|
13
13
|
|
14
|
-
# DEFAULT_YAML_PATH = File.expand_path(File.join(RAILS_ROOT, 'db/schema_comments.yml'))
|
15
|
-
|
16
14
|
mattr_accessor :yaml_path
|
17
|
-
|
15
|
+
self.yaml_path = Rails.root.join("db/schema_comments.yml").to_s if defined?(Rails)
|
18
16
|
|
19
17
|
mattr_accessor :quiet
|
20
18
|
|
@@ -23,7 +21,7 @@ module SchemaComments
|
|
23
21
|
|
24
22
|
class << self
|
25
23
|
def setup
|
26
|
-
base_names = %w(Base Migration Migrator Schema
|
24
|
+
base_names = %w(Base Migration Migrator Schema) +
|
27
25
|
%w(Column ColumnDefinition TableDefinition).map{|name| "ConnectionAdapters::#{name}"}
|
28
26
|
|
29
27
|
base_names.each do |base_name|
|
@@ -41,7 +39,7 @@ module SchemaComments
|
|
41
39
|
end
|
42
40
|
|
43
41
|
# %w(Mysql PostgreSQL SQLite3 SQLite Firebird DB2 Oracle Sybase Openbase Frontbase)
|
44
|
-
%w(Mysql PostgreSQL SQLite3 SQLite).each do |adapter|
|
42
|
+
%w(Mysql Mysql2 PostgreSQL SQLite3 SQLite).each do |adapter|
|
45
43
|
begin
|
46
44
|
require("active_record/connection_adapters/#{adapter.downcase}_adapter")
|
47
45
|
adapter_class = ('ActiveRecord::ConnectionAdapters::' << "#{adapter}Adapter").constantize
|
data/schema_comments.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "schema_comments"
|
8
|
-
s.version = "0.2.0.
|
8
|
+
s.version = "0.2.0.alpha3"
|
9
9
|
|
10
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 = "2012-04-
|
12
|
+
s.date = "2012-04-17"
|
13
13
|
s.description = "schema_comments generates extra methods dynamically for attribute which has options"
|
14
14
|
s.email = "akm2000@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,13 +17,13 @@ Gem::Specification.new do |s|
|
|
17
17
|
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
|
+
".rspec",
|
20
21
|
"Gemfile",
|
21
22
|
"Gemfile.lock",
|
22
23
|
"LICENSE.txt",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
25
26
|
"VERSION",
|
26
|
-
"autotest/discover.rb",
|
27
27
|
"init.rb",
|
28
28
|
"lib/annotate_models.rb",
|
29
29
|
"lib/hash_key_orderable.rb",
|
@@ -91,6 +91,7 @@ Gem::Specification.new do |s|
|
|
91
91
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
92
92
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
93
93
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
94
|
+
s.add_development_dependency(%q<ZenTest>, [">= 0"])
|
94
95
|
else
|
95
96
|
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
96
97
|
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
@@ -101,6 +102,7 @@ Gem::Specification.new do |s|
|
|
101
102
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
102
103
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
103
104
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
105
|
+
s.add_dependency(%q<ZenTest>, [">= 0"])
|
104
106
|
end
|
105
107
|
else
|
106
108
|
s.add_dependency(%q<activesupport>, [">= 3.0.0"])
|
@@ -112,6 +114,7 @@ Gem::Specification.new do |s|
|
|
112
114
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
113
115
|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
114
116
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
117
|
+
s.add_dependency(%q<ZenTest>, [">= 0"])
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
data/tasks/schema_comments.rake
CHANGED
@@ -1,79 +1,43 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'yaml'
|
3
|
-
require 'yaml_waml'
|
3
|
+
# require 'yaml_waml'
|
4
4
|
require 'active_record'
|
5
|
+
require 'schema_comments'
|
6
|
+
require 'schema_comments/schema_comment'
|
5
7
|
|
6
|
-
|
7
|
-
namespace :
|
8
|
-
Rake.application.send(:eval, "@tasks.delete('db:migrate')")
|
9
|
-
desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
10
|
-
task :migrate => :environment do
|
11
|
-
SchemaComments::SchemaComment.yaml_access do
|
12
|
-
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
13
|
-
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
14
|
-
SchemaComments.quiet = true
|
15
|
-
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
Rake.application.send(:eval, "@tasks.delete('db:rollback')")
|
20
|
-
desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
|
21
|
-
task :rollback => :environment do
|
22
|
-
SchemaComments::SchemaComment.yaml_access do
|
23
|
-
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
24
|
-
ActiveRecord::Migrator.rollback('db/migrate/', step)
|
25
|
-
SchemaComments.quiet = true
|
26
|
-
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
namespace :migrate do
|
31
|
-
desc 'Runs the "up" for a given migration VERSION.'
|
32
|
-
task :up => :environment do
|
33
|
-
SchemaComments::SchemaComment.yaml_access do
|
34
|
-
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
35
|
-
raise "VERSION is required" unless version
|
36
|
-
ActiveRecord::Migrator.run(:up, "db/migrate/", version)
|
37
|
-
SchemaComments.quiet = true
|
38
|
-
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
desc 'Runs the "down" for a given migration VERSION.'
|
43
|
-
task :down => :environment do
|
44
|
-
SchemaComments::SchemaComment.yaml_access do
|
45
|
-
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
46
|
-
raise "VERSION is required" unless version
|
47
|
-
ActiveRecord::Migrator.run(:down, "db/migrate/", version)
|
48
|
-
SchemaComments.quiet = true
|
49
|
-
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
8
|
+
db_namespace = namespace :db do
|
9
|
+
namespace :schema do
|
53
10
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
11
|
+
Rake.application.send(:eval, "@tasks.delete('db:schema:dump')")
|
12
|
+
desc 'Create a db/schema.rb file that can be portably used against any DB supported by AR'
|
13
|
+
task :dump => [:environment, :load_config] do
|
14
|
+
begin
|
15
|
+
SchemaComments.setup
|
16
|
+
require 'active_record/schema_dumper'
|
17
|
+
filename = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb"
|
18
|
+
File.open(filename, "w:utf-8") do |file|
|
19
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
20
|
+
# ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
21
|
+
SchemaComments::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
63
22
|
end
|
23
|
+
db_namespace['schema:dump'].reenable
|
24
|
+
rescue Exception => e
|
25
|
+
puts "[#{e.class}] #{e.message}:\n " << e.backtrace.join("\n ")
|
26
|
+
raise e
|
64
27
|
end
|
65
28
|
end
|
66
|
-
end
|
67
29
|
|
30
|
+
end
|
68
31
|
end
|
69
32
|
|
70
|
-
|
71
|
-
|
72
33
|
class ActiveRecord::Base
|
73
34
|
class << self
|
74
35
|
attr_accessor :ignore_pattern_to_export_i18n
|
75
|
-
|
36
|
+
end
|
76
37
|
|
38
|
+
self.ignore_pattern_to_export_i18n = /\(\(\(.*\)\)\)/
|
39
|
+
|
40
|
+
class << self
|
77
41
|
def export_i18n_models
|
78
42
|
subclasses = ActiveRecord::Base.send(:subclasses).select do |klass|
|
79
43
|
(klass != SchemaComments::SchemaComment) and
|
@@ -159,7 +123,7 @@ end
|
|
159
123
|
namespace :i18n do
|
160
124
|
namespace :schema_comments do
|
161
125
|
task :load_all_models => :environment do
|
162
|
-
Dir.glob(
|
126
|
+
Dir.glob(Rails.root.join('app/models/**/*.rb')) do |file_name|
|
163
127
|
require file_name
|
164
128
|
end
|
165
129
|
end
|
@@ -182,7 +146,7 @@ namespace :i18n do
|
|
182
146
|
task :update_config_locale => :"i18n:schema_comments:load_all_models" do
|
183
147
|
require 'yaml/store'
|
184
148
|
locale = (ENV['LOCALE'] || I18n.locale).to_s
|
185
|
-
path = (ENV['YAML_PATH'] ||
|
149
|
+
path = (ENV['YAML_PATH'] || Rails.root.join("config/locales/#{locale}.yml"))
|
186
150
|
print "updating #{path}..."
|
187
151
|
|
188
152
|
begin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.alpha3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &2168170300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2168170300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &2168169800 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.0.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2168169800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2168169320 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2168169320
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &2168185180 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.8.1
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2168185180
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: yard
|
60
|
-
requirement: &
|
60
|
+
requirement: &2168184700 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0.7'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2168184700
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rdoc
|
71
|
-
requirement: &
|
71
|
+
requirement: &2168184180 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '3.12'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2168184180
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: bundler
|
82
|
-
requirement: &
|
82
|
+
requirement: &2168183700 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.0.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2168183700
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: jeweler
|
93
|
-
requirement: &
|
93
|
+
requirement: &2168183180 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.8.3
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2168183180
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: simplecov
|
104
|
-
requirement: &
|
104
|
+
requirement: &2168182700 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,18 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2168182700
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: ZenTest
|
115
|
+
requirement: &2168182220 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *2168182220
|
113
124
|
description: schema_comments generates extra methods dynamically for attribute which
|
114
125
|
has options
|
115
126
|
email: akm2000@gmail.com
|
@@ -119,13 +130,13 @@ extra_rdoc_files:
|
|
119
130
|
- LICENSE.txt
|
120
131
|
- README.rdoc
|
121
132
|
files:
|
133
|
+
- .rspec
|
122
134
|
- Gemfile
|
123
135
|
- Gemfile.lock
|
124
136
|
- LICENSE.txt
|
125
137
|
- README.rdoc
|
126
138
|
- Rakefile
|
127
139
|
- VERSION
|
128
|
-
- autotest/discover.rb
|
129
140
|
- init.rb
|
130
141
|
- lib/annotate_models.rb
|
131
142
|
- lib/hash_key_orderable.rb
|
@@ -190,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
190
201
|
version: '0'
|
191
202
|
segments:
|
192
203
|
- 0
|
193
|
-
hash: -
|
204
|
+
hash: -382324986614841609
|
194
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
206
|
none: false
|
196
207
|
requirements:
|
data/autotest/discover.rb
DELETED