rbytes 0.1.3 → 0.2.0

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: f3aaeb47c729c4b3246544749d77204d17ecd9b27319158770cd8047cbb4c284
4
- data.tar.gz: 5d7da2c374643dad62d6047f406488ef092d7bb2f2464fc211a8fa35cd83f896
3
+ metadata.gz: f8780a2ff433a3b3e11c59a05fe7bf73a1a742463c659bbf8abd835b17242d43
4
+ data.tar.gz: 10fd5d4eb9271e6e3be8fe2f71262e03a743dbf077b71a925498796c20e2cafe
5
5
  SHA512:
6
- metadata.gz: e288e3f5c61130bdc676ca3a8bf14e40e6c796366283c27b7067e3588057bf516a3d160cca8547216f91f805d614c5e646453f84382bd528f2d1973c0b8dffe4
7
- data.tar.gz: 7b539e851f07d83a897477413c8ed4f1b2f399b985523085d037c123df6c01285de54702bd1c0392be146a7a7424f3654245641efbdd068f89c8f5d9776713fb
6
+ metadata.gz: c681d786e67cf6423e95b78b687bfec4dea5460ec3238656ed3319347240eae199a21fbf5bc05fb3d67a70fdd6862797712401085e239ce94c56ccb25f7ceea9
7
+ data.tar.gz: e8fae36e2fa7daa3acfd71a760b969e6c09c23dc248f1bedd479930e7c9e064b7c6027e987fa61683250c36a65398cc784f174f2f9890ce0a3764300abe76088
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.2.0 (2023-04-15)
6
+
7
+ - Add `#import_template` directive to inline other templates.
8
+
9
+ ## 0.1.4 (2023-04-11)
10
+
11
+ - Fix publishing to RailsBytes.
12
+
5
13
  ## 0.1.3 (2023-03-20)
6
14
 
7
15
  - Fix preparing dummy to alwasy set destination.
data/README.md CHANGED
@@ -11,10 +11,13 @@ Ruby Bytes is a tool to build application templates for Ruby and Rails applicati
11
11
 
12
12
  We also provide a [GitHub action](#github-action) to compile and deploy templates continuously.
13
13
 
14
+ > 📖 Read more about Ruby Bytes and application templates in the [Ruby Bytes, or generating standalone generators](https://evilmartians.com/chronicles/ruby-bytes-or-generating-standalone-generators) post.
15
+
14
16
  ## Examples
15
17
 
16
18
  - [ruby-on-whales][]
17
19
  - [view_component-contrib][]
20
+ - [rubocoping][]
18
21
 
19
22
  See also examples in the [templates](https://github.com/palkan/rbytes/tree/master/templates) folder.
20
23
 
@@ -104,6 +107,22 @@ file "config/anycable.yml", ERB.new(
104
107
 
105
108
  **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.
106
109
 
110
+ Ruby Bytes can also import a sub-template into your template. Simply use the `#import_template` helper in your template:
111
+
112
+ ```erb
113
+ # subtemplate/_partial.rb
114
+ say "Hello from subtemplate's partial!"
115
+
116
+ # subtemplate/subtemplate.rb
117
+ <%= include "partial" %>
118
+
119
+ # template.rb
120
+ <%= import_template("subtemplate/subtemplate.rb")>
121
+ ```
122
+
123
+ Note that the full filename must be passed to the `#import_template` helper, including any file extension, unlike the `#include` helper. All templates within the subtemplate directory will consider that to be their root directory.
124
+
125
+
107
126
  ### Compiling templates
108
127
 
109
128
  You can compile a template by using the `rbytes` executable:
@@ -268,3 +287,4 @@ The gem is available as open source under the terms of the [MIT License](http://
268
287
  [RailsBytes]: https://railsbytes.com
269
288
  [ruby-on-whales]: https://github.com/evilmartians/ruby-on-whales
270
289
  [view_component-contrib]: https://github.com/palkan/view_component-contrib
290
+ [rubocoping]: https://github.com/evilmartians/rubocoping-generator
@@ -32,6 +32,10 @@ module RubyBytes
32
32
  indented(render(File.read(resolve_path(path))), indent)
33
33
  end
34
34
 
35
+ def import_template(path, indent: 0)
36
+ indented(self.class.new(File.join(root, path)).render, indent)
37
+ end
38
+
35
39
  private
36
40
 
37
41
  PATH_CANDIDATES = [
@@ -27,7 +27,7 @@ module RubyBytes
27
27
  data,
28
28
  {
29
29
  "Content-Type" => "application/json",
30
- "Authorization" => "Bearer GGpxArFDSa2x3MT4BQNcyxG6"
30
+ "Authorization" => "Bearer #{token}"
31
31
  }
32
32
  )
33
33
  end.then do |response|
@@ -20,7 +20,7 @@ class Rbytes < Thor
20
20
  # TODO: Add more extensions
21
21
  class ::String
22
22
  def parameterize
23
- gsub("::", "/").gsub(/([a-z])([A-Z])/, '\1-\2').downcase
23
+ downcase.gsub(/[^a-z0-9\-_]+/, '-').gsub(/-{2,}/, '-').gsub(/^-|-$/, '')
24
24
  end
25
25
 
26
26
  def underscore
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyBytes # :nodoc:
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -7,7 +7,7 @@ rescue LoadError
7
7
  # TODO: Add more extensions
8
8
  class ::String
9
9
  def parameterize
10
- gsub("::", "/").gsub(/([a-z])([A-Z])/, '\1-\2').downcase
10
+ downcase.gsub(/[^a-z0-9\-_]+/, '-').gsub(/-{2,}/, '-').gsub(/^-|-$/, '')
11
11
  end
12
12
 
13
13
  def underscore
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.3
4
+ version: 0.2.0
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-21 00:00:00.000000000 Z
11
+ date: 2023-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor