rails_history 0.1.1 → 0.1.2

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: ec45d004deb86c20b54381c85e11558acd7575e2
4
- data.tar.gz: dc3c824f0500f7ea1b1d2d3fa50ca714e17b3993
3
+ metadata.gz: 4f84148e58700766cde2017601f4242043653a17
4
+ data.tar.gz: 7af9c142c9b4ae8c24c106611c39a96f0bb5f425
5
5
  SHA512:
6
- metadata.gz: de6fdc6d5a9dca1e7b7bd4fcb19afbc85bc4b95d4d4175136e327483379614614f2030a288f707c124b4d91217f3a1728776a83846569d08798eb0bd5a14aea2
7
- data.tar.gz: 3e2293c727cc86c22715cd4117bf6d317652c88644ccb3e2ec8cba067ecceacf3e567685e1bc52c6bf65c05afe0fdbcecc08c95a25b0ee1bb324db1d850f398f
6
+ metadata.gz: fd9eb60b9d55d122745c2edc1607e38df4027206f0a133fbce4e4b6acf7a3f676c4c89e94727401fd362c61e42b6491790aac7132be14c923b5bf9799cbe1c78
7
+ data.tar.gz: 148bad10e1009f2822bff05d3be8b03d6d3bb7122bfec08aa338fc06ea90ccd297ae67c3ef2afd1939a8bd8b9ef6454a464d4e40269b3edd453da6793fca4b4e
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # RailsHistory
2
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_history`. 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
3
+ A command like history for rails.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,33 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ### History Recording
24
+
25
+ This gem records rails generate/destroy histories on the `.rails_history` file automatically.
26
+
27
+ ```
28
+ $ rails g model sample
29
+ $ cat .rails_history
30
+ rails generate model sample
31
+ ```
32
+
33
+ ### History Reference
34
+
35
+ The `rails-history` command show entries in the history list:
36
+
37
+ ```
38
+ $ bundle exec rails-history
39
+ 1 rails generate model sample
40
+ ```
41
+
42
+ You can re-execute a command in the history list:
43
+
44
+ ```
45
+ $ bundle exec rails-history 1
46
+ bundle exec rails generate model sample
47
+ invoke active_record
48
+ ...
49
+ ```
26
50
 
27
51
  ## Development
28
52
 
@@ -37,3 +61,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
37
61
  3. Commit your changes (`git commit -am 'Add some feature'`)
38
62
  4. Push to the branch (`git push origin my-new-feature`)
39
63
  5. Create a new Pull Request
64
+
65
+ ## TODO
66
+
67
+ * Options like `history` command
@@ -1,8 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'active_support/all'
2
3
 
4
+ exit(0) unless File.exist?('.rails_history')
5
+
6
+ index = ARGV.shift
3
7
  lines = File.open('.rails_history').readlines
4
- digits = lines.size.to_s.size + 2
5
8
 
6
- lines.each.with_index do |line, i|
7
- puts sprintf("%#{digits}d %s", i + 1, line)
9
+ if index.blank?
10
+ digits = lines.size.to_s.size + 2
11
+ lines.each.with_index do |line, i|
12
+ puts format("%#{digits}d %s", i + 1, line)
13
+ end
14
+ else
15
+ command = lines[index.to_i - 1]
16
+ exit(1) if command.blank?
17
+
18
+ command = ['bundle exec', command].join(' ') if ENV['BUNDLE_GEMFILE'].present?
19
+
20
+ puts command
21
+ system(command)
8
22
  end
@@ -1,3 +1,3 @@
1
1
  module RailsHistory
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiyuki Kawanishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-24 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties