touch_erb 0.2.0 → 0.3.0
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 +21 -0
- data/Gemfile.lock +1 -1
- data/lib/touch_erb/cli.rb +19 -4
- data/lib/touch_erb/template_dir.rb +10 -3
- data/lib/touch_erb/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79424c1c87d84b01ba1fcd88fd9b997b0dcd91e0267de56e3f199ab4e544f5bb
|
4
|
+
data.tar.gz: d3685fa00d08a8cc9affb53b8dd72a234d66713125f02ec7cc07052858cc7c01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 136fe213550885833ed9d7cda18eb4c567e4e3c051f7952aed8c008d068da28d4b9953e3aa9cd56a18ff7a1da2db1e479b55bb9fbde09cac33dc5116fab4e5a2
|
7
|
+
data.tar.gz: 448167cc7d531477a4befa144216e984abd32a330064bc7c22a9a6ba816574fb75c7e609d18641f8460a8079135c3844762ff2e7150bf541f1db49c999380552
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
### v0.3.0 (Wed Feb 20 12:56:08 2019 +0900)
|
2
|
+
|
3
|
+
- Merge pull request #17 from himanoa/implement-list (Mon Feb 18 09:22:38 2019 +0900) [97d9c79](https://github.com/himanoa/touch_erb/commit/97d9c79a6a60396561b80a5adf07946745d4755c)
|
4
|
+
- chore(bugfix): Update Gemfile.lock (Mon Feb 18 09:25:42 2019 +0900) [b487601](https://github.com/himanoa/touch_erb/commit/b487601976b6385fa7d7e3f04fcb66fa78d1c9de)
|
5
|
+
- refactor: Add create_dir parameter (Tue Feb 19 23:45:33 2019 +0900) [cbd8b48](https://github.com/himanoa/touch_erb/commit/cbd8b48172eb79939bb7b5951a5ecf11eaad4025)
|
6
|
+
- feat: Create ./touch_erb to current directory when not exist in current directory (Tue Feb 19 23:54:48 2019 +0900) [a1fe0e0](https://github.com/himanoa/touch_erb/commit/a1fe0e0667dab7ac74e3ce46018c7e4693f48bdf)
|
7
|
+
- feat: Implement local options (Wed Feb 20 12:34:13 2019 +0900) [3c82c7a](https://github.com/himanoa/touch_erb/commit/3c82c7ac542b4f1bd7c6ba613233bf2c452fc2aa)
|
8
|
+
- Merge pull request #19 from himanoa/implement-local-dir-template-support (Wed Feb 20 12:46:55 2019 +0900) [d956d7d](https://github.com/himanoa/touch_erb/commit/d956d7d8e53e2bb1e0494b99d9143c4dc50c2f3a)
|
9
|
+
- Release v0.3.0 (Wed Feb 20 12:56:08 2019 +0900) [85ed4af](https://github.com/himanoa/touch_erb/commit/85ed4afbb4ef1c1749ed310466074178c1063a76)
|
10
|
+
|
11
|
+
### v0.2.0 (Mon Feb 18 09:19:04 2019 +0900)
|
12
|
+
|
13
|
+
- docs: Update README.md (Fri Feb 15 05:49:24 2019 +0900) [1c42d30](https://github.com/himanoa/touch_erb/commit/1c42d3045f04472b947d37cfd82a1d65986bd8de)
|
14
|
+
- chore(bugfix): Passed `bundle install` (Fri Feb 15 06:34:36 2019 +0900) [18abeef](https://github.com/himanoa/touch_erb/commit/18abeef4098b0037acd96372e0fe1f8dd2b7fc5e)
|
15
|
+
- chore: Add minitest-power_assert to dev dependency (Mon Feb 18 08:54:26 2019 +0900) [deddf4c](https://github.com/himanoa/touch_erb/commit/deddf4cbfaa53bc4c945746c922da3d552431028)
|
16
|
+
- chore: Activate power assert (Mon Feb 18 09:01:16 2019 +0900) [4651f80](https://github.com/himanoa/touch_erb/commit/4651f80b79ccfc479c39febdb7a5036b9d86963b)
|
17
|
+
- feat: Implement TemplateDir#list (Mon Feb 18 09:03:43 2019 +0900) [1c080e3](https://github.com/himanoa/touch_erb/commit/1c080e352f204e1f7e027e9b10e7050737db54cf)
|
18
|
+
- feat: Define list command (Mon Feb 18 09:10:10 2019 +0900) [97393d9](https://github.com/himanoa/touch_erb/commit/97393d929975754c00ea60c10adbe3979c071e4d)
|
19
|
+
- test(bugfix): Fix test case (Mon Feb 18 09:14:10 2019 +0900) [cfc58dc](https://github.com/himanoa/touch_erb/commit/cfc58dc157f35ec9fe91a7688b66834cc9a9abe6)
|
20
|
+
- Release v0.2.0 (Mon Feb 18 09:19:04 2019 +0900) [425f4d1](https://github.com/himanoa/touch_erb/commit/425f4d1f7760f70efdd17d8be0a5fa94a29a0fd0)
|
21
|
+
|
data/Gemfile.lock
CHANGED
data/lib/touch_erb/cli.rb
CHANGED
@@ -9,12 +9,22 @@ module TouchErb
|
|
9
9
|
def initialize(*args)
|
10
10
|
super
|
11
11
|
@template_dir = TouchErb::TemplateDir.new
|
12
|
+
|
13
|
+
@local_template_dir = TouchErb::TemplateDir.new(
|
14
|
+
File.join(Dir.pwd, '.touch_erb'),
|
15
|
+
false
|
16
|
+
)
|
12
17
|
end
|
13
18
|
|
14
19
|
desc "add <source>", "Create new erb file"
|
15
|
-
option
|
20
|
+
option "local", aliases: "l", type: :boolean
|
21
|
+
method_option :source, :type => :string, :desc => "Create new erb template to {current directory}/.touch_erb/"
|
16
22
|
def add(source)
|
17
|
-
|
23
|
+
target_dir = @template_dir
|
24
|
+
if options[:local]
|
25
|
+
target_dir = @local_template_dir
|
26
|
+
end
|
27
|
+
path = target_dir.add(source)
|
18
28
|
system("#{ENV['EDITOR']}", path)
|
19
29
|
end
|
20
30
|
|
@@ -27,14 +37,19 @@ module TouchErb
|
|
27
37
|
FileUtils.touch(dist_name)
|
28
38
|
else
|
29
39
|
File.open(dist_name, 'w') do |f|
|
30
|
-
f.write(ERB.new(@template_dir.find(template_name) || "", nil, "%<>").result())
|
40
|
+
f.write(ERB.new(@local_template_dir.find(template_name) || @template_dir.find("template_name") || "", nil, "%<>").result())
|
31
41
|
end
|
32
42
|
end
|
33
43
|
end
|
34
44
|
|
35
45
|
desc "list", "Show erb templates"
|
46
|
+
option "local", aliases: "l", type: :boolean, desc: "Show templates only local directory .touch_erb"
|
36
47
|
def list()
|
37
|
-
|
48
|
+
if(options[:local])
|
49
|
+
@local_template_dir.list().each{ |name| puts name }
|
50
|
+
else
|
51
|
+
(@template_dir.list() + @local_template_dir.list()).each{ |name| puts name }
|
52
|
+
end
|
38
53
|
end
|
39
54
|
|
40
55
|
default_task :touch
|
@@ -2,14 +2,21 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module TouchErb
|
4
4
|
class TemplateDir
|
5
|
-
def initialize(
|
6
|
-
|
5
|
+
def initialize(
|
6
|
+
root_dir = ENV['TOUCH_ERB_ROOT'] || File.join(Dir.home, '.touch_erb'),
|
7
|
+
create_dir = true
|
8
|
+
)
|
9
|
+
FileUtils.mkdir_p(root_dir) if create_dir && !Dir.exist?(root_dir)
|
7
10
|
@root = root_dir
|
8
11
|
end
|
9
12
|
|
10
13
|
def find(template_name)
|
11
14
|
absolute_path = "#{File.join(@root, template_name)}.erb"
|
12
|
-
|
15
|
+
if File.exist?(absolute_path)
|
16
|
+
File.read(absolute_path)
|
17
|
+
else
|
18
|
+
nil
|
19
|
+
end
|
13
20
|
end
|
14
21
|
|
15
22
|
def add(template_name)
|
data/lib/touch_erb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: touch_erb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- himanoa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -104,6 +104,7 @@ extra_rdoc_files: []
|
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
106
|
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
107
108
|
- Gemfile
|
108
109
|
- Gemfile.lock
|
109
110
|
- LICENSE.txt
|
@@ -141,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
- !ruby/object:Gem::Version
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.7.6
|
145
|
+
rubygems_version: 3.0.1
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Better touch command
|