ns_service_pack 0.0.19 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,35 +5,50 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ns_service_pack"
8
- s.version = "0.0.19"
8
+ s.version = "0.0.21"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Caory, Shang, Geogeous"]
12
- s.date = "2011-11-24"
12
+ s.date = "2011-11-29"
13
13
  s.description = "abstract some common pattern to service pack"
14
14
  s.email = "cao7113@hotmail.com"
15
+ s.executables = ["ns_service_pack"]
15
16
  s.extra_rdoc_files = [
16
17
  "LICENSE.txt",
17
18
  "README.rdoc"
18
19
  ]
19
20
  s.files = [
20
21
  ".document",
22
+ "CHANGELOG",
21
23
  "Gemfile",
22
24
  "Gemfile.lock",
23
25
  "LICENSE.txt",
24
26
  "README.rdoc",
25
27
  "Rakefile",
26
28
  "VERSION",
29
+ "bin/ns_service_pack",
30
+ "lib/generators/ns/scaffold/scaffold_generator.rb",
31
+ "lib/generators/try/templates/test.rb",
32
+ "lib/generators/try/try_generator.rb",
27
33
  "lib/ns_service_pack.rb",
28
- "lib/ns_service_pack/application_controller_module.rb",
34
+ "lib/ns_service_pack/client.rb",
29
35
  "lib/ns_service_pack/code_hash.rb",
36
+ "lib/ns_service_pack/controller_servicable.rb",
30
37
  "lib/ns_service_pack/field_mapping.rb",
31
38
  "lib/ns_service_pack/global_const.rb",
39
+ "lib/ns_service_pack/result.rb",
40
+ "lib/ns_service_pack/result_error.rb",
32
41
  "lib/ns_service_pack/result_packer.rb",
42
+ "lib/ns_service_pack/service_config.rb",
43
+ "lib/ns_service_pack/util.rb",
33
44
  "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",
45
+ "lib/templates/active_record/model/model.rb",
46
+ "lib/templates/config/code_hashes/code_hash.yml.sample",
47
+ "lib/templates/config/database.yml.sample",
48
+ "lib/templates/config/initializers/ns_service_pack.rb",
49
+ "lib/templates/config/initializers/oracle_db_config.rb",
50
+ "lib/templates/config/ns_services.yml",
51
+ "lib/templates/rails/scaffold_controller/controller.rb",
37
52
  "ns_service_pack.gemspec",
38
53
  "test/helper.rb",
39
54
  "test/test_ns_service_pack.rb"
@@ -48,17 +63,23 @@ Gem::Specification.new do |s|
48
63
  s.specification_version = 3
49
64
 
50
65
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
+ s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.7"])
67
+ s.add_runtime_dependency(%q<thor>, ["~> 0.14.6"])
51
68
  s.add_development_dependency(%q<shoulda>, [">= 0"])
52
69
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
53
70
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
54
71
  s.add_development_dependency(%q<rcov>, [">= 0"])
55
72
  else
73
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
74
+ s.add_dependency(%q<thor>, ["~> 0.14.6"])
56
75
  s.add_dependency(%q<shoulda>, [">= 0"])
57
76
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
77
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
59
78
  s.add_dependency(%q<rcov>, [">= 0"])
60
79
  end
61
80
  else
81
+ s.add_dependency(%q<rest-client>, ["~> 1.6.7"])
82
+ s.add_dependency(%q<thor>, ["~> 0.14.6"])
62
83
  s.add_dependency(%q<shoulda>, [">= 0"])
63
84
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
85
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
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.19
4
+ version: 0.0.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-24 00:00:00.000000000Z
12
+ date: 2011-11-29 00:00:00.000000000Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: &86468680 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.7
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *86468680
25
+ - !ruby/object:Gem::Dependency
26
+ name: thor
27
+ requirement: &86468440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.14.6
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *86468440
14
36
  - !ruby/object:Gem::Dependency
15
37
  name: shoulda
16
- requirement: &83422540 !ruby/object:Gem::Requirement
38
+ requirement: &86468200 !ruby/object:Gem::Requirement
17
39
  none: false
18
40
  requirements:
19
41
  - - ! '>='
@@ -21,10 +43,10 @@ dependencies:
21
43
  version: '0'
22
44
  type: :development
23
45
  prerelease: false
24
- version_requirements: *83422540
46
+ version_requirements: *86468200
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: bundler
27
- requirement: &83422300 !ruby/object:Gem::Requirement
49
+ requirement: &86467960 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ~>
@@ -32,10 +54,10 @@ dependencies:
32
54
  version: 1.0.0
33
55
  type: :development
34
56
  prerelease: false
35
- version_requirements: *83422300
57
+ version_requirements: *86467960
36
58
  - !ruby/object:Gem::Dependency
37
59
  name: jeweler
38
- requirement: &83422060 !ruby/object:Gem::Requirement
60
+ requirement: &86467720 !ruby/object:Gem::Requirement
39
61
  none: false
40
62
  requirements:
41
63
  - - ~>
@@ -43,10 +65,10 @@ dependencies:
43
65
  version: 1.6.4
44
66
  type: :development
45
67
  prerelease: false
46
- version_requirements: *83422060
68
+ version_requirements: *86467720
47
69
  - !ruby/object:Gem::Dependency
48
70
  name: rcov
49
- requirement: &83421820 !ruby/object:Gem::Requirement
71
+ requirement: &86467480 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ! '>='
@@ -54,32 +76,47 @@ dependencies:
54
76
  version: '0'
55
77
  type: :development
56
78
  prerelease: false
57
- version_requirements: *83421820
79
+ version_requirements: *86467480
58
80
  description: abstract some common pattern to service pack
59
81
  email: cao7113@hotmail.com
60
- executables: []
82
+ executables:
83
+ - ns_service_pack
61
84
  extensions: []
62
85
  extra_rdoc_files:
63
86
  - LICENSE.txt
64
87
  - README.rdoc
65
88
  files:
66
89
  - .document
90
+ - CHANGELOG
67
91
  - Gemfile
68
92
  - Gemfile.lock
69
93
  - LICENSE.txt
70
94
  - README.rdoc
71
95
  - Rakefile
72
96
  - VERSION
97
+ - bin/ns_service_pack
98
+ - lib/generators/ns/scaffold/scaffold_generator.rb
99
+ - lib/generators/try/templates/test.rb
100
+ - lib/generators/try/try_generator.rb
73
101
  - lib/ns_service_pack.rb
74
- - lib/ns_service_pack/application_controller_module.rb
102
+ - lib/ns_service_pack/client.rb
75
103
  - lib/ns_service_pack/code_hash.rb
104
+ - lib/ns_service_pack/controller_servicable.rb
76
105
  - lib/ns_service_pack/field_mapping.rb
77
106
  - lib/ns_service_pack/global_const.rb
107
+ - lib/ns_service_pack/result.rb
108
+ - lib/ns_service_pack/result_error.rb
78
109
  - lib/ns_service_pack/result_packer.rb
110
+ - lib/ns_service_pack/service_config.rb
111
+ - lib/ns_service_pack/util.rb
79
112
  - lib/ns_service_pack/version.rb
80
- - lib/tasks/test.rake
81
- - lib/templates/code_hashes/code_hash.yml.sample
82
- - lib/templates/initializers/ns_service_pack.rb
113
+ - lib/templates/active_record/model/model.rb
114
+ - lib/templates/config/code_hashes/code_hash.yml.sample
115
+ - lib/templates/config/database.yml.sample
116
+ - lib/templates/config/initializers/ns_service_pack.rb
117
+ - lib/templates/config/initializers/oracle_db_config.rb
118
+ - lib/templates/config/ns_services.yml
119
+ - lib/templates/rails/scaffold_controller/controller.rb
83
120
  - ns_service_pack.gemspec
84
121
  - test/helper.rb
85
122
  - test/test_ns_service_pack.rb
@@ -98,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
135
  version: '0'
99
136
  segments:
100
137
  - 0
101
- hash: 849417421
138
+ hash: 777346227
102
139
  required_rubygems_version: !ruby/object:Gem::Requirement
103
140
  none: false
104
141
  requirements:
@@ -1,95 +0,0 @@
1
- #coding: utf-8
2
- module ApplicationControllerModule
3
- def index
4
- @result = paginate(params) do |start, page_size|
5
- get_page_data(start, page_size, params)
6
- end
7
- render :json=>ResultPacker.data(@result.as_json)
8
- end
9
-
10
- #return [total_count, page_data]
11
- #可在子类中覆盖定制
12
- def get_page_data(start = 0, size = 10, params = {})
13
- where_conds = if @conds.present?
14
- @conds
15
- else
16
- query_conditionize(params, @conds)
17
- end
18
- logger.debug "====>conds: #{where_conds.inspect}"
19
- conds = {:conditions=>where_conds}
20
- total_count = model_class.count(conds)
21
- page_params = conds.merge!(:offset=>start, :limit=>size, :order=>params[:order])
22
- page_data = model_class.all(page_params)
23
- [total_count, page_data]
24
- end
25
-
26
- def query_conditionize(params = {}, conds = {})
27
- #清除空条件
28
- params.delete_if{|k, v| v.blank? }
29
- #TODO 有@conds时如何融入???
30
- #hash结构
31
- conds = model_class.db_hashize(params)
32
- end
33
-
34
- #分页方法
35
- def paginate(params = {})
36
- current_page = params[:current_page].to_i
37
- current_page = current_page < 1 ? 1 : current_page
38
- page_size = params[:page_size].to_i
39
- page_size = page_size <= 0 ? 10 : page_size
40
- page_size = page_size > 250 ? 250 : page_size
41
- offset = (current_page-1)*page_size
42
- #返回总数和当前页数据 起始位置, 数量
43
- total_count, page_data = yield(offset, page_size)
44
- {
45
- :total_size=>total_count,
46
- :page_size=>page_size,
47
- :current_page=>current_page,
48
- :page_from=>offset + 1,
49
- :page_to=>offset + page_data.size,
50
- :page_items=>page_data
51
- }
52
- end
53
-
54
- #查找单条记录
55
- def show
56
- @_obj = model_class.find(params[:id])
57
- render :json=>ResultPacker.data(@_obj.as_json)
58
- end
59
-
60
- #创建记录
61
- def create
62
- @_obj = model_class.new_from_buz(params[:data])
63
- if @_obj.save
64
- render :json=>ResultPacker.data(@_obj)
65
- else
66
- render :json=>ResultPacker.help(valid_errors(model_class.buz_hashize(@_obj.errors.to_hash)))
67
- end
68
- end
69
-
70
- #更新记录
71
- def update
72
- @_obj = model_class.find(params[:id])
73
- if @_obj.update_from_buz(params[:data])
74
- render :json=>ResultPacker.data(@_obj)
75
- else
76
- render :json=>ResultPacker.help(valid_errors(model_class.buz_hashize(@_obj.errors.to_hash)))
77
- end
78
- end
79
-
80
- #验证错误回传
81
- def valid_errors(error_hash={})
82
- (error_hash||{}).each{|k, v| error_hash[k] = v.join(', ') if v.is_a? Array }
83
- end
84
-
85
- #ABORTED NOW, keep here
86
- def query_fields
87
- @_data = model_class.buz_hashize
88
- render :json=>ResultPacker.data(:fields=>@_data)
89
- end
90
-
91
- #动态查看该模块发布接口列表
92
- def interfaces
93
- @routes = Rails.application.routes.routes
94
- end
95
- end
data/lib/tasks/test.rake DELETED
@@ -1,2 +0,0 @@
1
- #coding: utf-8
2
- puts "this is from gem rake file..."
@@ -1,18 +0,0 @@
1
- #coding: utf-8
2
-
3
- #导入项目中使用的CodeHashes
4
- GlobalConst.load_app_code_hashes!
5
-
6
- #对rails应用的扩展
7
- if defined?(Rails)
8
- #TODO 为什么不能像ActiveRecord::Base一样include,到底什么道理呢???
9
- #预加载,否则此处定义后为什么不去加载项目中的定义文件呢???
10
- #这样做的缺点,改变了加载顺序,需调查有依赖时是否影响较大???
11
- require 'application_controller'
12
- class ApplicationController # < ActionController::Base
13
- include ApplicationControllerModule
14
- end
15
- if defined?(ActiveRecord::Base)
16
- ActiveRecord::Base.send(:include, FieldMapping)
17
- end
18
- end