irm_yaml_db 0.0.2 → 0.0.3

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.
data/README.markdown CHANGED
@@ -12,7 +12,7 @@ Any database that has an ActiveRecord adapter should work. This gem is now Rail
12
12
 
13
13
  Simply add to your Gemfile:
14
14
 
15
- gem 'yaml_db'
15
+ gem 'irm_yaml_db', :require => 'yaml_db'
16
16
 
17
17
  All rake tasks will then be available to you.
18
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/irm_yaml_db.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "irm_yaml_db"
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["uudui"]
@@ -52,6 +52,9 @@ module SerializationHelper
52
52
  end
53
53
 
54
54
  class Load
55
+ GREEN = "\e[32m"
56
+ CLEAR = "\e[0m"
57
+
55
58
  def self.load(io, truncate = true)
56
59
  ActiveRecord::Base.connection.transaction do
57
60
  load_documents(io, truncate)
@@ -82,7 +85,7 @@ module SerializationHelper
82
85
  columns = column_names.map{|cn| ActiveRecord::Base.connection.columns(table).detect{|c| c.name == cn}}
83
86
  quoted_column_names = column_names.map { |column| ActiveRecord::Base.connection.quote_column_name(column) }.join(',')
84
87
  quoted_table_name = SerializationHelper::Utils.quote_table(table)
85
- puts "Synch #{table}'s data......"
88
+ puts "#{GREEN}Synch #{table}'s data......#{CLEAR}"
86
89
  records.each do |record|
87
90
  quoted_values = record.zip(columns).map{|c| ActiveRecord::Base.connection.quote(c.first, c.last)}.join(',')
88
91
 
data/lib/yaml_db.rb CHANGED
@@ -59,14 +59,26 @@ module YamlDb
59
59
  class Load < SerializationHelper::Load
60
60
  def self.load_documents(io, truncate = true)
61
61
  YAML.load_documents(io) do |ydoc|
62
+ not_exists_tables = []
62
63
  ydoc.keys.each do |table_name|
63
64
  next if ydoc[table_name].nil?
64
65
  if ActiveRecord::Base.connection.table_exists?(table_name)
65
66
  load_table(table_name, ydoc[table_name], truncate)
66
67
  else
67
- puts "Table: #{table_name} is not exists."
68
+ not_exists_tables << table_name
68
69
  end
69
70
  end
71
+ if not_exists_tables.any?
72
+ red_color = "\e[31m"
73
+ default_color = "\e[0m"
74
+ #CLEAR = "\e[0m"
75
+ #BOLD = "\e[1m"
76
+ #RED = "\e[31m"
77
+ #GREEN = "\e[32m"
78
+ #YELLOW = "\e[33m"
79
+ #BLUE = "\e[34m"
80
+ puts "#{red_color}Synch data field because tables: #{not_exists_tables.join(",")} are not exists #{default_color}"
81
+ end
70
82
  end
71
83
  end
72
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irm_yaml_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: