hekenga 0.2.2 → 0.2.3

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: 5c1f3ac82c49c8e9a8bd7c6f4f19c84635aaa23a
4
- data.tar.gz: 8a5ca5edb2466028aae898dbadea22be274c16cb
3
+ metadata.gz: 3cf17b971c05bcd12752ba2fee74a7ff91822bb3
4
+ data.tar.gz: c1bf8483ec9c90af9b9928e8824145947a5a77c8
5
5
  SHA512:
6
- metadata.gz: 2521d604981082a18726e254fa08753341a6fa636cb0faa43c052978794bca502d7a1d472d0d89bf0f7c5e5978e5656163630974d14f70745651f035e1b7f228
7
- data.tar.gz: e72982f0c4295750105fc89eadd058dc2b79556b4419f77cc53c0f3c0307cc69b4019192d1d625667b9e23c70cfbd5ffb705f7c7f2762756fb8179e21d18abe8
6
+ metadata.gz: fb3af1f89fa0245d6342cd75ddd819da3503091f36356d4d6d38ddc27bb54c25e5f31184f2f57c164cbd23fc7e0f7ef32338f36aa5c8a67c65fb332383ad0b6d
7
+ data.tar.gz: 5feb76a672d70b79fdfc09f44c8770a048de7ce84a928a6476971f74d8cf31258e5473e48426cfb6f5c99381f64f843d943675951e6b0287ecc5b81a86acb37b
data/exe/hekenga CHANGED
@@ -8,6 +8,7 @@ end
8
8
 
9
9
  require "hekenga"
10
10
  require "thor"
11
+ require "pathname"
11
12
 
12
13
  class HekengaCLI < Thor
13
14
  desc "status", "Show which migrations have run and their status."
@@ -110,6 +111,23 @@ class HekengaCLI < Thor
110
111
  puts "Done!"
111
112
  end
112
113
 
114
+ desc "generate <description> --edit", "Generate a migration scaffold (and optionally edit in your editor)."
115
+ option :edit
116
+ def generate(*description)
117
+ description = description.join(" ")
118
+ scaffold = Hekenga::Scaffold.new(description)
119
+ scaffold.write!
120
+ puts "Done! You can find your migration in:"
121
+ path = Pathname.new(scaffold.to_path).relative_path_from(Pathname.new(Dir.pwd)).to_s
122
+ puts path
123
+ if options[:edit]
124
+ if !ENV["EDITOR"]
125
+ puts "You need to set EDITOR in your ENV to use this feature."
126
+ exit(0)
127
+ end
128
+ exec "$EDITOR #{path}"
129
+ end
130
+ end
113
131
  private
114
132
 
115
133
  def todo(op)
@@ -0,0 +1,62 @@
1
+ require 'hekenga/migration'
2
+ module Hekenga
3
+ class Scaffold
4
+ def initialize(description)
5
+ @migration = Hekenga::Migration.new.tap do |migration|
6
+ migration.description = description
7
+ migration.stamp = Time.now
8
+ end
9
+ end
10
+
11
+ def write!
12
+ if File.exist?(to_path)
13
+ raise "That migration already exists!"
14
+ end
15
+ File.open(to_path, "w") {|f| f.puts self }
16
+ end
17
+
18
+ def to_path
19
+ @path ||= File.join(Hekenga.config.abs_dir, @migration.to_key+".rb")
20
+ end
21
+
22
+ def to_s
23
+ <<-EOF.strip_heredoc
24
+ Hekenga.migration do
25
+ ## Required
26
+ description #{@migration.description.inspect}
27
+ created #{@migration.timestamp.sub("T", " ").inspect}
28
+
29
+ ## Optional
30
+ # batch_size 10
31
+
32
+ ## Simple tasks
33
+ # task "task description" do
34
+ # up do
35
+ # end
36
+ # end
37
+
38
+ ## Per document tasks
39
+ # per_document "task description" do
40
+ # ## Required
41
+ # scope MyModel.all
42
+ #
43
+ # ## Optional config
44
+ # # parallel!
45
+ # # timeless!
46
+ # # skip_prepare!
47
+ # # when_invalid :prompt # :prompt, :cancel, :stop, :continue
48
+ # #
49
+ # # setup do
50
+ # # end
51
+ # # filter do
52
+ # # end
53
+ #
54
+ # up do |doc|
55
+ # end
56
+ # end
57
+ end
58
+ EOF
59
+ end
60
+
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module Hekenga
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/hekenga.rb CHANGED
@@ -5,6 +5,7 @@ require "hekenga/dsl"
5
5
  require "hekenga/config"
6
6
  require "hekenga/irreversible"
7
7
  require "hekenga/virtual_method"
8
+ require "hekenga/scaffold"
8
9
 
9
10
  module Hekenga
10
11
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hekenga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tapio Saarinen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-06 00:00:00.000000000 Z
11
+ date: 2017-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -175,6 +175,7 @@ files:
175
175
  - lib/hekenga/master_process.rb
176
176
  - lib/hekenga/migration.rb
177
177
  - lib/hekenga/parallel_job.rb
178
+ - lib/hekenga/scaffold.rb
178
179
  - lib/hekenga/simple_task.rb
179
180
  - lib/hekenga/version.rb
180
181
  - lib/hekenga/virtual_method.rb