touch_erb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 01c37217d974c228d77981b065157b8e2aa2d69da5e43d593de279f60c256d55
4
+ data.tar.gz: 35f8858999dcd84588e88e11710b7bf203cb52110013643487d5bb4bc2e88812
5
+ SHA512:
6
+ metadata.gz: b101964ecbed44cefca5be56c79d4e7e35c8f59f65fad2e273c83ed670a539a0b96f81d5d6ca05248e5956ffd4c13ac5fa51b97895b23bf07e300a76c82c6afd
7
+ data.tar.gz: 704394fa232123b5d24b2ab22da41afe28df2bc3f6c0f044e16928c87cbbb080734d109d678af92166e3a2b210e6e21deeb2644d65887c52552d7ae59576331e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.1
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in touch_erb.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ touch_erb (0.1.0)
5
+ thor
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ansi (1.5.0)
11
+ builder (3.2.3)
12
+ minitest (5.11.3)
13
+ minitest-reporters (1.3.6)
14
+ ansi
15
+ builder
16
+ minitest (>= 5.0)
17
+ ruby-progressbar
18
+ rake (12.3.2)
19
+ ruby-progressbar (1.10.0)
20
+ thor (0.20.3)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler (~> 2.0)
27
+ minitest (~> 5.0)
28
+ minitest-reporters
29
+ rake (~> 12.3)
30
+ touch_erb!
31
+
32
+ BUNDLED WITH
33
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 himanoa
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,39 @@
1
+ # TouchErb
2
+
3
+ Create from a template file command.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ gem install touch_erb
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ $ ls ~/.touch_erb
15
+ today.erb
16
+
17
+ $ cat ~/.touch_erb/today.erb
18
+ <% require 'time' %>
19
+ <%= Time.new.to_s %>
20
+
21
+ $ touch_erb today
22
+ $ cat today
23
+ 2019-02-15 05:13:56 +0900
24
+
25
+ ```
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/touch_erb.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "touch_erb"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/touch_erb ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'touch_erb'
4
+
5
+ TouchErb::CLI.start
data/exe/touch_erb ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "touch_erb/cli"
4
+
5
+ ARGV.unshift(TouchErb::CLI.default_task) unless TouchErb::CLI.all_tasks.has_key?(ARGV[0])
6
+ TouchErb::CLI.start(ARGV)
@@ -0,0 +1,38 @@
1
+ require 'touch_erb'
2
+ require 'thor'
3
+ require 'erb'
4
+ require 'fileutils'
5
+
6
+ module TouchErb
7
+ class CLI < Thor
8
+
9
+ def initialize(*args)
10
+ super
11
+ @template_dir = TouchErb::TemplateDir.new
12
+ end
13
+
14
+ desc "add <source>", "Create new erb file"
15
+ option :source, :type => :string
16
+ def add(source)
17
+ path = @template_dir.add(source)
18
+ system("#{ENV['EDITOR']}", path)
19
+ end
20
+
21
+ desc "<template_name> <output_name>", "Create file to current directory from execute erb template"
22
+ option :template_name, :type => :string
23
+ option :output_name, :type => :string, :default => nil
24
+ def touch(template_name, output_name = nil)
25
+ dist_name = output_name || template_name
26
+ if FileTest.exists?(dist_name)
27
+ FileUtils.touch(dist_name)
28
+ else
29
+ File.open(dist_name, 'w') do |f|
30
+ f.write(ERB.new(@template_dir.find(template_name) || "", nil, "%<>").result())
31
+ end
32
+ end
33
+ end
34
+
35
+ default_task :touch
36
+ end
37
+ end
38
+
@@ -0,0 +1,21 @@
1
+ require 'fileutils'
2
+
3
+ module TouchErb
4
+ class TemplateDir
5
+ def initialize(root_dir = ENV['TOUCH_ERB_ROOT'] || File.join(Dir.home, '.touch_erb'))
6
+ FileUtils.mkdir_p(root_dir) unless Dir.exist?(root_dir)
7
+ @root = root_dir
8
+ end
9
+
10
+ def find(template_name)
11
+ absolute_path = "#{File.join(@root, template_name)}.erb"
12
+ File.read(absolute_path) if File.exist?(absolute_path)
13
+ end
14
+
15
+ def add(template_name)
16
+ absolute_path = File.join(@root, "#{template_name}.erb")
17
+ FileUtils.touch(absolute_path)
18
+ absolute_path
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module TouchErb
2
+ VERSION = "0.1.0"
3
+ end
data/lib/touch_erb.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "fileutils"
2
+
3
+ require "touch_erb/version"
4
+ require "touch_erb/template_dir"
5
+
6
+ module TouchErb
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
data/touch_erb.gemspec ADDED
@@ -0,0 +1,45 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "touch_erb/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "touch_erb"
8
+ spec.version = TouchErb::VERSION
9
+ spec.authors = ["himanoa"]
10
+ spec.email = ["matsunoappy@gmail.com"]
11
+
12
+ spec.summary = %q{Better touch command}
13
+ spec.description = %q{Create from a template file command.}
14
+ spec.homepage = "https://github.com/himanoa/touch_erb"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/himanoa/touch_erb"
24
+ spec.metadata["changelog_uri"] = "https://github.com/himanoa/touch_erb"
25
+ else
26
+ raise "RubyGems 2.0 or newer is required to protect against " \
27
+ "public gem pushes."
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_dependency "thor", "~> 0.20"
40
+
41
+ spec.add_development_dependency "bundler", "~> 2.0"
42
+ spec.add_development_dependency "rake", "~> 12.3"
43
+ spec.add_development_dependency "minitest", "~> 5.0"
44
+ spec.add_development_dependency "minitest-reporters", "~> 1.3"
45
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: touch_erb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - himanoa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.20'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.20'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ description: Create from a template file command.
84
+ email:
85
+ - matsunoappy@gmail.com
86
+ executables:
87
+ - touch_erb
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - bin/touch_erb
101
+ - exe/touch_erb
102
+ - lib/touch_erb.rb
103
+ - lib/touch_erb/cli.rb
104
+ - lib/touch_erb/template_dir.rb
105
+ - lib/touch_erb/version.rb
106
+ - touch_erb.gemspec
107
+ homepage: https://github.com/himanoa/touch_erb
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ allowed_push_host: https://rubygems.org
112
+ homepage_uri: https://github.com/himanoa/touch_erb
113
+ source_code_uri: https://github.com/himanoa/touch_erb
114
+ changelog_uri: https://github.com/himanoa/touch_erb
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.0.1
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Better touch command
134
+ test_files: []