rbs_draper 1.1.1 → 1.1.2

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: 485968223634d96cd141059a7895c8d2d16bea7aba9414d82510db8f2c5d6466
4
- data.tar.gz: 4e31de11d6a585ea5f7fae983671daf3233b16aa6475ea0e26c35546f0691c9a
3
+ metadata.gz: 78fc355f126b6fad89da00fd5a6f33a67fb0de4b7242f57a49826d3bad1f6246
4
+ data.tar.gz: c4d636fc57de09959c81ad783bd567f5ca5e4b56f46fd0ab5442d7d65c9f3154
5
5
  SHA512:
6
- metadata.gz: caeb6ed8933f96cb3453ad3e41014c418b738b7e79c9a23a3d8e0cbc02df520b2053af1a1f7f6d6129701a1202875a2f3cae518742032a75e202c8c36d7447c3
7
- data.tar.gz: c903adf4eaebd70a5f9438c33cda4000b64de63d199a04cc4e65278673abe21ad106b903dab2790b882f7095f86b19f436f33396657f1aefcaf98ddd9017d850
6
+ metadata.gz: 9cf067be8404f7a8842738994ae3971875a9542d0c2784cf3e0ecf9c33bf113298d457a67372d1131f899466c1a566838fe92063071db8808cbed99d755d4000
7
+ data.tar.gz: d684fb48ed0a3be6bc23ceb4ff4760c01ebfe3e2a6e16f8bc78cbeb65c01f4e7f10926e8bf8abd12ba3c253fe505fa52a2d06e87be0445b4f221fd3ef9150949
data/Gemfile.lock CHANGED
@@ -1,12 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_draper (1.1.1)
4
+ rbs_draper (1.1.2)
5
5
  activesupport
6
6
  draper
7
7
  fileutils
8
8
  rbs
9
- rbs_rails
10
9
 
11
10
  GEM
12
11
  remote: https://rubygems.org/
@@ -104,9 +103,6 @@ GEM
104
103
  rb-inotify (0.10.1)
105
104
  ffi (~> 1.0)
106
105
  rbs (3.1.3)
107
- rbs_rails (0.12.0)
108
- parser
109
- rbs (>= 1)
110
106
  regexp_parser (2.8.1)
111
107
  request_store (1.5.1)
112
108
  rack (>= 1.4)
@@ -7,7 +7,9 @@ module RbsDraper
7
7
  def create_raketask
8
8
  create_file "lib/tasks/rbs_draper.rake", <<~RUBY
9
9
  begin
10
- require 'rbs_draper/rake_task'
10
+ # frozen_string_literal: true
11
+
12
+ require "rbs_draper/rake_task"
11
13
 
12
14
  RbsDraper::RakeTask.new do |task|
13
15
  # If you have decorators having different names from models, you can specify the mapping from decorator names to model names.
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "draper"
4
- require "rbs_rails"
5
4
 
6
5
  module RbsDraper
7
6
  module Decoratable
@@ -22,23 +21,26 @@ module RbsDraper
22
21
 
23
22
  def initialize(klass)
24
23
  @klass = klass
25
- @klass_name = RbsRails::Util.module_name(klass)
24
+ @klass_name = klass.name || ""
26
25
  end
27
26
 
28
27
  def generate
29
- RbsRails::Util.format_rbs klass_decl
30
- end
31
-
32
- private
33
-
34
- def klass_decl
35
- <<~RBS
28
+ format <<~RBS
36
29
  #{header}
37
30
  #{method_decls}
38
31
  #{footer}
39
32
  RBS
40
33
  end
41
34
 
35
+ private
36
+
37
+ def format(rbs)
38
+ parsed = RBS::Parser.parse_signature(rbs)
39
+ StringIO.new.tap do |out|
40
+ RBS::Writer.new(out: out).write(parsed[1] + parsed[2])
41
+ end.string
42
+ end
43
+
42
44
  def header
43
45
  namespace = +""
44
46
  klass_name.split("::").map do |mod_name|
@@ -48,7 +50,7 @@ module RbsDraper
48
50
  when Class
49
51
  # @type var superclass: Class
50
52
  superclass = _ = mod_object.superclass
51
- superclass_name = RbsRails::Util.module_name(superclass)
53
+ superclass_name = superclass.name || "Object"
52
54
 
53
55
  "class #{mod_name} < ::#{superclass_name}"
54
56
  when Module
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "draper"
4
4
  require "rbs"
5
- require "rbs_rails"
6
5
 
7
6
  module RbsDraper
8
7
  module Decorator
@@ -15,7 +14,7 @@ module RbsDraper
15
14
 
16
15
  def initialize(klass, rbs_builder, decorated_class: nil)
17
16
  @klass = klass
18
- @klass_name = RbsRails::Util.module_name(klass)
17
+ @klass_name = klass.name || ""
19
18
  @rbs_builder = rbs_builder
20
19
  @decorated_class = decorated_class
21
20
  end
@@ -23,13 +22,7 @@ module RbsDraper
23
22
  def generate
24
23
  return if decorated_class_def.blank?
25
24
 
26
- RbsRails::Util.format_rbs klass_decl
27
- end
28
-
29
- private
30
-
31
- def klass_decl
32
- <<~RBS
25
+ format <<~RBS
33
26
  #{header}
34
27
  #{object_method_decls}
35
28
 
@@ -38,6 +31,15 @@ module RbsDraper
38
31
  RBS
39
32
  end
40
33
 
34
+ private
35
+
36
+ def format(rbs)
37
+ parsed = RBS::Parser.parse_signature(rbs)
38
+ StringIO.new.tap do |out|
39
+ RBS::Writer.new(out: out).write(parsed[1] + parsed[2])
40
+ end.string
41
+ end
42
+
41
43
  def header
42
44
  namespace = +""
43
45
  klass_name.split("::").map do |mod_name|
@@ -47,7 +49,7 @@ module RbsDraper
47
49
  when Class
48
50
  # @type var superclass: Class
49
51
  superclass = _ = mod_object.superclass
50
- superclass_name = RbsRails::Util.module_name(superclass)
52
+ superclass_name = superclass.name || "Object"
51
53
 
52
54
  "class #{mod_name} < ::#{superclass_name}"
53
55
  when Module
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsDraper
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2"
5
5
  end
@@ -2,7 +2,7 @@
2
2
  sources:
3
3
  - type: git
4
4
  name: ruby/gem_rbs_collection
5
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
5
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
6
6
  remote: https://github.com/ruby/gem_rbs_collection.git
7
7
  repo_dir: gems
8
8
  path: ".gem_rbs_collection"
@@ -171,10 +171,6 @@ gems:
171
171
  version: 3.1.3
172
172
  source:
173
173
  type: rubygems
174
- - name: rbs_rails
175
- version: 0.12.0
176
- source:
177
- type: rubygems
178
174
  - name: rdoc
179
175
  version: '0'
180
176
  source:
data/rbs_draper.gemspec CHANGED
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "draper"
32
32
  spec.add_dependency "fileutils"
33
33
  spec.add_dependency "rbs"
34
- spec.add_dependency "rbs_rails"
35
34
 
36
35
  # For more information and examples about making a new gem, check out our
37
36
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -12,7 +12,7 @@ module RbsDraper
12
12
 
13
13
  private
14
14
 
15
- def klass_decl: () -> String
15
+ def format: (String rbs) -> String
16
16
  def header: () -> String
17
17
  def method_decls: () -> String
18
18
  def footer: () -> String
@@ -16,7 +16,7 @@ module RbsDraper
16
16
 
17
17
  private
18
18
 
19
- def klass_decl: () -> String
19
+ def format: (String rbs) -> String
20
20
  def header: () -> String
21
21
  def object_method_decls: () -> String
22
22
  def method_decls: () -> String?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi KOMIYA
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rbs_rails
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  description: A RBS files generator for Draper decorators
84
70
  email:
85
71
  - i.tkomiya@gmail.com