ns_service_pack 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +100 -0
- data/LICENSE.txt +20 -0
- data/{README → README.rdoc} +22 -2
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/lib/ns_service_pack/global_const.rb +3 -3
- data/lib/ns_service_pack.rb +6 -3
- data/lib/tasks/test.rake +2 -0
- data/{config/code_hashes.yml.sample → lib/templates/code_hashes/code_hash.yml.sample} +0 -0
- data/{config → lib/templates}/initializers/ns_service_pack.rb +0 -0
- data/ns_service_pack.gemspec +65 -16
- data/test/helper.rb +18 -0
- data/test/test_ns_service_pack.rb +7 -0
- metadata +77 -23
- data/lib/ns_service_pack/code_hash.rb~ +0 -37
- data/lib/ns_service_pack.rb~ +0 -26
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "rails", "= 3.1.0"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.6.4"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.1.0)
|
5
|
+
actionpack (= 3.1.0)
|
6
|
+
mail (~> 2.3.0)
|
7
|
+
actionpack (3.1.0)
|
8
|
+
activemodel (= 3.1.0)
|
9
|
+
activesupport (= 3.1.0)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
i18n (~> 0.6)
|
13
|
+
rack (~> 1.3.2)
|
14
|
+
rack-cache (~> 1.0.3)
|
15
|
+
rack-mount (~> 0.8.2)
|
16
|
+
rack-test (~> 0.6.1)
|
17
|
+
sprockets (~> 2.0.0)
|
18
|
+
activemodel (3.1.0)
|
19
|
+
activesupport (= 3.1.0)
|
20
|
+
bcrypt-ruby (~> 3.0.0)
|
21
|
+
builder (~> 3.0.0)
|
22
|
+
i18n (~> 0.6)
|
23
|
+
activerecord (3.1.0)
|
24
|
+
activemodel (= 3.1.0)
|
25
|
+
activesupport (= 3.1.0)
|
26
|
+
arel (~> 2.2.1)
|
27
|
+
tzinfo (~> 0.3.29)
|
28
|
+
activeresource (3.1.0)
|
29
|
+
activemodel (= 3.1.0)
|
30
|
+
activesupport (= 3.1.0)
|
31
|
+
activesupport (3.1.0)
|
32
|
+
multi_json (~> 1.0)
|
33
|
+
arel (2.2.1)
|
34
|
+
bcrypt-ruby (3.0.1)
|
35
|
+
builder (3.0.0)
|
36
|
+
erubis (2.7.0)
|
37
|
+
git (1.2.5)
|
38
|
+
hike (1.2.1)
|
39
|
+
i18n (0.6.0)
|
40
|
+
jeweler (1.6.4)
|
41
|
+
bundler (~> 1.0)
|
42
|
+
git (>= 1.2.5)
|
43
|
+
rake
|
44
|
+
json (1.6.1)
|
45
|
+
mail (2.3.0)
|
46
|
+
i18n (>= 0.4.0)
|
47
|
+
mime-types (~> 1.16)
|
48
|
+
treetop (~> 1.4.8)
|
49
|
+
mime-types (1.17.2)
|
50
|
+
multi_json (1.0.3)
|
51
|
+
polyglot (0.3.3)
|
52
|
+
rack (1.3.5)
|
53
|
+
rack-cache (1.0.3)
|
54
|
+
rack (>= 0.4)
|
55
|
+
rack-mount (0.8.3)
|
56
|
+
rack (>= 1.0.0)
|
57
|
+
rack-ssl (1.3.2)
|
58
|
+
rack
|
59
|
+
rack-test (0.6.1)
|
60
|
+
rack (>= 1.0)
|
61
|
+
rails (3.1.0)
|
62
|
+
actionmailer (= 3.1.0)
|
63
|
+
actionpack (= 3.1.0)
|
64
|
+
activerecord (= 3.1.0)
|
65
|
+
activeresource (= 3.1.0)
|
66
|
+
activesupport (= 3.1.0)
|
67
|
+
bundler (~> 1.0)
|
68
|
+
railties (= 3.1.0)
|
69
|
+
railties (3.1.0)
|
70
|
+
actionpack (= 3.1.0)
|
71
|
+
activesupport (= 3.1.0)
|
72
|
+
rack-ssl (~> 1.3.2)
|
73
|
+
rake (>= 0.8.7)
|
74
|
+
rdoc (~> 3.4)
|
75
|
+
thor (~> 0.14.6)
|
76
|
+
rake (0.9.2.2)
|
77
|
+
rcov (0.9.11)
|
78
|
+
rdoc (3.11)
|
79
|
+
json (~> 1.4)
|
80
|
+
shoulda (2.11.3)
|
81
|
+
sprockets (2.0.3)
|
82
|
+
hike (~> 1.2)
|
83
|
+
rack (~> 1.0)
|
84
|
+
tilt (~> 1.1, != 1.3.0)
|
85
|
+
thor (0.14.6)
|
86
|
+
tilt (1.3.3)
|
87
|
+
treetop (1.4.10)
|
88
|
+
polyglot
|
89
|
+
polyglot (>= 0.3.1)
|
90
|
+
tzinfo (0.3.31)
|
91
|
+
|
92
|
+
PLATFORMS
|
93
|
+
ruby
|
94
|
+
|
95
|
+
DEPENDENCIES
|
96
|
+
bundler (~> 1.0.0)
|
97
|
+
jeweler (~> 1.6.4)
|
98
|
+
rails (= 3.1.0)
|
99
|
+
rcov
|
100
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 caory
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/{README → README.rdoc}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
= ns_service_pack
|
2
|
+
|
3
3
|
实现部分REST架构(ROA)中Service层基础共享代码抽取
|
4
4
|
|
5
5
|
#==功能列表:
|
@@ -67,6 +67,10 @@ end
|
|
67
67
|
|
68
68
|
|
69
69
|
#==============History:
|
70
|
+
#==0.0.17
|
71
|
+
* 转用jeweler包来管理本gem项目, 可用bundler,rake,git来便利化相关开发
|
72
|
+
* 注释gem root变量的引用
|
73
|
+
|
70
74
|
#==0.0.16 20111119
|
71
75
|
* 由Gao发现load_code_hashes!时引入空.yml文件时出错,已修复
|
72
76
|
* 修改dump_mapping文件目录从code_hashes/fields到code_hashes/mappings
|
@@ -157,3 +161,19 @@ end
|
|
157
161
|
#==20111116
|
158
162
|
根据Shang的建议,决定将共用代码抽离成gem包形式
|
159
163
|
|
164
|
+
|
165
|
+
== Contributing to ns_service_pack
|
166
|
+
|
167
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
168
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
169
|
+
* Fork the project
|
170
|
+
* Start a feature/bugfix branch
|
171
|
+
* Commit and push until you are happy with your contribution
|
172
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
173
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
174
|
+
|
175
|
+
== Copyright
|
176
|
+
|
177
|
+
Copyright (c) 2011 caory. See LICENSE.txt for
|
178
|
+
further details.
|
179
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "ns_service_pack"
|
18
|
+
gem.homepage = "http://github.com/caory/ns_service_pack"
|
19
|
+
#gem.version = NsServicePack::VERSION
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{little service pack}
|
22
|
+
gem.description = %Q{abstract some common pattern to service pack}
|
23
|
+
gem.email = "cao7113@hotmail.com"
|
24
|
+
gem.authors = ["Caory, Shang, Geogeous"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
test.rcov_opts << '--exclude "gems/*"'
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "ns_service_pack #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.17
|
@@ -6,7 +6,7 @@
|
|
6
6
|
=end
|
7
7
|
require 'fileutils'
|
8
8
|
module GlobalConst
|
9
|
-
SAMPLE_FILE = "
|
9
|
+
SAMPLE_FILE = "templates/code_hashes/code_hash.yml.sample"
|
10
10
|
APP_CODE_HASHES = "config/code_hashes/"
|
11
11
|
|
12
12
|
mattr_accessor :global_data
|
@@ -51,14 +51,14 @@ module GlobalConst
|
|
51
51
|
end
|
52
52
|
|
53
53
|
#为引用项目生成样例文件, TODO rake方式生成
|
54
|
-
def self.setup_sample(yml_file = "#{APP_CODE_HASHES}
|
54
|
+
def self.setup_sample(yml_file = "#{APP_CODE_HASHES}code_hash.yml.sample")
|
55
55
|
if defined? Rails
|
56
56
|
target = "#{Rails.root}/#{yml_file}"
|
57
57
|
unless File.exists?(target)
|
58
58
|
path = File.dirname(target)
|
59
59
|
FileUtils.mkpath(path)
|
60
60
|
#默认覆盖已有
|
61
|
-
FileUtils.cp(
|
61
|
+
FileUtils.cp(SAMPLE_FILE, target)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/ns_service_pack.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#coding: utf-8
|
2
|
-
NS_GEM_ROOT = File.expand_path('../..', __FILE__)
|
2
|
+
#NS_GEM_ROOT = File.expand_path('../..', __FILE__)
|
3
3
|
#debug this gem
|
4
4
|
#$LOAD_PATH.unshift("#{NS_GEM_ROOT}/lib")
|
5
5
|
|
@@ -11,11 +11,14 @@ require 'ns_service_pack/result_packer'
|
|
11
11
|
require 'ns_service_pack/application_controller_module'
|
12
12
|
|
13
13
|
module NsServicePack
|
14
|
+
|
15
|
+
PRE_INIT_FILE = "config/initializers/ns_service_pack.rb"
|
16
|
+
INIT_FILE_TMPL = "templates/initializers/ns_service_pack.rb"
|
14
17
|
#初始安装设置
|
15
18
|
def self.install
|
16
|
-
init_file = "#{Rails.root}
|
19
|
+
init_file = "#{Rails.root}/#{PRE_INIT_FILE}"
|
17
20
|
unless File.exists?(init_file)
|
18
|
-
FileUtils.cp(
|
21
|
+
FileUtils.cp(INIT_FILE_TMPL, init_file)
|
19
22
|
puts "==>I have installed a intializer file: #{init_file}"
|
20
23
|
GlobalConst.setup_sample
|
21
24
|
puts "==>Now config your constants in folder: #{GlobalConst::APP_CODE_HASHES}"
|
data/lib/tasks/test.rake
ADDED
File without changes
|
File without changes
|
data/ns_service_pack.gemspec
CHANGED
@@ -1,22 +1,71 @@
|
|
1
|
-
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
2
5
|
|
3
6
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version =
|
7
|
+
s.name = "ns_service_pack"
|
8
|
+
s.version = "0.0.17"
|
6
9
|
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
|
13
|
-
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Caory, Shang, Geogeous"]
|
12
|
+
s.date = "2011-11-24"
|
13
|
+
s.description = "abstract some common pattern to service pack"
|
14
|
+
s.email = "cao7113@hotmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
14
18
|
]
|
15
|
-
s.
|
16
|
-
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/ns_service_pack.rb",
|
28
|
+
"lib/ns_service_pack/application_controller_module.rb",
|
29
|
+
"lib/ns_service_pack/code_hash.rb",
|
30
|
+
"lib/ns_service_pack/field_mapping.rb",
|
31
|
+
"lib/ns_service_pack/global_const.rb",
|
32
|
+
"lib/ns_service_pack/result_packer.rb",
|
33
|
+
"lib/ns_service_pack/version.rb",
|
34
|
+
"lib/tasks/test.rake",
|
35
|
+
"lib/templates/code_hashes/code_hash.yml.sample",
|
36
|
+
"lib/templates/initializers/ns_service_pack.rb",
|
37
|
+
"ns_service_pack.gemspec",
|
38
|
+
"test/helper.rb",
|
39
|
+
"test/test_ns_service_pack.rb"
|
40
|
+
]
|
41
|
+
s.homepage = "http://github.com/caory/ns_service_pack"
|
42
|
+
s.licenses = ["MIT"]
|
17
43
|
s.require_paths = ["lib"]
|
18
|
-
s.
|
19
|
-
|
20
|
-
|
21
|
-
s.
|
44
|
+
s.rubygems_version = "1.8.10"
|
45
|
+
s.summary = "little service pack"
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
s.specification_version = 3
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<rails>, ["= 3.1.0"])
|
53
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
55
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rails>, ["= 3.1.0"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rails>, ["= 3.1.0"])
|
66
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
67
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
68
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
69
|
+
end
|
22
70
|
end
|
71
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'ns_service_pack'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
CHANGED
@@ -1,53 +1,104 @@
|
|
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.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Caory
|
9
|
-
- Shang
|
10
|
-
- Gorgeous
|
8
|
+
- Caory, Shang, Geogeous
|
11
9
|
autorequire:
|
12
10
|
bindir: bin
|
13
11
|
cert_chain: []
|
14
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-24 00:00:00.000000000Z
|
15
13
|
dependencies:
|
16
14
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
18
|
-
requirement: &
|
15
|
+
name: shoulda
|
16
|
+
requirement: &74818950 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
18
|
requirements:
|
21
19
|
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *74818950
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &74818600 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
22
31
|
- !ruby/object:Gem::Version
|
23
32
|
version: 3.1.0
|
24
33
|
type: :development
|
25
34
|
prerelease: false
|
26
|
-
version_requirements: *
|
27
|
-
|
28
|
-
|
35
|
+
version_requirements: *74818600
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bundler
|
38
|
+
requirement: &74818230 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *74818230
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jeweler
|
49
|
+
requirement: &74817850 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.4
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *74817850
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rcov
|
60
|
+
requirement: &74817460 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *74817460
|
69
|
+
description: abstract some common pattern to service pack
|
70
|
+
email: cao7113@hotmail.com
|
29
71
|
executables: []
|
30
72
|
extensions: []
|
31
|
-
extra_rdoc_files:
|
73
|
+
extra_rdoc_files:
|
74
|
+
- LICENSE.txt
|
75
|
+
- README.rdoc
|
32
76
|
files:
|
77
|
+
- .document
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.rdoc
|
82
|
+
- Rakefile
|
83
|
+
- VERSION
|
33
84
|
- lib/ns_service_pack.rb
|
34
|
-
- lib/ns_service_pack/global_const.rb
|
35
|
-
- lib/ns_service_pack/version.rb
|
36
85
|
- lib/ns_service_pack/application_controller_module.rb
|
37
|
-
- lib/ns_service_pack/code_hash.rb~
|
38
86
|
- lib/ns_service_pack/code_hash.rb
|
39
87
|
- lib/ns_service_pack/field_mapping.rb
|
88
|
+
- lib/ns_service_pack/global_const.rb
|
40
89
|
- lib/ns_service_pack/result_packer.rb
|
41
|
-
- lib/ns_service_pack.rb
|
42
|
-
-
|
43
|
-
-
|
90
|
+
- lib/ns_service_pack/version.rb
|
91
|
+
- lib/tasks/test.rake
|
92
|
+
- lib/templates/code_hashes/code_hash.yml.sample
|
93
|
+
- lib/templates/initializers/ns_service_pack.rb
|
44
94
|
- ns_service_pack.gemspec
|
45
|
-
-
|
46
|
-
|
47
|
-
|
95
|
+
- test/helper.rb
|
96
|
+
- test/test_ns_service_pack.rb
|
97
|
+
homepage: http://github.com/caory/ns_service_pack
|
98
|
+
licenses:
|
99
|
+
- MIT
|
48
100
|
post_install_message:
|
49
|
-
rdoc_options:
|
50
|
-
- --charset=UTF-8
|
101
|
+
rdoc_options: []
|
51
102
|
require_paths:
|
52
103
|
- lib
|
53
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -56,6 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
107
|
- - ! '>='
|
57
108
|
- !ruby/object:Gem::Version
|
58
109
|
version: '0'
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
hash: -147394673
|
59
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
114
|
none: false
|
61
115
|
requirements:
|
@@ -67,5 +121,5 @@ rubyforge_project:
|
|
67
121
|
rubygems_version: 1.8.10
|
68
122
|
signing_key:
|
69
123
|
specification_version: 3
|
70
|
-
summary:
|
124
|
+
summary: little service pack
|
71
125
|
test_files: []
|
@@ -1,37 +0,0 @@
|
|
1
|
-
#coding: utf-8
|
2
|
-
=begin
|
3
|
-
用一致化方法根据key查值或反查,使用hash方法([]),如
|
4
|
-
code_hash = CodeHash.new({'普通会员'=>0, '高级会员'=>10})
|
5
|
-
code_hash['普通会员'] #=>0
|
6
|
-
dode_hash[0] #=>'普通会员'
|
7
|
-
相关概念:
|
8
|
-
key: 人可识别的编码,如‘普通会员’
|
9
|
-
value: 存入数据库的编码,一般为增加数据检索速度
|
10
|
-
|
11
|
-
规则:
|
12
|
-
* 键/值具有唯一性(符合大部分使用情况)
|
13
|
-
=end
|
14
|
-
class CodeHash
|
15
|
-
attr_accessor :data, :invert_data
|
16
|
-
|
17
|
-
def initialize(code_hash={})
|
18
|
-
@data = code_hash
|
19
|
-
@invert_data = code_hash.invert
|
20
|
-
end
|
21
|
-
|
22
|
-
def [](code)
|
23
|
-
@data[code] || @invert_data[code]||"真的没找到呀![code=#{code.to_s}]"
|
24
|
-
end
|
25
|
-
|
26
|
-
def all
|
27
|
-
@data.merge(@invert_data)
|
28
|
-
end
|
29
|
-
|
30
|
-
def keys
|
31
|
-
@data.keys
|
32
|
-
end
|
33
|
-
|
34
|
-
def values
|
35
|
-
@data.values
|
36
|
-
end
|
37
|
-
end
|
data/lib/ns_service_pack.rb~
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
##TODO
|
2
|
-
#$LOAD_PATH.unshift("#{Dir.pwd}/lib/ns_service_pack/lib")
|
3
|
-
|
4
|
-
require 'ns_service_pack/code_hash.rb'
|
5
|
-
require 'ns_service_pack/result_packer.rb'
|
6
|
-
require 'ns_service_pack/field_mapping.rb'
|
7
|
-
require 'ns_service_pack/application_controller_module.rb'
|
8
|
-
|
9
|
-
#TODO WHY FIXME
|
10
|
-
#if defined?(ActionController::Base)
|
11
|
-
#ActionController::Base.include(ApplicationControllerModule)
|
12
|
-
# ActionController::Base.send(:include, ApplicationControllerModule)
|
13
|
-
#end
|
14
|
-
if defined?(ActiveRecord::Base)
|
15
|
-
ActiveRecord::Base.send(:include, FieldMapping)
|
16
|
-
end
|
17
|
-
|
18
|
-
GlobalConstants = {
|
19
|
-
:genders => CodeHash.new('男'=>0, '女'=>1, '保密'=>2),
|
20
|
-
:trues => CodeHash.new('是'=>true, '否'=>false)
|
21
|
-
}
|
22
|
-
|
23
|
-
#Genders = CodeHash.new('男'=>0, '女'=>1, '保密'=>2)
|
24
|
-
#Trues = CodeHash.new('是'=>true, '否'=>false)
|
25
|
-
|
26
|
-
puts "============ns service pack has installed in your application..."
|