rails_auto_commiter 0.1.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: f5df18bfffc33c736c2d10bef0c7f0757a98d715
4
- data.tar.gz: 9329b472279ce77d088b4e1d6444e3583641fbde
3
+ metadata.gz: 10929dba21499d3c2e568dab9b538a6547e0bee6
4
+ data.tar.gz: 2622279310cc0355a6712909536c066ba758b69a
5
5
  SHA512:
6
- metadata.gz: 8b232be2625bcb3c92081d300cd9b9d7eac299df3baa45a0c31ce161c64371d1e36538cb3aa7002a2c77838ab56111ceeb4b81f2c992d90611e66abe2dbb304a
7
- data.tar.gz: aab4afc31bbfdfea6d5441833371bd9d89f7b42de29617e86a56fd56c666f08b6c6015ceb175534d9032a1456d99947e8e4dadf8538f6e110bbe9008f77c4383
6
+ metadata.gz: 72ca1fcff071d01d233220abd4c8b40313abde2618b7cead6e78c4496b3a2826ca7c40c77c60322ab9c94aefe3a943c859429628968f50296eca437aad80fcff
7
+ data.tar.gz: 68ceba6aabe8d35d542d51b3f794a100c7f5b6e0189b730fc3fd381e23c850580824b0e0cb676d6b8bbedd463bf46309563b88210db1cf966c9124be244b5f24
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # RailsAutoCommiter
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_auto_commiter`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
2
+ RailsAutoCommiter provides an auto commiter for Ruby on Rails.
3
+ If you run `rails [generate,destroy] ...`, files Rails changed will be automatically commited by it.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,15 +20,30 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
23
+ Run the rails commands as always. The changed files are automatically committed.
24
+
25
+ ```zsh
26
+ % rails generate model Post hoge
27
+ Running via Spring preloader in process 78876
28
+ Expected string default value for '--jbuilder'; got true (boolean)
29
+ invoke active_record
30
+ create db/migrate/20170115144306_create_posts.rb
31
+ create app/models/post.rb
32
+ invoke test_unit
33
+ create test/models/post_test.rb
34
+ create test/fixtures/posts.yml
35
+ [master 0a9773b] result of 'rails generate model Post title body:text'.
36
+ 4 files changed, 28 insertions(+)
37
+ create mode 100644 app/models/post.rb
38
+ create mode 100644 db/migrate/20170115144306_create_posts.rb
39
+ create mode 100644 test/fixtures/posts.yml
40
+ create mode 100644 test/models/post_test.rb
41
+ ```
32
42
 
33
43
  ## Contributing
34
44
 
35
45
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_auto_commiter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
46
 
47
+ ## License
48
+
49
+ RailsAutoCommiter is released under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -1,101 +1,49 @@
1
1
  require "rails_auto_commiter/version"
2
+ require 'rails/commands/commands_tasks'
2
3
 
3
4
  module RailsAutoCommiter
4
5
  @@rails_auto_commiter_sub_commands = []
5
- @@rails_auto_commiter_commit_files = []
6
+ @@git_stashed = false
7
+
8
+ def self.git_stashed?
9
+ @@git_stashed
10
+ end
11
+
12
+ def self.git_stashed=(bool)
13
+ @@git_stashed = bool
14
+ end
15
+
6
16
  def self.sub_commands
7
17
  @@rails_auto_commiter_sub_commands
8
18
  end
9
19
  def self.sub_commands=(sub_commands)
10
20
  @@rails_auto_commiter_sub_commands = sub_commands
11
21
  end
12
- def self.commit_files
13
- @@rails_auto_commiter_commit_files
14
- end
15
- def self.commit_files=(files)
16
- @@rails_auto_commiter_commit_files = self.commit_files + files
17
- end
18
-
19
- module Thor
20
- module Actions
21
- module CreateFile
22
- def invoke_with_conflict_check(&block)
23
- unless exists? || pretend?
24
- RailsAutoCommiter.commit_files << destination
25
- end
26
- super
27
- end
28
-
29
- def revoke!
30
- #RailsAutoCommiter.sub_commands ||= ARGV.dup
31
- if exists? && !pretend?
32
- RailsAutoCommiter.commit_files << destination
33
- end
34
- super
35
- end
36
-
37
- protected
38
- def on_conflict_behavior(&block)
39
- options = base.options.dup.merge(config)
40
- if !identical? && pretend?
41
- RailsAutoCommiter.commit_files << destination
42
- end
43
- super
44
- end
45
-
46
- def force_or_skip_or_conflict(force, skip, &block)
47
- if force && !pretend?
48
- RailsAutoCommiter.commit_files << destination
49
- end
50
- super
51
- end
52
- end
53
- end
54
- end
55
22
 
56
23
  module Rails
57
24
  module CommandsTasks
58
25
  def run_command!(command)
59
- RailsAutoCommiter.sub_commands ||= []
26
+ #RailsAutoCommiter.sub_commands ||= []
60
27
  RailsAutoCommiter.sub_commands << command
61
28
  RailsAutoCommiter.sub_commands << ARGV.dup
62
- super
63
- end
64
- end
65
- module Generators
66
- module Actions
67
- module CreateMigration
68
- def revoke!
69
- say_destination = exists? ? relative_existing_migration : relative_destination
70
- if exists? && !pretend?
71
- RailsAutoCommiter.commit_files << say_destination
72
- end
73
- super
74
- end
75
-
76
- protected
77
- def on_conflict_behavior
78
- options = base.options.dup.merge(config)
79
- if !identical? && options[:force] && !pretend?
80
- RailsAutoCommiter.commit_files << existing_migration
81
- end
82
- super
83
- end
29
+ unless `git status`.match(/nothing to commit, working directory clean/)
30
+ system('git stash')
31
+ RailsAutoCommiter.git_stashed = true
84
32
  end
33
+ super
85
34
  end
86
35
  end
87
36
  end
88
37
  end
89
-
90
-
91
- Thor::Actions::CreateFile.send(:prepend, RailsAutoCommiter::Thor::Actions::CreateFile)
92
- Rails::Generators::Actions::CreateMigration.send(:prepend, RailsAutoCommiter::Rails::Generators::Actions::CreateMigration)
93
38
  Rails::CommandsTasks.send(:prepend, RailsAutoCommiter::Rails::CommandsTasks)
39
+
94
40
  at_exit do
95
- if RailsAutoCommiter.commit_files.any?
41
+ unless `git status`.match(/nothing to commit, working directory clean/)
42
+ system('git add .')
96
43
  sub_commands = RailsAutoCommiter.sub_commands.join(' ')
97
- commit_files = RailsAutoCommiter.commit_files.join(" ")
98
- system("git add #{commit_files}")
99
- system("git commit -o #{commit_files} -m \"result of 'rails #{sub_commands}'.\"")
44
+ system("git commit -m \"result of 'rails #{sub_commands}'.\"")
45
+ end
46
+ if RailsAutoCommiter.git_stashed?
47
+ system('git stash pop')
100
48
  end
101
49
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAutoCommiter
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_auto_commiter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Shirai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-15 00:00:00.000000000 Z
11
+ date: 2017-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler