oneshot_task_generator 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b5647e3e28a4c5dd000eb09c53e36f3f0c17e5f003e7df5198300da319b6e2f
4
- data.tar.gz: c4f5f66e379426a019acbfe49adb7bd45d68e9de4fc5a2f83ee24cfabae55a0b
3
+ metadata.gz: 2a314fba0676ad53998616ecd7f1c6d6a867b52336e78139a6e4500f57e52cfc
4
+ data.tar.gz: f9167edfcb98a7ce8d32c37521ab4372bbc7a25971e826c7ca63040df0ac1079
5
5
  SHA512:
6
- metadata.gz: 017572bb3fa8cc58d67cff63bb10c6e8fcab05e3962addb0b9f7aee25d3395317397cdaff41efd3590612788fde7b00c184262ca0462b7d41930fdd970a01fbe
7
- data.tar.gz: bbd064b8c05cef1141af5aa052ae90762aa3149ef75d1cd31d6605576b0d00518edb432952db8da78911496ace51910b07d8dcaa90428869fa4889123f8d795b
6
+ metadata.gz: b87c57adbaebe2d9216829a9fb40b1634c294441df6e5b8e3bf39a03ac881bd45559113bf15f751e16d00166dffd3a159ef4b3404536e9648fdb50b58ac49aa8
7
+ data.tar.gz: b78e5b2589534e4896154ff8956cbd59ffb76e0f7cc684253a9af2963120be9bc0e29c9ca643b2a454898df04ef4946e4447c0966f430a2f5523e892929620f7
@@ -1,5 +1,5 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.16.0
4
+ - 2.4.4
5
+ before_install: gem install bundler -v 2.0.1
@@ -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/ohesnot_task_generator.rb
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 = "#{name.underscore}_#{timestamp}"
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
- template 'oneshot.rake.erb', "lib/tasks/oneshot/#{timestamp}_#{name.underscore}.rake"
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
- attr_accessor :body
3
+ DEFAULT_DIRECTORY = 'lib/tasks/oneshot'.freeze
4
4
 
5
- def initialize
6
- @body = nil
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
- <%- configuration.body.each_line.map(&:chomp).each do |line| -%>
10
- <%= line %>
11
- <%- end -%>
9
+ <%= configuration.body.indent(4) %>
12
10
  <%- end -%>
13
11
  end
14
12
  end
@@ -1,3 +1,5 @@
1
+ require 'rails/generators'
2
+
1
3
  require 'oneshot_task_generator/version'
2
4
  require 'generators/oneshot/oneshot_generator'
3
5
 
@@ -1,3 +1,3 @@
1
1
  module OneshotTaskGenerator
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  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', '~> 1.16'
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.1.1
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: 2018-08-14 00:00:00.000000000 Z
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: '1.16'
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: '1.16'
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
- rubyforge_project:
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