oneshot_task_generator 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +36 -0
- data/README.md +30 -2
- data/lib/generators/oneshot/oneshot_generator.rb +3 -2
- data/lib/generators/oneshot/oneshot_generator/configuration.rb +9 -3
- data/lib/generators/oneshot/templates/oneshot.rake.erb +2 -4
- data/lib/oneshot_task_generator.rb +2 -0
- data/lib/oneshot_task_generator/version.rb +1 -1
- data/oneshot_task_generator.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a314fba0676ad53998616ecd7f1c6d6a867b52336e78139a6e4500f57e52cfc
|
4
|
+
data.tar.gz: f9167edfcb98a7ce8d32c37521ab4372bbc7a25971e826c7ca63040df0ac1079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b87c57adbaebe2d9216829a9fb40b1634c294441df6e5b8e3bf39a03ac881bd45559113bf15f751e16d00166dffd3a159ef4b3404536e9648fdb50b58ac49aa8
|
7
|
+
data.tar.gz: b78e5b2589534e4896154ff8956cbd59ffb76e0f7cc684253a9af2963120be9bc0e29c9ca643b2a454898df04ef4946e4447c0966f430a2f5523e892929620f7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [0.2.0] - 2020-05-31
|
8
|
+
### Changed
|
9
|
+
- Task name format follows file name style ('YYYYMMDD_foo_bar') [#13](https://github.com/s-osa/oneshot_task_generator/pull/13)
|
10
|
+
|
11
|
+
## [0.1.5] - 2020-04-25
|
12
|
+
### Added
|
13
|
+
- Enable to specify the directory to place task files [#11](https://github.com/s-osa/oneshot_task_generator/pull/11)
|
14
|
+
|
15
|
+
## [0.1.4] - 2020-03-11
|
16
|
+
### Fixed
|
17
|
+
- Remove trailing spaces on blank line [#9](https://github.com/s-osa/oneshot_task_generator/pull/9)
|
18
|
+
|
19
|
+
## [0.1.3] - 2019-08-20
|
20
|
+
### Added
|
21
|
+
- Enable to configure task arguments [#5](https://github.com/s-osa/oneshot_task_generator/pull/5)
|
22
|
+
|
23
|
+
## [0.1.2] - 2019-05-13
|
24
|
+
### Fixed
|
25
|
+
- Require generator [#4](https://github.com/s-osa/oneshot_task_generator/pull/4)
|
26
|
+
|
27
|
+
## [0.1.1] - 2018-08-14
|
28
|
+
### Added
|
29
|
+
- frozen_string_literal magic comment [#2](https://github.com/s-osa/oneshot_task_generator/pull/2)
|
30
|
+
|
31
|
+
## [0.1.0] - 2018-02-08
|
32
|
+
### Added
|
33
|
+
- Enable to configure task body
|
34
|
+
|
35
|
+
## [0.0.1] - 2018-02-06
|
36
|
+
First release
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ end
|
|
27
27
|
Add this line to your application's Gemfile:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
gem 'oneshot_task_generator'
|
30
|
+
gem 'oneshot_task_generator', group: :development
|
31
31
|
```
|
32
32
|
|
33
33
|
And then execute:
|
@@ -41,7 +41,7 @@ $ bundle
|
|
41
41
|
### Task Body
|
42
42
|
|
43
43
|
```ruby
|
44
|
-
# config/initializers/
|
44
|
+
# config/initializers/oneshot_task_generator.rb
|
45
45
|
OneshotGenerator.configure do |config|
|
46
46
|
config.body = <<-BODY
|
47
47
|
ActiveRecord::Base.transaction do
|
@@ -64,6 +64,34 @@ namespace :oneshot do
|
|
64
64
|
end
|
65
65
|
```
|
66
66
|
|
67
|
+
### Arguments
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
# config/initializers/oneshot_task_generator.rb
|
71
|
+
OneshotGenerator.configure do |config|
|
72
|
+
config.arguments = ['task', 'args']
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
# Skeleton for this file was generated by `bin/rails generate oneshot FooBar`
|
78
|
+
# For copy and paste: `bin/rake oneshot:foo_bar_20180208`
|
79
|
+
namespace :oneshot do
|
80
|
+
desc ''
|
81
|
+
task foo_bar_20180208: :environment do |task, args|
|
82
|
+
end
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
### Directory
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
# config/initializers/oneshot_task_generator.rb
|
90
|
+
OneshotGenerator.configure do |config|
|
91
|
+
config.directory = 'your/favorite/directory' # Default: lib/tasks/oneshot
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
67
95
|
## Contributing
|
68
96
|
|
69
97
|
Bug reports and pull requests are welcome on GitHub at https://github.com/s-osa/oneshot_task_generator.
|
@@ -10,11 +10,12 @@ class OneshotGenerator < Rails::Generators::NamedBase
|
|
10
10
|
def setup
|
11
11
|
@current = Time.current
|
12
12
|
@timestamp = @current.strftime('%Y%m%d')
|
13
|
-
@task_name = "#{
|
13
|
+
@task_name = "#{timestamp}_#{name.underscore}"
|
14
14
|
@configuration = self.class.configuration
|
15
15
|
end
|
16
16
|
|
17
17
|
def create_file_with_template
|
18
|
-
|
18
|
+
path = File.join(@configuration.directory, "#{task_name}.rake")
|
19
|
+
template 'oneshot.rake.erb', path
|
19
20
|
end
|
20
21
|
end
|
@@ -1,9 +1,15 @@
|
|
1
1
|
class OneshotGenerator < Rails::Generators::NamedBase
|
2
2
|
class Configuration
|
3
|
-
|
3
|
+
DEFAULT_DIRECTORY = 'lib/tasks/oneshot'.freeze
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
attr_accessor :body, :arguments
|
6
|
+
|
7
|
+
def directory
|
8
|
+
@directory || DEFAULT_DIRECTORY
|
9
|
+
end
|
10
|
+
|
11
|
+
def directory=(dir)
|
12
|
+
@directory = dir
|
7
13
|
end
|
8
14
|
end
|
9
15
|
end
|
@@ -4,11 +4,9 @@
|
|
4
4
|
<%= "# For copy and paste: `bin/rake oneshot:#{task_name}`" %>
|
5
5
|
namespace :oneshot do
|
6
6
|
desc ''
|
7
|
-
task <%= task_name %>: :environment do
|
7
|
+
task <%= "'#{task_name}'" %>: :environment do<%= configuration.arguments && " |#{configuration.arguments.join(", ")}|" %>
|
8
8
|
<%- if configuration.body -%>
|
9
|
-
|
10
|
-
<%= line %>
|
11
|
-
<%- end -%>
|
9
|
+
<%= configuration.body.indent(4) %>
|
12
10
|
<%- end -%>
|
13
11
|
end
|
14
12
|
end
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_runtime_dependency 'rails', '>= 3.0.0'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'ammeter'
|
30
|
-
spec.add_development_dependency 'bundler', '~>
|
30
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
31
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
32
32
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
33
|
spec.add_development_dependency 'sqlite3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneshot_task_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OSA Shunsuke
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
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: '
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
106
|
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
107
108
|
- Gemfile
|
108
109
|
- LICENSE
|
109
110
|
- README.md
|
@@ -135,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
- !ruby/object:Gem::Version
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
|
-
|
139
|
-
rubygems_version: 2.7.6
|
139
|
+
rubygems_version: 3.0.3
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Generator for oneshot rake task
|