twirp_rails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb9cd76586bee57eba493e9578eb1ddf48c71f1f6aef959d32a73e7a5feafb81
4
- data.tar.gz: 6fb7194c09bcdad9392f9f5f1c902efed00b32472ab3ffbb54773cfd15f544d3
3
+ metadata.gz: f76a67c6644535dc835e68bb6b47b28661dca6922b9733653f0480e297f65bb1
4
+ data.tar.gz: f0a855d0cb9d1a0b693e5b11c03d7bdca9486ff12bf82ac103298bfdf67dfe88
5
5
  SHA512:
6
- metadata.gz: 58548bffd0a6faf5a3a55407e5bb88b53cec6ee37d667bff76b4ec34e579bf2960503561d70d8d7dc7bca2a278d2916223ed3516d8c5fadc3ab3cae16c3cfcb1
7
- data.tar.gz: ee013919391df0d53e4c5a1acc5a145fff4a39769ed83fbdc98e06cd8bb2ea64e8bda05f3950d534a3112d8d049c449044796395c399b5e0f2a728566d0065e0
6
+ metadata.gz: 22b8a3a2c75e2a5084a5184c1137726ce3f8978f111a2cd1749028492276b518ab2c03b19e799d9ec858023fe51ce01d79f6d7702357e761ec555e90ac832a5b
7
+ data.tar.gz: 87bf3f8cc09b9694cdc1f949de56d38f1a6283bc2d6237b0e06f75b15266c4009015a13efa6f74966623d01db2773cc3e4a51fb7bce17401b14830f78c795d4d
data/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 0.1.3 - 2020-01-28
8
+
9
+ ### Added
10
+ - convert package.message type to Package::Message
11
+
12
+ ### Fixed
13
+ - twirp_ruby missing module workaround https://github.com/twitchtv/twirp-ruby/issues/48
14
+
7
15
  ## 0.1.2 - 2020-01-27
8
16
 
9
17
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twirp_rails (0.1.2)
4
+ twirp_rails (0.1.3)
5
5
  railties (~> 6.0)
6
6
  twirp (~> 1)
7
7
 
@@ -27,17 +27,23 @@ class TwirpGenerator < Rails::Generators::NamedBase
27
27
 
28
28
  def generate_twirp_files
29
29
  in_root do
30
- cmd = protoc_cmd
30
+ proto_files = Dir.glob 'app/protos/**/*.proto'
31
31
 
32
- `#{cmd}`
32
+ proto_files.each do |file|
33
+ cmd = protoc_cmd(file)
33
34
 
34
- raise "protoc failure: #{cmd}" unless $?.success?
35
+ `#{cmd}`
36
+
37
+ raise "protoc failure: #{cmd}" unless $?.success?
38
+ end
35
39
  end
36
40
  end
37
41
 
38
42
  PROTO_RPC_REGEXP = /\brpc\s+(\S+)\s*\(\s*(\S+)\s*\)\s*returns\s*\(\s*(\S+)\s*\)/m.freeze
43
+
39
44
  def generate_handler
40
- calls = proto_content.scan(PROTO_RPC_REGEXP).map do |method, arg_type, result_type|
45
+ methods = proto_content.scan(PROTO_RPC_REGEXP).map do |method, arg_type, result_type|
46
+ result_type = proto_type_to_ruby(result_type)
41
47
  <<-RUBY
42
48
  def #{method.underscore}(req, _env)
43
49
  #{result_type}.new
@@ -45,11 +51,11 @@ class TwirpGenerator < Rails::Generators::NamedBase
45
51
  RUBY
46
52
  end.join("\n")
47
53
 
48
- # Пока считаем, что имя сервиса совпадает с именем файла,
54
+ # Let us assume that the service name is the same file name
49
55
  create_file "app/rpc/#{file_name}_handler.rb", <<~RUBY
50
56
  class #{class_name}Handler
51
57
 
52
- #{calls}end
58
+ #{methods}end
53
59
  RUBY
54
60
  end
55
61
 
@@ -63,6 +69,10 @@ class TwirpGenerator < Rails::Generators::NamedBase
63
69
 
64
70
  private
65
71
 
72
+ def proto_type_to_ruby(result_type)
73
+ result_type.split('.').map(&:camelize).join('::')
74
+ end
75
+
66
76
  def from_rails_root(&block)
67
77
  old_dir = Dir.pwd
68
78
  Dir.chdir Rails.root
@@ -71,12 +81,11 @@ class TwirpGenerator < Rails::Generators::NamedBase
71
81
  Dir.chdir old_dir
72
82
  end
73
83
 
74
- def protoc_cmd
84
+ def protoc_cmd(files)
75
85
  FileUtils.mkdir_p 'lib/twirp'
76
86
  flags = "--proto_path=app/protos --ruby_out=lib/twirp --twirp_ruby_out=lib/twirp --plugin=#{PLUGIN_PATH}"
77
87
 
78
- proto_files = Dir.glob 'app/protos/*.proto'
79
- "#{PROTOC_PATH} #{flags} #{proto_files.join(' ')}"
88
+ "#{PROTOC_PATH} #{flags} #{files}"
80
89
  end
81
90
 
82
91
  def proto_content
@@ -1,3 +1,3 @@
1
1
  module TwirpRails
2
- VERSION = "0.1.2"
2
+ VERSION = '0.1.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twirp_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Zimin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twirp