rbs_draper 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile.lock +2 -6
 - data/README.md +1 -1
 - data/lib/generators/rbs_draper/install_generator.rb +4 -2
 - data/lib/rbs_draper/decoratable.rb +12 -10
 - data/lib/rbs_draper/decorator.rb +12 -10
 - data/lib/rbs_draper/version.rb +1 -1
 - data/rbs_collection.lock.yaml +1 -5
 - data/rbs_draper.gemspec +0 -1
 - data/sig/rbs_draper/decoratable.rbs +1 -1
 - data/sig/rbs_draper/decorator.rbs +1 -1
 - metadata +1 -15
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 78fc355f126b6fad89da00fd5a6f33a67fb0de4b7242f57a49826d3bad1f6246
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c4d636fc57de09959c81ad783bd567f5ca5e4b56f46fd0ab5442d7d65c9f3154
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 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. 
     | 
| 
      
 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)
         
     | 
| 
         @@ -127,7 +123,7 @@ GEM 
     | 
|
| 
       127 
123 
     | 
    
         
             
                  diff-lcs (>= 1.2.0, < 2.0)
         
     | 
| 
       128 
124 
     | 
    
         
             
                  rspec-support (~> 3.12.0)
         
     | 
| 
       129 
125 
     | 
    
         
             
                rspec-support (3.12.0)
         
     | 
| 
       130 
     | 
    
         
            -
                rubocop (1.56. 
     | 
| 
      
 126 
     | 
    
         
            +
                rubocop (1.56.2)
         
     | 
| 
       131 
127 
     | 
    
         
             
                  base64 (~> 0.1.1)
         
     | 
| 
       132 
128 
     | 
    
         
             
                  json (~> 2.3)
         
     | 
| 
       133 
129 
     | 
    
         
             
                  language_server-protocol (>= 3.17.0)
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ If you have decorators having different names from models, you can specify the m 
     | 
|
| 
       18 
18 
     | 
    
         
             
            decorator names to model names in `lib/tasks/rbs_draper.rake`. For example:
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                RbsDraper::RakeTask.new do |task|
         
     | 
| 
       21 
     | 
    
         
            -
                  task.mapping = -> { { AdminUserDecorator 
     | 
| 
      
 21 
     | 
    
         
            +
                  task.mapping = -> { { AdminUserDecorator => User } }
         
     | 
| 
       22 
22 
     | 
    
         
             
                end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
            ## Usage
         
     | 
| 
         @@ -7,13 +7,15 @@ module RbsDraper 
     | 
|
| 
       7 
7 
     | 
    
         
             
                def create_raketask
         
     | 
| 
       8 
8 
     | 
    
         
             
                  create_file "lib/tasks/rbs_draper.rake", <<~RUBY
         
     | 
| 
       9 
9 
     | 
    
         
             
                    begin
         
     | 
| 
       10 
     | 
    
         
            -
                       
     | 
| 
      
 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.
         
     | 
| 
       14 
16 
     | 
    
         
             
                        # The value should be a lambda that returns a hash to load decorators and models easily.
         
     | 
| 
       15 
17 
     | 
    
         
             
                        #
         
     | 
| 
       16 
     | 
    
         
            -
                        # task.mapping = -> { { AdminUserDecorator 
     | 
| 
      
 18 
     | 
    
         
            +
                        # task.mapping = -> { { AdminUserDecorator => User } }
         
     | 
| 
       17 
19 
     | 
    
         
             
                      end
         
     | 
| 
       18 
20 
     | 
    
         
             
                    rescue LoadError
         
     | 
| 
       19 
21 
     | 
    
         
             
                      # failed to load rbs_draper. Skip to load rbs_draper tasks.
         
     | 
| 
         @@ -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 =  
     | 
| 
      
 24 
     | 
    
         
            +
                    @klass_name = klass.name || ""
         
     | 
| 
       26 
25 
     | 
    
         
             
                  end
         
     | 
| 
       27 
26 
     | 
    
         | 
| 
       28 
27 
     | 
    
         
             
                  def generate
         
     | 
| 
       29 
     | 
    
         
            -
                     
     | 
| 
       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 =  
     | 
| 
      
 53 
     | 
    
         
            +
                        superclass_name = superclass.name || "Object"
         
     | 
| 
       52 
54 
     | 
    
         | 
| 
       53 
55 
     | 
    
         
             
                        "class #{mod_name} < ::#{superclass_name}"
         
     | 
| 
       54 
56 
     | 
    
         
             
                      when Module
         
     | 
    
        data/lib/rbs_draper/decorator.rb
    CHANGED
    
    | 
         @@ -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 =  
     | 
| 
      
 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 
     | 
    
         
            -
                     
     | 
| 
       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 =  
     | 
| 
      
 52 
     | 
    
         
            +
                        superclass_name = superclass.name || "Object"
         
     | 
| 
       51 
53 
     | 
    
         | 
| 
       52 
54 
     | 
    
         
             
                        "class #{mod_name} < ::#{superclass_name}"
         
     | 
| 
       53 
55 
     | 
    
         
             
                      when Module
         
     | 
    
        data/lib/rbs_draper/version.rb
    CHANGED
    
    
    
        data/rbs_collection.lock.yaml
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            sources:
         
     | 
| 
       3 
3 
     | 
    
         
             
            - type: git
         
     | 
| 
       4 
4 
     | 
    
         
             
              name: ruby/gem_rbs_collection
         
     | 
| 
       5 
     | 
    
         
            -
              revision:  
     | 
| 
      
 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
         
     | 
    
        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. 
     | 
| 
      
 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
         
     |