oneshot_task_generator 0.0.1 → 0.1.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
  SHA1:
3
- metadata.gz: 2d95571491a35232bc1229f5fc8c38b82b45efd0
4
- data.tar.gz: 41ce05fcd9b90173dbe785656aa8c36e60cbccaa
3
+ metadata.gz: acbff35d1496ac10162cbd82c93167bab47f07b3
4
+ data.tar.gz: 4fc4c0346f8a4a84b325ef193eb0dd5790ea62e5
5
5
  SHA512:
6
- metadata.gz: d552062163765c421d0174d108c13aecdac11e9dbae8673db3da100f9c857fb34e5d4ab526eab2a1eae28c22738086fc252ef313069c643671c8f34a19ea163e
7
- data.tar.gz: '095751893072868ef0119e10eccdba49c34a6a1b4cc64f0d1e79a815de7a8010895d960449e794ec97c0727e68dcf7eb0df82df9244585606d0054680cc0196d'
6
+ metadata.gz: b943d81ac188cfd3c66036f6c403a042c3773864768aedcfccd5a3aab7fa9ac7ef381dfe47335dedeae31d10d9b584394af866e751eee0ebabbbd6511f2109b2
7
+ data.tar.gz: a79c5ad7f9349af14a3456eba9bc69d6cafb51d28138767d774f6c8c7d073fd4e4a12757028fcd45d6a8b4b128b8fc4dc16ef0686a2c71a513c20531290861ec
data/README.md CHANGED
@@ -26,7 +26,7 @@ end
26
26
  Add this line to your application's Gemfile:
27
27
 
28
28
  ```ruby
29
- gem 'oneshot_generator'
29
+ gem 'oneshot_task_generator'
30
30
  ```
31
31
 
32
32
  And then execute:
@@ -1,12 +1,17 @@
1
+ require 'generators/oneshot/oneshot_generator/configurator'
2
+
1
3
  class OneshotGenerator < Rails::Generators::NamedBase
4
+ extend Configurator
5
+
2
6
  source_root File.expand_path('../templates', __FILE__)
3
7
 
4
- attr_reader :current, :timestamp, :task_name
8
+ attr_reader :current, :timestamp, :task_name, :configuration
5
9
 
6
10
  def setup
7
11
  @current = Time.current
8
12
  @timestamp = @current.strftime('%Y%m%d')
9
13
  @task_name = "#{name.underscore}_#{timestamp}"
14
+ @configuration = self.class.configuration
10
15
  end
11
16
 
12
17
  def create_file_with_template
@@ -0,0 +1,10 @@
1
+ class OneshotGenerator < Rails::Generators::NamedBase
2
+ class Configuration
3
+ attr_accessor :body
4
+
5
+ def initialize
6
+ @body = nil
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,19 @@
1
+ require 'generators/oneshot/oneshot_generator/configuration'
2
+
3
+ class OneshotGenerator < Rails::Generators::NamedBase
4
+ module Configurator
5
+ def configure
6
+ yield(configuration)
7
+ end
8
+
9
+ def configuration
10
+ @configuration ||= Configuration.new
11
+ end
12
+ alias :config :configuration
13
+
14
+ def configuration=(config)
15
+ @configuration = config
16
+ end
17
+ alias :config= :configuration=
18
+ end
19
+ end
@@ -3,5 +3,10 @@
3
3
  namespace :oneshot do
4
4
  desc ''
5
5
  task <%= task_name %>: :environment do
6
+ <%- if configuration.body -%>
7
+ <%- configuration.body.each_line.map(&:chomp).each do |line| -%>
8
+ <%= line %>
9
+ <%- end -%>
10
+ <%- end -%>
6
11
  end
7
12
  end
@@ -1,4 +1,5 @@
1
1
  require 'oneshot_task_generator/version'
2
+ require 'generators/oneshot/oneshot_generator'
2
3
 
3
4
  module OneshotTaskGenerator
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module OneshotTaskGenerator
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
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.0.1
4
+ version: 0.1.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-02-06 00:00:00.000000000 Z
11
+ date: 2018-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -110,6 +110,8 @@ files:
110
110
  - Rakefile
111
111
  - lib/generators/oneshot/USAGE
112
112
  - lib/generators/oneshot/oneshot_generator.rb
113
+ - lib/generators/oneshot/oneshot_generator/configuration.rb
114
+ - lib/generators/oneshot/oneshot_generator/configurator.rb
113
115
  - lib/generators/oneshot/templates/oneshot.rake.erb
114
116
  - lib/oneshot_task_generator.rb
115
117
  - lib/oneshot_task_generator/version.rb