protobuf 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- protobuf (1.1.2)
4
+ protobuf (1.1.3)
5
5
  eventmachine (~> 0.12.10)
6
6
  eventually (~> 0.1.0)
7
7
  json_pure (~> 1.6.4)
@@ -13,10 +13,10 @@ module Protobuf
13
13
  end
14
14
  end
15
15
 
16
- # Expects: SomeLongName
16
+ # Expects: SomeLongName, SOMELongName
17
17
  # Returns: some_long_name
18
18
  def underscore(str)
19
- str.to_s.gsub(/\B[A-Z]/, '_\&').downcase
19
+ str.to_s.gsub(/\B[A-Z](?:[a-z])/, '_\&').downcase
20
20
  end
21
21
 
22
22
  # Expects: SomeModule::Path
@@ -18,8 +18,8 @@ require '<%= required_file %>'
18
18
  <%- rpcs.each do |name, request, response| -%>
19
19
  ## <%= class_indent %> # request -> <%= module_name %>::<%= request %>
20
20
  ## <%= class_indent %> # response -> <%= module_name %>::<%= response %>
21
- ## <%= class_indent %> def <%= underscore name %>
22
- ## <%= class_indent %> # TODO: implement <%= underscore name %>
21
+ ## <%= class_indent %> def <%= Util.underscore(name) %>
22
+ ## <%= class_indent %> # TODO: implement <%= Util.underscore(name) %>
23
23
  ## <%= class_indent %> end
24
24
  ## <%= class_indent %>
25
25
  <%- end -%>
@@ -34,7 +34,7 @@ require '<%= required_file %>'
34
34
  <%- end -%>
35
35
  <%= class_indent %>class <%= service_name %> < Protobuf::Rpc::Service
36
36
  <%- rpcs.each do |name, request, response| -%>
37
- <%= class_indent %> rpc :<%= underscore name %>, <%= request %>, <%= response %>
37
+ <%= class_indent %> rpc :<%= Util.underscore(name) %>, <%= request %>, <%= response %>
38
38
  <%- end -%>
39
39
  <%= class_indent %>end
40
40
  <%- (module_array.size-1).downto(0) do |i| -%>
@@ -153,21 +153,20 @@ module Protobuf
153
153
 
154
154
  def create_files(message_file, out_dir, create_file=true)
155
155
  @create_file = create_file
156
- default_port = 9999
157
156
  @services.each do |service_name, rpcs|
158
- underscored_name = underscore service_name.to_s
157
+ underscored_name = Util.underscore(service_name.to_s)
159
158
  message_module = package.map{|p| p.to_s.capitalize}.join('::')
160
159
  required_file = [
161
160
  Util.module_to_path(message_module),
162
- File.basename(message_file.sub(/^\.\//, '').sub(/\.rb$/, ''))
161
+ File.basename(message_file, '.rb')
163
162
  ].join('/').gsub(/\/{2,}/, '/')
164
163
 
165
- create_service(message_file, out_dir, underscored_name, message_module, service_name, default_port, rpcs, required_file)
164
+ create_service(message_file, out_dir, underscored_name, message_module, service_name, rpcs, required_file)
166
165
  end
167
166
  @file_contents
168
167
  end
169
168
 
170
- def create_service(message_file, out_dir, underscored_name, module_name, service_name, default_port, rpcs, required_file)
169
+ def create_service(message_file, out_dir, underscored_name, module_name, service_name, rpcs, required_file)
171
170
  service_filename = "#{out_dir}/#{Util.module_to_path(module_name)}/#{underscored_name}.rb"
172
171
  service_contents = template_erb('rpc_service_implementation').result(binding)
173
172
  create_file_with_backup(service_filename, service_contents) if @create_file
@@ -176,10 +175,6 @@ module Protobuf
176
175
 
177
176
  private
178
177
 
179
- def underscore(str)
180
- str.to_s.gsub(/\B[A-Z]/, '_\&').downcase
181
- end
182
-
183
178
  def template_erb(template)
184
179
  ERB.new(File.read("#{File.dirname(__FILE__)}/template/#{template}.erb"), nil, '-')
185
180
  end
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'
3
3
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Protobuf::Util do
4
+
5
+ describe '.underscore' do
6
+ it 'underscores constant name' do
7
+ Protobuf::Util.underscore("HelloMoto").should eq "hello_moto"
8
+ end
9
+
10
+ context 'when constant name has uppercased word' do
11
+ it 'keeps the uppercased word together' do
12
+ Protobuf::Util.underscore("UPPERCase").should eq "upper_case"
13
+ Protobuf::Util.underscore("MDXService").should eq "mdx_service"
14
+ end
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-07 00:00:00.000000000Z
13
+ date: 2012-02-13 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: eventmachine
17
- requirement: &2165510400 !ruby/object:Gem::Requirement
17
+ requirement: &2152846700 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.12.10
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2165510400
25
+ version_requirements: *2152846700
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: eventually
28
- requirement: &2165509320 !ruby/object:Gem::Requirement
28
+ requirement: &2152845660 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2165509320
36
+ version_requirements: *2152845660
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: json_pure
39
- requirement: &2165507640 !ruby/object:Gem::Requirement
39
+ requirement: &2152844280 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.4
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2165507640
47
+ version_requirements: *2152844280
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rake
50
- requirement: &2165506400 !ruby/object:Gem::Requirement
50
+ requirement: &2152843280 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.8.7
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2165506400
58
+ version_requirements: *2152843280
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rspec
61
- requirement: &2165505500 !ruby/object:Gem::Requirement
61
+ requirement: &2152817360 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 2.8.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2165505500
69
+ version_requirements: *2152817360
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: yard
72
- requirement: &2165504360 !ruby/object:Gem::Requirement
72
+ requirement: &2152816600 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 0.7.4
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2165504360
80
+ version_requirements: *2152816600
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: redcarpet
83
- requirement: &2165503160 !ruby/object:Gem::Requirement
83
+ requirement: &2152815800 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 1.17.2
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *2165503160
91
+ version_requirements: *2152815800
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: simplecov
94
- requirement: &2165501280 !ruby/object:Gem::Requirement
94
+ requirement: &2152814840 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,7 +99,7 @@ dependencies:
99
99
  version: 0.5.4
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *2165501280
102
+ version_requirements: *2152814840
103
103
  description: ! 'Ruby implementation for Protocol Buffers. Works with other protobuf
104
104
  rpc implementations (e.g. Java, Python, C++).
105
105
 
@@ -192,6 +192,7 @@ files:
192
192
  - spec/proto/test_service_impl.rb
193
193
  - spec/spec_helper.rb
194
194
  - spec/unit/common/logger_spec.rb
195
+ - spec/unit/common/util_spec.rb
195
196
  - spec/unit/enum_spec.rb
196
197
  - spec/unit/message_spec.rb
197
198
  - spec/unit/rpc/client_spec.rb
@@ -288,6 +289,7 @@ test_files:
288
289
  - spec/proto/test_service_impl.rb
289
290
  - spec/spec_helper.rb
290
291
  - spec/unit/common/logger_spec.rb
292
+ - spec/unit/common/util_spec.rb
291
293
  - spec/unit/enum_spec.rb
292
294
  - spec/unit/message_spec.rb
293
295
  - spec/unit/rpc/client_spec.rb