geny 2.1.4 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/build.yml +22 -0
- data/.github/workflows/publish.yml +38 -0
- data/Gemfile +0 -1
- data/README.md +8 -1
- data/Rakefile +2 -2
- data/geny.gemspec +7 -6
- data/lib/geny/actions/files.rb +57 -10
- data/lib/geny/actions/find.rb +1 -1
- data/lib/geny/actions/templates.rb +3 -3
- data/lib/geny/context/invoke.rb +1 -1
- data/lib/geny/context/view.rb +17 -0
- data/lib/geny/version.rb +1 -1
- metadata +31 -17
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1bc848e8409e0bade3ed8a6ecdd931f0355c4fd12617a28fa9b82653e7f21064
|
4
|
+
data.tar.gz: 4002b6123125e73bdbee5d118e5732283b6df39ab958c399d74756311aa8e2e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f18b863910ab8b163cfb4ff09546ada715402d2785d4e7b87abed141232e78fca79720a3eb3ceb0df95c0a32daed0ba61e8cddbbf51bd8ebfd0af36a2aedaf
|
7
|
+
data.tar.gz: cdc37bad979303e1d715eab3b9df86cd0ed62982fd815d18663b13a4bb0177ecb9cd39172c7afbe96d14a71574fcb68af8d9226676d91eb4fcbd5094f4997d09
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: Build
|
2
|
+
on: [push]
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
steps:
|
7
|
+
- name: Checkout
|
8
|
+
uses: actions/checkout@v2
|
9
|
+
|
10
|
+
- name: Setup Ruby
|
11
|
+
uses: actions/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.7.x
|
14
|
+
|
15
|
+
- name: Install bundler
|
16
|
+
run: gem install bundler
|
17
|
+
|
18
|
+
- name: Install dependencies
|
19
|
+
run: bundle install
|
20
|
+
|
21
|
+
- name: Test
|
22
|
+
run: bundle exec rspec
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: Publish
|
2
|
+
on:
|
3
|
+
release:
|
4
|
+
types: [published]
|
5
|
+
jobs:
|
6
|
+
publish:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- name: Checkout
|
10
|
+
uses: actions/checkout@v2
|
11
|
+
|
12
|
+
- name: Setup Ruby
|
13
|
+
uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.7.x
|
16
|
+
|
17
|
+
- name: Install bundler
|
18
|
+
run: gem install bundler
|
19
|
+
|
20
|
+
- name: Install dependencies
|
21
|
+
run: bundle install
|
22
|
+
|
23
|
+
- name: Test
|
24
|
+
run: bundle exec rspec
|
25
|
+
|
26
|
+
- name: Set version
|
27
|
+
run: perl -pi -e "s/0\.0\.0/${GITHUB_REF:11}/" lib/geny/version.rb
|
28
|
+
|
29
|
+
- name: Publish
|
30
|
+
run: |
|
31
|
+
mkdir -p $HOME/.gem
|
32
|
+
touch $HOME/.gem/credentials
|
33
|
+
chmod 0600 $HOME/.gem/credentials
|
34
|
+
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_TOKEN}\n" > $HOME/.gem/credentials
|
35
|
+
gem build *.gemspec
|
36
|
+
gem push *.gem
|
37
|
+
env:
|
38
|
+
RUBYGEMS_TOKEN: ${{ secrets.RUBYGEMS_TOKEN }}
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
|
1
|
+
<h1 align="center">Geny</h1>
|
2
|
+
|
3
|
+
<div align="center">
|
4
|
+
|
5
|
+
![Build](https://github.com/rzane/geny/workflows/Build/badge.svg)
|
6
|
+
![Version](https://img.shields.io/gem/v/geny)
|
7
|
+
|
8
|
+
</div>
|
2
9
|
|
3
10
|
A tool for building code generators.
|
4
11
|
|
data/Rakefile
CHANGED
data/geny.gemspec
CHANGED
@@ -24,13 +24,14 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_dependency "argy", "~> 0.2
|
28
|
-
spec.add_dependency "pastel", "~> 0.7
|
29
|
-
spec.add_dependency "tty-file", "~> 0.
|
30
|
-
spec.add_dependency "tty-prompt", "~> 0.
|
27
|
+
spec.add_dependency "argy", "~> 0.2"
|
28
|
+
spec.add_dependency "pastel", "~> 0.7"
|
29
|
+
spec.add_dependency "tty-file", "~> 0.9"
|
30
|
+
spec.add_dependency "tty-prompt", "~> 0.21"
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 2.0"
|
33
|
-
spec.add_development_dependency "rake", "~>
|
33
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
-
spec.add_development_dependency "simplecov", "~> 0.
|
35
|
+
spec.add_development_dependency "simplecov", "~> 0.18"
|
36
|
+
spec.add_development_dependency "file_spec", "~> 0.1.0"
|
36
37
|
end
|
data/lib/geny/actions/files.rb
CHANGED
@@ -8,6 +8,10 @@ module Geny
|
|
8
8
|
class Files
|
9
9
|
extend Forwardable
|
10
10
|
|
11
|
+
def initialize(ui:)
|
12
|
+
@ui = ui
|
13
|
+
end
|
14
|
+
|
11
15
|
# @!method create
|
12
16
|
# Create a file
|
13
17
|
# @see TTY::File.create
|
@@ -15,9 +19,18 @@ module Geny
|
|
15
19
|
# @example
|
16
20
|
# files.create("test.txt")
|
17
21
|
# files.create("test.txt", "hello!")
|
18
|
-
# files.
|
22
|
+
# files.create("test.txt", force: true)
|
19
23
|
def_delegator TTY::File, :create_file, :create
|
20
24
|
|
25
|
+
# @!method copy
|
26
|
+
# Copy a file
|
27
|
+
# @see TTY::File.copy
|
28
|
+
#
|
29
|
+
# @example
|
30
|
+
# files.copy("foo.txt", "bar.txt")
|
31
|
+
# files.copy("foo.txt", "bar.txt", force: true)
|
32
|
+
def_delegator TTY::File, :copy_file, :copy
|
33
|
+
|
21
34
|
# @!method create_dir
|
22
35
|
# Create a directory recursively
|
23
36
|
# @see TTY::File.create_dir
|
@@ -26,6 +39,15 @@ module Geny
|
|
26
39
|
# files.create_dir("app/controllers")
|
27
40
|
def_delegator TTY::File, :create_dir
|
28
41
|
|
42
|
+
# @!method copy_dir
|
43
|
+
# Copy a directory recursively
|
44
|
+
# @see TTY::File.copy_dir
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# files.copy_dir("foo", "bar")
|
48
|
+
# files.copy_dir("foo", "bar", force: true)
|
49
|
+
def_delegator TTY::File, :copy_dir
|
50
|
+
|
29
51
|
# @!method remove
|
30
52
|
# Remove a file
|
31
53
|
# @see TTY::File.remove_file
|
@@ -68,23 +90,48 @@ module Geny
|
|
68
90
|
# files.insert("Gemfile", "gem 'geny'", after: /gem 'rails'\n/)
|
69
91
|
def_delegator TTY::File, :safe_inject_into_file, :insert
|
70
92
|
|
93
|
+
# Move a file
|
94
|
+
# @param source [String]
|
95
|
+
# @param dest [String]
|
96
|
+
#
|
97
|
+
# @example
|
98
|
+
# files.move "Gemfile", "Gemfile.bak"
|
99
|
+
def move(source, dest, force: false, verbose: true)
|
100
|
+
@ui.status("move", source) if verbose
|
101
|
+
FileUtils.mv(source, dest, force: force)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Change directory
|
105
|
+
# @param path [String]
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# files.chdir "foo" do
|
109
|
+
# # do something inside foo/
|
110
|
+
# end
|
111
|
+
def chdir(path, verbose: true, &block)
|
112
|
+
@ui.status("cd", path) if verbose
|
113
|
+
Dir.chdir(path, &block)
|
114
|
+
ensure
|
115
|
+
@ui.status("cd", "-") if verbose
|
116
|
+
end
|
117
|
+
|
71
118
|
# Change the permissions of a file
|
72
119
|
# @see TTY::File.chmod
|
73
120
|
#
|
74
121
|
# @example
|
75
122
|
# files.chmod("bin/test", "+x")
|
76
|
-
def chmod(path, mode, *args)
|
77
|
-
TTY::File.chmod(path,
|
123
|
+
def chmod(path, mode, *args, **opts)
|
124
|
+
TTY::File.chmod(path, mode, *args, **opts)
|
78
125
|
end
|
79
126
|
|
80
|
-
|
127
|
+
# @see #insert
|
128
|
+
def insert_before(path, pattern, content, **opts)
|
129
|
+
insert(path, content, before: pattern, **opts)
|
130
|
+
end
|
81
131
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
else
|
86
|
-
mode
|
87
|
-
end
|
132
|
+
# @see #insert
|
133
|
+
def insert_after(path, pattern, content, **opts)
|
134
|
+
insert(path, content, after: pattern, **opts)
|
88
135
|
end
|
89
136
|
end
|
90
137
|
end
|
data/lib/geny/actions/find.rb
CHANGED
@@ -68,7 +68,7 @@ module Geny
|
|
68
68
|
FileUtils.mv(path, dest, force: force)
|
69
69
|
|
70
70
|
# Find and rename the children of the path
|
71
|
-
rename(dest, pattern, replacement, options) if File.directory?(dest)
|
71
|
+
rename(dest, pattern, replacement, **options) if File.directory?(dest)
|
72
72
|
|
73
73
|
# We already searched the directory's children, so we should stop
|
74
74
|
::Find.prune
|
@@ -23,7 +23,7 @@ module Geny
|
|
23
23
|
# templates.copy("hello.erb", "hello.txt", locals: {name: "world"})
|
24
24
|
def copy(source, *args, **opts)
|
25
25
|
source = expand_path(source)
|
26
|
-
context, opts = build_context(opts)
|
26
|
+
context, opts = build_context(**opts)
|
27
27
|
TTY::File.copy_file(source, *args, context: context, **opts)
|
28
28
|
end
|
29
29
|
|
@@ -36,7 +36,7 @@ module Geny
|
|
36
36
|
# templates.copy_dir("boilerplate", output, locals: {name: "world"})
|
37
37
|
def copy_dir(source, *args, **opts)
|
38
38
|
source = expand_path(source)
|
39
|
-
context, opts = build_context(opts)
|
39
|
+
context, opts = build_context(**opts)
|
40
40
|
TTY::File.copy_dir(source, *args, context: context, **opts)
|
41
41
|
end
|
42
42
|
|
@@ -49,7 +49,7 @@ module Geny
|
|
49
49
|
def render(path, **opts)
|
50
50
|
path = expand_path(path)
|
51
51
|
input = File.binread(path)
|
52
|
-
context, _opts = build_context(opts)
|
52
|
+
context, _opts = build_context(**opts)
|
53
53
|
erb = ERB.new(input, nil, "-", "@output_buffer")
|
54
54
|
erb.result(context.instance_eval("binding"))
|
55
55
|
end
|
data/lib/geny/context/invoke.rb
CHANGED
data/lib/geny/context/view.rb
CHANGED
@@ -10,6 +10,23 @@ module Geny
|
|
10
10
|
def merge(updates)
|
11
11
|
View.new(command: command, locals: locals.merge(updates))
|
12
12
|
end
|
13
|
+
|
14
|
+
# Append to the output buffer
|
15
|
+
def concat(data)
|
16
|
+
@output_buffer << data
|
17
|
+
end
|
18
|
+
|
19
|
+
# Capture the ERB rendered inside a block
|
20
|
+
def capture(*args, &block)
|
21
|
+
@output_buffer, buffer_was = "", @output_buffer
|
22
|
+
|
23
|
+
begin
|
24
|
+
block.call(*args)
|
25
|
+
block.binding.eval("@output_buffer")
|
26
|
+
ensure
|
27
|
+
@output_buffer = buffer_was
|
28
|
+
end
|
29
|
+
end
|
13
30
|
end
|
14
31
|
end
|
15
32
|
end
|
data/lib/geny/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: argy
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2
|
19
|
+
version: '0.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2
|
26
|
+
version: '0.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pastel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.7
|
33
|
+
version: '0.7'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.7
|
40
|
+
version: '0.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: tty-file
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: '0.9'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: '0.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: tty-prompt
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: '0.21'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: '0.21'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '13.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '13.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,28 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: '0.18'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: '0.18'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: file_spec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.1.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.1.0
|
125
139
|
description:
|
126
140
|
email:
|
127
141
|
- raymondzane@gmail.com
|
@@ -130,9 +144,10 @@ executables:
|
|
130
144
|
extensions: []
|
131
145
|
extra_rdoc_files: []
|
132
146
|
files:
|
147
|
+
- ".github/workflows/build.yml"
|
148
|
+
- ".github/workflows/publish.yml"
|
133
149
|
- ".gitignore"
|
134
150
|
- ".rspec"
|
135
|
-
- ".travis.yml"
|
136
151
|
- ".yardopts"
|
137
152
|
- CODE_OF_CONDUCT.md
|
138
153
|
- Gemfile
|
@@ -184,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
199
|
- !ruby/object:Gem::Version
|
185
200
|
version: '0'
|
186
201
|
requirements: []
|
187
|
-
|
188
|
-
rubygems_version: 2.6.14
|
202
|
+
rubygems_version: 3.1.2
|
189
203
|
signing_key:
|
190
204
|
specification_version: 4
|
191
205
|
summary: The only tool you need to build a code generator.
|