rbytes 0.1.0 → 0.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/CHANGELOG.md +8 -0
- data/README.md +13 -3
- data/lib/ruby_bytes/cli.rb +1 -0
- data/lib/ruby_bytes/compiler.rb +4 -4
- data/lib/ruby_bytes/test_case.rb +10 -3
- data/lib/ruby_bytes/version.rb +1 -1
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 240c05001c82217a6c81800227e8043364abf995559420377265e921bf8b30a6
         | 
| 4 | 
            +
              data.tar.gz: 44c8486ef55774b3fbf8bf6781dc17202e2b5e9a8f885fe7db8395ca7fa59e0c
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d85b989709ffb1a3eb9a820516a5097bc87a6788b6384faa36ca00ec2608e9df7a366383826761b7938dfbcf6976b5335cfb90ce1d667af61c1c957fa88b6ec1
         | 
| 7 | 
            +
              data.tar.gz: 149d5ec020537aaedb78c5d17d6dd9e56f75d33493b22ec6f12b1679515065f672e9bb91859a726bb90ee38766ec5ed3a61f4ffb08801e4fd315bc9be22e28c8
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -53,6 +53,16 @@ You can also install Ruby Bytes as a plugin for Thor (see [Thor integration](#th | |
| 53 53 |  | 
| 54 54 | 
             
            ## Writing templates
         | 
| 55 55 |  | 
| 56 | 
            +
            The quickest way to get started with using Ruby Bytes to build templates is to use our generator to create a project:
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            ```sh
         | 
| 59 | 
            +
            $ rbytes install https://railsbytes.com/script/V2GsbB
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            ...
         | 
| 62 | 
            +
            ```
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            ### Splitting template into partials
         | 
| 65 | 
            +
             | 
| 56 66 | 
             
            Ruby Bytes adds partial support to Thor/Rails templates. For that, you can use `#include` and `#render` methods:
         | 
| 57 67 |  | 
| 58 68 | 
             
            ```erb
         | 
| @@ -78,7 +88,7 @@ cable_adapter = ask? "Which AnyCable pub/sub adapter do you want to use?" | |
| 78 88 | 
             
            file "config/anycable.yml", <%= code("anycable.yml") %>
         | 
| 79 89 | 
             
            ```
         | 
| 80 90 |  | 
| 81 | 
            -
            The compiled template will  | 
| 91 | 
            +
            The compiled template will look like this:
         | 
| 82 92 |  | 
| 83 93 | 
             
            ```erb
         | 
| 84 94 | 
             
            cable_adapter = ask? "Which AnyCable pub/sub adapter do you want to use?"
         | 
| @@ -92,7 +102,7 @@ file "config/anycable.yml", ERB.new( | |
| 92 102 | 
             
              ], trim_mode: "<>").result(binding)
         | 
| 93 103 | 
             
            ```
         | 
| 94 104 |  | 
| 95 | 
            -
            **NOTE:** By default, we assume that partials are stored next to the template's  | 
| 105 | 
            +
            **NOTE:** By default, we assume that partials are stored next to the template's entry-point. Partials may have the "_" prefix and ".rb" or ".tt" suffixes.
         | 
| 96 106 |  | 
| 97 107 | 
             
            ### Compiling templates
         | 
| 98 108 |  | 
| @@ -249,7 +259,7 @@ Bug reports and pull requests are welcome on GitHub at [https://github.com/palka | |
| 249 259 |  | 
| 250 260 | 
             
            ## Credits
         | 
| 251 261 |  | 
| 252 | 
            -
            This gem is generated via [ | 
| 262 | 
            +
            This gem is generated via [`newgem` template](https://github.com/palkan/newgem) by [@palkan](https://github.com/palkan).
         | 
| 253 263 |  | 
| 254 264 | 
             
            ## License
         | 
| 255 265 |  | 
    
        data/lib/ruby_bytes/cli.rb
    CHANGED
    
    
    
        data/lib/ruby_bytes/compiler.rb
    CHANGED
    
    | @@ -22,14 +22,14 @@ module RubyBytes | |
| 22 22 | 
             
                  contents = File.read(resolve_path(path))
         | 
| 23 23 | 
             
                  %(ERB.new(
         | 
| 24 24 | 
             
                *[
         | 
| 25 | 
            -
              <<~' | 
| 26 | 
            -
             | 
| 27 | 
            -
               | 
| 25 | 
            +
              <<~'TCODE'
         | 
| 26 | 
            +
            #{contents}
         | 
| 27 | 
            +
              TCODE
         | 
| 28 28 | 
             
              ], trim_mode: "<>").result(binding))
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 31 | 
             
                def include(path, indent: 0)
         | 
| 32 | 
            -
                  indented(File.read(resolve_path(path)), indent)
         | 
| 32 | 
            +
                  indented(render(File.read(resolve_path(path))), indent)
         | 
| 33 33 | 
             
                end
         | 
| 34 34 |  | 
| 35 35 | 
             
                private
         | 
    
        data/lib/ruby_bytes/test_case.rb
    CHANGED
    
    | @@ -11,9 +11,6 @@ module RubyBytes | |
| 11 11 | 
             
              class TestCase < Minitest::Test
         | 
| 12 12 | 
             
                TMP_DIR = File.join(Dir.pwd, "tmp", "rbytes_test")
         | 
| 13 13 |  | 
| 14 | 
            -
                FileUtils.rm_rf(TMP_DIR) if File.directory?(TMP_DIR)
         | 
| 15 | 
            -
                FileUtils.mkdir_p(TMP_DIR)
         | 
| 16 | 
            -
             | 
| 17 14 | 
             
                Rbytes::Base.source_paths << TMP_DIR
         | 
| 18 15 |  | 
| 19 16 | 
             
                # Patch Thor::LineEditor to use Basic in tests
         | 
| @@ -81,6 +78,11 @@ module RubyBytes | |
| 81 78 |  | 
| 82 79 | 
             
                attr_accessor :destination
         | 
| 83 80 |  | 
| 81 | 
            +
                def setup
         | 
| 82 | 
            +
                  FileUtils.rm_rf(TMP_DIR) if File.directory?(TMP_DIR)
         | 
| 83 | 
            +
                  FileUtils.mkdir_p(TMP_DIR)
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 84 86 | 
             
                def prepare_dummy
         | 
| 85 87 | 
             
                  # Then, copy the dummy app if any
         | 
| 86 88 | 
             
                  dummy = self.class.dummy_app
         | 
| @@ -169,6 +171,11 @@ module RubyBytes | |
| 169 171 | 
             
                  assert File.file?(fullpath), "File not found: #{path}"
         | 
| 170 172 | 
             
                end
         | 
| 171 173 |  | 
| 174 | 
            +
                def refute_file(path)
         | 
| 175 | 
            +
                  fullpath = File.join(destination, path)
         | 
| 176 | 
            +
                  refute File.file?(fullpath), "File must not exist: #{path}"
         | 
| 177 | 
            +
                end
         | 
| 178 | 
            +
             | 
| 172 179 | 
             
                def refute_file_contains(path, body)
         | 
| 173 180 | 
             
                  fullpath = File.join(destination, path)
         | 
| 174 181 | 
             
                  assert File.file?(fullpath), "File not found: #{path}"
         | 
    
        data/lib/ruby_bytes/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rbytes
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Vladimir Dementyev
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-03- | 
| 11 | 
            +
            date: 2023-03-20 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: thor
         | 
| @@ -70,7 +70,8 @@ description: Ruby Bytes is a tool to build application templates for Ruby and Ra | |
| 70 70 | 
             
              applications
         | 
| 71 71 | 
             
            email:
         | 
| 72 72 | 
             
            - dementiev.vm@gmail.com
         | 
| 73 | 
            -
            executables: | 
| 73 | 
            +
            executables:
         | 
| 74 | 
            +
            - rbytes
         | 
| 74 75 | 
             
            extensions: []
         | 
| 75 76 | 
             
            extra_rdoc_files: []
         | 
| 76 77 | 
             
            files:
         |