tasks-migration 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3819807335af95ccb427e285be7b1a1de33de62121de2e02dc84ef91b2beb7bd
4
- data.tar.gz: b4fddc32fbbbed607aac80e1cde9f1b055fad5ac29585341e174797391647594
3
+ metadata.gz: 7bafed3e78b6ace08a69b4159b0eacab87074972936f856a04ad258d52bad39c
4
+ data.tar.gz: 18e092b469d0078078f812e145624c91a8dc53c375d9f111171c273f483e563d
5
5
  SHA512:
6
- metadata.gz: 26cc0a5b760811dc70cfbfd7399d8b2839188a52576de844da203194fe7a265f0e791c0898384f5e5fd4c018c201dc41647d9c34893822b2b14f5590265f1e98
7
- data.tar.gz: f5f04b6dcac6ad14fecf802ea16368d3fda732abe502fca9bfb8123b8413ec4e8e3eaa781d686301a4ed0dd093a07664e2909557509f8f085e3229d9373d1f15
6
+ metadata.gz: aa47170f31399eb113ae212fa642e32503a9d037dd2b3e8d087c264cce6278c68b6253ff8e349bb5845bd91434a89f80cb001b349c8e69b3fe4c42b8a215f58f
7
+ data.tar.gz: e813bebfc95b56668652adff08f9fea37877c7bbd37d2b4ab9085d211aeef69d650089df5d57bd63971ada5cbb2cfe5721fe5cda996b334d4be55e65fc56b826
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## `0.0.2`
4
+
5
+ - Enhancements
6
+ * Support run task(s) when module name similar task name ([#13](https://github.com/namnv609/tasks-migration/issues/13))
7
+ * Add option `--no-suffix` to remove `Task` suffix from task name
8
+
3
9
  ## `0.0.1`
4
10
 
5
11
  - Release gem
data/README.md CHANGED
@@ -31,7 +31,7 @@ This command will create 2 files:
31
31
  Create a new task by command:
32
32
 
33
33
  ```
34
- rails generate tasks_migration:task <TaskName>
34
+ rails generate tasks_migration:task <TaskName> [--no-suffix]
35
35
  ```
36
36
 
37
37
  Business Logic will be handled in method `self.excute` on file `app/migration_tasks/<task_name>.rb`. Example:
@@ -4,10 +4,15 @@ module TasksMigration
4
4
  module Generators
5
5
  class TaskGenerator < ::Rails::Generators::NamedBase
6
6
  source_root File.expand_path("../templates", __FILE__)
7
+ class_option "no-suffix", type: :boolean, default: false,
8
+ desc: "Remove Task suffix for task class name"
7
9
 
8
10
  desc "Add new migration task"
9
11
  def add_task
10
- template "task.rb", "app/migration_tasks/#{name.underscore}_task.rb", name: name
12
+ task_file_suffix = "_task" unless options["no-suffix"]
13
+ task_file_name = "#{name.underscore}#{task_file_suffix}.rb"
14
+
15
+ template "task.rb", "app/migration_tasks/#{task_file_name}"
11
16
  end
12
17
  end
13
18
  end
@@ -1,4 +1,4 @@
1
- class <%= name %>Task
1
+ class <%= name.classify %><%= "Task" unless options["no-suffix"] %>
2
2
  def self.execute
3
3
  # Logic here
4
4
  end
@@ -9,8 +9,11 @@ module TasksMigration
9
9
  executed_tasks = TasksMigrationSchema.pluck :version
10
10
 
11
11
  (all_tasks - executed_tasks).each do |task|
12
- puts "Running task #{task}..."
13
- task.constantize.execute
12
+ task_name = task.classify
13
+
14
+ puts "Running task #{task_name}..."
15
+ task_name.constantize.execute
16
+
14
17
  TasksMigrationSchema.create version: task
15
18
  end
16
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tasks-migration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - NamNV609
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-01 00:00:00.000000000 Z
11
+ date: 2019-02-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Running tasks for Rails as migration
14
14
  email: namnv609@gmail.com