dupler 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/main.yml +16 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +122 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/dupler.gemspec +43 -0
- data/exe/dupler +13 -0
- data/lib/dupler.rb +14 -0
- data/lib/dupler/cli.rb +52 -0
- data/lib/dupler/core.rb +56 -0
- data/lib/dupler/version.rb +5 -0
- data/project_template/Gemfile +3 -0
- data/project_template/README.md +18 -0
- data/project_template/templates/sample.md.erb +12 -0
- data/project_template/values.yaml +12 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bbdffb17321666919551924b96c790fb5e0c180eedcbb825a48658842dfdf055
|
4
|
+
data.tar.gz: bea5611c45ea867a8450649f8b274788402d0f7bef00b158a32d44a3105d55b6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e839db91cc365340aecc60193e0113195bc6cff7d2a1b3b2ff09c2a4c850bfc9825792601502e8825fd6e0325a7e1f8a1eca3031a82548467e5038648311c0d
|
7
|
+
data.tar.gz: 4fb5e091cdee6423e51b601857911e261fbd56aac8065e342a1c55bc4e5cd9bb15a3b56480ceb885d3479c4e8f5ab2a3cfa41fd5a595c6ae301ac8abe391a1dc
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push,pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v2
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.7.3
|
14
|
+
bundler-cache: true
|
15
|
+
- name: Run the default task
|
16
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at daixque@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 daixque
|
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,122 @@
|
|
1
|
+
# Dupler
|
2
|
+
|
3
|
+
Easy-to-use template engine driver.
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
Dupler provides you a simple command line interface to document generation environment using template engine especially in ERB format.
|
8
|
+
|
9
|
+
Typical use cases are:
|
10
|
+
|
11
|
+
- generate configuration files for some different environments
|
12
|
+
- generate test data
|
13
|
+
|
14
|
+
Technically dupler is just a cli wrapper of `Tilt` template engine.
|
15
|
+
And Dupler supports ActiveSupport by default in template.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Install it by using just below command:
|
20
|
+
|
21
|
+
$ gem install dupler
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
You can generate your project bootstrap with `dupler new` command.
|
26
|
+
|
27
|
+
$ dupler new myproject
|
28
|
+
|
29
|
+
Then you will find new `myproject` project is generated on your current directory.
|
30
|
+
|
31
|
+
Inside the directory, below files are there.
|
32
|
+
|
33
|
+
- values.yaml : You can define any values for placeholder in the templates
|
34
|
+
- templates : In this directory, all files will be processed by dupler as template file.
|
35
|
+
|
36
|
+
You can just execute `dupler` command on top of your project folder, then output file will be generated in `output` directory.
|
37
|
+
|
38
|
+
$ dupler
|
39
|
+
|
40
|
+
Or you can specify like below
|
41
|
+
|
42
|
+
$ dupler -c values.yaml output templates/*
|
43
|
+
|
44
|
+
## Examples
|
45
|
+
|
46
|
+
How to write template and values.yaml? Here is the example of Dupler config file (values.yaml) and template in ERB format.
|
47
|
+
|
48
|
+
### values.yaml
|
49
|
+
|
50
|
+
First you should define your valiables in values.yaml file. (Filename is configurable in `dupler` command in `-c` option.)
|
51
|
+
|
52
|
+
```
|
53
|
+
sample:
|
54
|
+
name: Dupler
|
55
|
+
records: 5
|
56
|
+
```
|
57
|
+
|
58
|
+
### templates/sample.md.erb
|
59
|
+
|
60
|
+
Then you can write template with above values. In dupler, values.yaml is load as Hashie::Mash, it means you can access all of the elements with dot notation like `sample.name`.
|
61
|
+
|
62
|
+
```
|
63
|
+
# Dupler Example
|
64
|
+
|
65
|
+
This file is generated by <%= sample.name %> <%= Dupler::VERSION %>.
|
66
|
+
Generated at: <%= Time.now %>
|
67
|
+
|
68
|
+
## List sample
|
69
|
+
|
70
|
+
Iteration example with ActiveSupport time expression.
|
71
|
+
|
72
|
+
<% sample.records.times do |i| %>
|
73
|
+
- <%= i %>, <%= i.days.after.iso8601 %>
|
74
|
+
<% end %>
|
75
|
+
```
|
76
|
+
|
77
|
+
### Outcome file
|
78
|
+
|
79
|
+
You can build document using below command:
|
80
|
+
|
81
|
+
$ dupler
|
82
|
+
|
83
|
+
Or you can specify like below:
|
84
|
+
|
85
|
+
$ dupler -c values.yaml output templates/sample.md.erb
|
86
|
+
|
87
|
+
Output document will be like this:
|
88
|
+
|
89
|
+
```
|
90
|
+
# Dupler Example
|
91
|
+
|
92
|
+
This file is generated by Dupler 0.1.0.
|
93
|
+
Generated at: 2021-06-19 23:14:28 +0900
|
94
|
+
|
95
|
+
## List sample
|
96
|
+
|
97
|
+
Iteration example with ActiveSupport time expression.
|
98
|
+
|
99
|
+
- 0, 2021-06-19T23:14:28+09:00
|
100
|
+
- 1, 2021-06-20T23:14:28+09:00
|
101
|
+
- 2, 2021-06-21T23:14:28+09:00
|
102
|
+
- 3, 2021-06-22T23:14:28+09:00
|
103
|
+
- 4, 2021-06-23T23:14:28+09:00
|
104
|
+
```
|
105
|
+
|
106
|
+
## Development
|
107
|
+
|
108
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
109
|
+
|
110
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
111
|
+
|
112
|
+
## Contributing
|
113
|
+
|
114
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/daixque/dupler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/daixque/dupler/blob/master/CODE_OF_CONDUCT.md).
|
115
|
+
|
116
|
+
## License
|
117
|
+
|
118
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
119
|
+
|
120
|
+
## Code of Conduct
|
121
|
+
|
122
|
+
Everyone interacting in the Dupler project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/daixque/dupler/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "dupler"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/dupler.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/dupler/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "dupler"
|
7
|
+
spec.version = Dupler::VERSION
|
8
|
+
spec.authors = ["daixque"]
|
9
|
+
spec.email = ["daixque@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Easy-to-use template engine driver"
|
12
|
+
spec.description = "Dupler provides you a simple command line interface to document generation environment using template engine especially in ERB format."
|
13
|
+
spec.homepage = "https://github.com/daixque/dupler"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.4.0"
|
16
|
+
|
17
|
+
#spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
#spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
21
|
+
#spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
#spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.executables = Dir.glob('./exe/*').map { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
# Uncomment to register a new dependency of your gem
|
34
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
35
|
+
spec.add_dependency "thor"
|
36
|
+
spec.add_dependency "tilt"
|
37
|
+
spec.add_dependency "yaml"
|
38
|
+
spec.add_dependency "hashie"
|
39
|
+
spec.add_dependency "activesupport"
|
40
|
+
|
41
|
+
# For more information and examples about making a new gem, checkout our
|
42
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
43
|
+
end
|
data/exe/dupler
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
lib = File.expand_path('../../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'dupler'
|
7
|
+
|
8
|
+
begin
|
9
|
+
Dupler::Cli.start
|
10
|
+
rescue Dupler::DuplerException => ex
|
11
|
+
$stderr.puts ex.message
|
12
|
+
exit 1
|
13
|
+
end
|
data/lib/dupler.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "bundler"
|
3
|
+
Bundler.require
|
4
|
+
|
5
|
+
require "dupler/version"
|
6
|
+
require "dupler/cli"
|
7
|
+
|
8
|
+
module Dupler
|
9
|
+
class DuplerException < StandardError; end
|
10
|
+
|
11
|
+
def self.home
|
12
|
+
@dupler_home = File.join File.dirname(__FILE__), "../"
|
13
|
+
end
|
14
|
+
end
|
data/lib/dupler/cli.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'json'
|
5
|
+
require "dupler/core"
|
6
|
+
|
7
|
+
module Dupler
|
8
|
+
class Cli < Thor
|
9
|
+
@@defalut_conf_name = "./values.yaml"
|
10
|
+
|
11
|
+
default_command :build
|
12
|
+
|
13
|
+
desc :new, "create new dupler project."
|
14
|
+
def new_project(name)
|
15
|
+
core = Dupler::Core.new
|
16
|
+
core.new_project(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
desc :build, "build documents."
|
20
|
+
option "conf", aliases: "c", type: :string
|
21
|
+
def build(output_dir = "./output", *template_files)
|
22
|
+
if template_files.empty?
|
23
|
+
templates_dir = './templates'
|
24
|
+
if !Dir.exists?(templates_dir)
|
25
|
+
raise DuplerException.new("No such template directory: #{templates_dir}")
|
26
|
+
end
|
27
|
+
|
28
|
+
Dir.glob(File.join(templates_dir, '*')) do |f|
|
29
|
+
template_files << f
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
extract_template_files = []
|
34
|
+
template_files.each do |f|
|
35
|
+
if File.directory?(f)
|
36
|
+
files = Dir.glob(File.join(f, '*'))
|
37
|
+
extract_template_files.concat files
|
38
|
+
else
|
39
|
+
extract_template_files << f
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
values_file_path = options['conf'] || @@defalut_conf_name
|
44
|
+
if !File.exists? values_file_path
|
45
|
+
raise DuplerException.new("No such conf file: #{values_file_path}")
|
46
|
+
end
|
47
|
+
|
48
|
+
core = Dupler::Core.new
|
49
|
+
core.build(values_file_path, output_dir, extract_template_files)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/dupler/core.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'yaml'
|
3
|
+
require 'hashie'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'active_support/all'
|
6
|
+
|
7
|
+
module Dupler
|
8
|
+
class Core
|
9
|
+
def new_project(project_name)
|
10
|
+
FileUtils.mkdir_p project_name
|
11
|
+
project_template_dir = Dir.glob File.join(Dupler::home, "project_template/*")
|
12
|
+
FileUtils.cp_r(project_template_dir, project_name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def setup(config)
|
16
|
+
formats = config.dig("Dupler", "time", "format")
|
17
|
+
if formats
|
18
|
+
formats.each do |key, value|
|
19
|
+
Time::DATE_FORMATS[key.to_sym] = value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def build(values_file_path, output_dir, template_files)
|
25
|
+
yaml = YAML.load File.read(values_file_path)
|
26
|
+
|
27
|
+
setup(yaml)
|
28
|
+
yaml.delete("Dupler")
|
29
|
+
config = Hashie::Mash.new yaml
|
30
|
+
FileUtils.mkdir_p output_dir
|
31
|
+
|
32
|
+
template_files.each do |path|
|
33
|
+
output_filename = File.basename(path, File.extname(path))
|
34
|
+
output_filepath = File.join(output_dir, output_filename)
|
35
|
+
render(path, config, output_filepath)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def render(template_path, config, output_filepath)
|
40
|
+
content = apply_template(template_path, config)
|
41
|
+
output_file(output_filepath, content)
|
42
|
+
puts "render: #{output_filepath}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def apply_template(template_path, config)
|
46
|
+
template = Tilt.new(template_path)
|
47
|
+
output = template.render(self, config)
|
48
|
+
end
|
49
|
+
|
50
|
+
def output_file(filepath, content)
|
51
|
+
File.open(filepath, "w") do |file|
|
52
|
+
file.write content
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Dupler
|
2
|
+
|
3
|
+
This project is created by Dupler.
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
By default, below files are there in this project directory.
|
8
|
+
|
9
|
+
- values.yaml : You can define any values for placeholder in the templates
|
10
|
+
- templates : In this directory, all files will be processed by dupler as template file.
|
11
|
+
|
12
|
+
You can just execute `dupler` command on top of your project folder, then output file will be generated in `output` directory.
|
13
|
+
|
14
|
+
$ dupler
|
15
|
+
|
16
|
+
Or you can specify like below
|
17
|
+
|
18
|
+
$ dupler -c values.yaml output templates/*
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Dupler Example
|
2
|
+
|
3
|
+
This file is generated by <%= sample.name %> <%= Dupler::VERSION %>.
|
4
|
+
Generated at: <%= Time.now %>
|
5
|
+
|
6
|
+
## List sample
|
7
|
+
|
8
|
+
Iteration example with ActiveSupport time expression.
|
9
|
+
|
10
|
+
<% sample.records.times do |i| %>
|
11
|
+
- <%= i %>, <%= i.days.after.iso8601 %>
|
12
|
+
<% end %>
|
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dupler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- daixque
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-19 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
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tilt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: yaml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Dupler provides you a simple command line interface to document generation
|
84
|
+
environment using template engine especially in ERB format.
|
85
|
+
email:
|
86
|
+
- daixque@gmail.com
|
87
|
+
executables:
|
88
|
+
- dupler
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".github/workflows/main.yml"
|
93
|
+
- ".gitignore"
|
94
|
+
- ".rubocop.yml"
|
95
|
+
- CHANGELOG.md
|
96
|
+
- CODE_OF_CONDUCT.md
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/setup
|
103
|
+
- dupler.gemspec
|
104
|
+
- exe/dupler
|
105
|
+
- lib/dupler.rb
|
106
|
+
- lib/dupler/cli.rb
|
107
|
+
- lib/dupler/core.rb
|
108
|
+
- lib/dupler/version.rb
|
109
|
+
- project_template/Gemfile
|
110
|
+
- project_template/README.md
|
111
|
+
- project_template/templates/sample.md.erb
|
112
|
+
- project_template/values.yaml
|
113
|
+
homepage: https://github.com/daixque/dupler
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata:
|
117
|
+
homepage_uri: https://github.com/daixque/dupler
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 2.4.0
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubygems_version: 3.1.6
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Easy-to-use template engine driver
|
137
|
+
test_files: []
|