erb-indent 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.rspec_status +3 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/erb-indent.gemspec +29 -0
- data/lib/erb/indent.rb +59 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c7aa043852488fc2496bb406be6143f963c76288f076696069e501e4e08ef8ed
|
4
|
+
data.tar.gz: de21f0338daa3fb8417d4fb18b6db05664df11745bc2a955e22333ee2fbe52c0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4920f2bef1e1525d1609d76935e977929f0b447d37ae27ddb43972cea4ec753bf6dfc2fbcd632dcbf0d9c91495d39b13dcb38c9847120451883772880537f4cd
|
7
|
+
data.tar.gz: 5f4632f91e838fb1b7b98cca685b07930b44f66ab6dd9ae38c22c48d309ed59e250c32d434073db811cf80eeb4fff9dbbdbc3c59048a9402aa77dfaf8cbfee57
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rspec_status
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
erb-indent (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.2)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
method_source (0.9.2)
|
12
|
+
pry (0.12.2)
|
13
|
+
coderay (~> 1.1.0)
|
14
|
+
method_source (~> 0.9.0)
|
15
|
+
rake (10.5.0)
|
16
|
+
rspec (3.8.0)
|
17
|
+
rspec-core (~> 3.8.0)
|
18
|
+
rspec-expectations (~> 3.8.0)
|
19
|
+
rspec-mocks (~> 3.8.0)
|
20
|
+
rspec-core (3.8.0)
|
21
|
+
rspec-support (~> 3.8.0)
|
22
|
+
rspec-expectations (3.8.2)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.8.0)
|
25
|
+
rspec-mocks (3.8.0)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.8.0)
|
28
|
+
rspec-support (3.8.0)
|
29
|
+
|
30
|
+
PLATFORMS
|
31
|
+
ruby
|
32
|
+
|
33
|
+
DEPENDENCIES
|
34
|
+
bundler (~> 1.17)
|
35
|
+
erb-indent!
|
36
|
+
pry
|
37
|
+
rake (~> 10.0)
|
38
|
+
rspec (>= 3.0)
|
39
|
+
|
40
|
+
BUNDLED WITH
|
41
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Takashi Kokubun
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Erb::Indent
|
2
|
+
|
3
|
+
A gem that supports [Feature #15538](https://bugs.ruby-lang.org/issues/15538).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install erb-indent
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```rb
|
12
|
+
require 'erb/indent'
|
13
|
+
|
14
|
+
erb = <<-ERB
|
15
|
+
1
|
16
|
+
<%| [2, 3, 4].each do |num| -%>
|
17
|
+
<% unless num == 3 -%>
|
18
|
+
<%= num %>
|
19
|
+
<% end -%>
|
20
|
+
<%| end -%>
|
21
|
+
5
|
22
|
+
ERB
|
23
|
+
|
24
|
+
puts Erb::Indent.new(erb, nil, "-").result
|
25
|
+
```
|
26
|
+
|
27
|
+
```
|
28
|
+
1
|
29
|
+
2
|
30
|
+
4
|
31
|
+
5
|
32
|
+
```
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/erb-indent.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "erb/indent"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "erb-indent"
|
8
|
+
spec.version = Erb::Indent::VERSION
|
9
|
+
spec.authors = ["Takashi Kokubun"]
|
10
|
+
spec.email = ["takashikkbn@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{ERB that supports de-indentation}
|
13
|
+
spec.description = %q{ERB that supports de-indentation}
|
14
|
+
spec.homepage = "https://github.com/k0kubun/erb-indent"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", ">= 3.0"
|
29
|
+
end
|
data/lib/erb/indent.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
module Erb
|
4
|
+
class Indent < ERB
|
5
|
+
VERSION = '0.0.1'
|
6
|
+
|
7
|
+
class IndentScanner < ERB::Compiler::TrimScanner
|
8
|
+
def stags
|
9
|
+
['<%\|', *super]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class IndentCompiler < ERB::Compiler
|
14
|
+
def initialize(*)
|
15
|
+
super
|
16
|
+
@indent_level = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_put_cmd(out, content)
|
20
|
+
if @indent_level
|
21
|
+
super(out, content.sub(/^ +/, ' ' * @indent_level))
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_insert_cmd(out, content)
|
28
|
+
if @indent_level
|
29
|
+
super(out, "(#{content}).to_s.sub(/^ +/, ' ' * #{@indent_level})")
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def compile_stag(stag, out, scanner)
|
36
|
+
case stag
|
37
|
+
when '<%|'
|
38
|
+
if @indent_level
|
39
|
+
@indent_level = nil
|
40
|
+
else
|
41
|
+
spaces = content.lines.last&.match(/\A +/)&.to_s
|
42
|
+
@indent_level = spaces ? spaces.length : 0
|
43
|
+
end
|
44
|
+
super('<%', out, scanner)
|
45
|
+
else
|
46
|
+
super
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def make_scanner(src)
|
51
|
+
IndentScanner.new(src, @trim_mode, @percent)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def make_compiler(trim_mode)
|
56
|
+
IndentCompiler.new(trim_mode)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: erb-indent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takashi Kokubun
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: ERB that supports de-indentation
|
56
|
+
email:
|
57
|
+
- takashikkbn@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".rspec_status"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- erb-indent.gemspec
|
73
|
+
- lib/erb/indent.rb
|
74
|
+
homepage: https://github.com/k0kubun/erb-indent
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.7.6
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: ERB that supports de-indentation
|
98
|
+
test_files: []
|