ns_service_pack 0.0.6 → 0.0.7
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/History +3 -1
- data/lib/ns_service_pack/field_mapping.rb +5 -5
- data/lib/ns_service_pack/global_const.rb +11 -7
- data/lib/ns_service_pack/version.rb +1 -1
- metadata +3 -3
data/History
CHANGED
@@ -40,9 +40,9 @@ module FieldMapping
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def dump_new(force=true)
|
44
44
|
if defined?(Rails)
|
45
|
-
file = "#{Rails.root}/data/#{model_key}.yml"
|
45
|
+
file = "#{Rails.root}/data/#{model_key}_#{Time.now.to_i}.yml"
|
46
46
|
path = File.dirname(file)
|
47
47
|
FileUtils.mkpath(path) unless File.directory?(path)
|
48
48
|
existed = File.exists?(file)
|
@@ -68,7 +68,7 @@ module FieldMapping
|
|
68
68
|
#生成field mapping,dump到指定的yaml文件中
|
69
69
|
def dump_mapping(attr_prefix = nil, force = true)
|
70
70
|
if defined?(Rails)
|
71
|
-
file = "#{Rails.root}/#{GlobalConst::APP_CODE_HASHES}
|
71
|
+
file = "#{Rails.root}/#{GlobalConst::APP_CODE_HASHES}fields/#{model_key}_#{Time.now.to_i}.yml"
|
72
72
|
path = File.dirname(file)
|
73
73
|
FileUtils.mkpath(path) unless File.directory?(path)
|
74
74
|
existed = File.exists?(file)
|
@@ -94,8 +94,8 @@ module FieldMapping
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
97
|
+
#TODO
|
98
|
+
def dump_field_map(force=true)
|
99
99
|
puts "==Warning: please use dump_mapping instead, this will be removed..."
|
100
100
|
dump_mapping(nil, true)
|
101
101
|
end
|
@@ -27,7 +27,7 @@ module GlobalConst
|
|
27
27
|
nh = h.symbolize_keys
|
28
28
|
nh.keys.each do |k|
|
29
29
|
if @@global_data.key?(k)
|
30
|
-
puts "==>Warning: new value(#{
|
30
|
+
puts "==>Warning: new value(from #{hash_or_file.inspect}) is set for key:#{k}! Please check that is your need!"
|
31
31
|
end
|
32
32
|
@@global_data[k] = CodeHash.new(nh[k])
|
33
33
|
end
|
@@ -60,20 +60,24 @@ module GlobalConst
|
|
60
60
|
end
|
61
61
|
|
62
62
|
#将一个hash和array写入data下的yaml结构中
|
63
|
-
def self.yamlize(hash_or_array = {})
|
64
|
-
return if
|
65
|
-
if hash_or_array.is_a?
|
66
|
-
|
63
|
+
def self.yamlize(hash_or_array = {}, file_name = nil)
|
64
|
+
return if hash_or_array.nil?
|
65
|
+
hash = if hash_or_array.is_a?(Array)
|
66
|
+
hash_or_array.inject({}) do |r, k|
|
67
67
|
r[k] = nil
|
68
68
|
r
|
69
69
|
end
|
70
|
+
else
|
71
|
+
hash_or_array
|
70
72
|
end
|
71
|
-
|
73
|
+
|
74
|
+
method_key = file_name.nil? ? "hash" : file_name.to_s
|
75
|
+
name = "#{method_key}_#{Time.now.to_i}"
|
72
76
|
file = "#{Rails.root}/data/#{name}.yml"
|
73
77
|
path = File.dirname(file)
|
74
78
|
Fileutils.mkpath(path) unless File.directory?(path)
|
75
79
|
File.open(file, 'w+') do |f|
|
76
|
-
f.puts YAML.dump(
|
80
|
+
f.puts YAML.dump(method_key.to_sym=>hash)
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ns_service_pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ date: 2011-11-17 00:00:00.000000000Z
|
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
18
|
-
requirement: &
|
18
|
+
requirement: &82958800 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: 3.1.0
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *82958800
|
27
27
|
description: Service package for our service lier
|
28
28
|
email: cao7113@gmail.com
|
29
29
|
executables: []
|