archer-rails 0.1.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +7 -2
- data/LICENSE.txt +1 -1
- data/README.md +10 -0
- data/lib/archer.rb +20 -4
- data/lib/archer/version.rb +1 -1
- data/lib/generators/archer/install_generator.rb +3 -23
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7efb1ead011d342fecc5b05028013de7a07fd101bbda3610b67f11d2707b8e59
|
4
|
+
data.tar.gz: 26e4472b7a6e5402a4319fd148d4b921225b19cd4d47215a1f6e45b20d1300d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 452c0c2b502e99e1d88694751ab538cab0134193ecff8de09ae27adc130cb37ab488162d48998c4e935165cf18c9c517298c7c33a04c89c4156a5ce997ac449e
|
7
|
+
data.tar.gz: 7adbb6348c77d01d5a3e9ddf5bd61ef4071e54f1a5b2018d7b877f67b04a05160025852408498a2fff6fa25d45cf4c38b4663135708fa517af9569844f9e0784
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -59,6 +59,8 @@ Clear history for current user with:
|
|
59
59
|
Archer.clear
|
60
60
|
```
|
61
61
|
|
62
|
+
You should do this after running sensitive commands.
|
63
|
+
|
62
64
|
## Configuration
|
63
65
|
|
64
66
|
Change the number of commands to remember
|
@@ -105,3 +107,11 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
105
107
|
- Fix bugs and [submit pull requests](https://github.com/ankane/archer/pulls)
|
106
108
|
- Write, clarify, or fix documentation
|
107
109
|
- Suggest or add new features
|
110
|
+
|
111
|
+
To get started with development:
|
112
|
+
|
113
|
+
```sh
|
114
|
+
git clone https://github.com/ankane/archer.git
|
115
|
+
cd archer
|
116
|
+
bundle install
|
117
|
+
```
|
data/lib/archer.rb
CHANGED
@@ -20,7 +20,8 @@ module Archer
|
|
20
20
|
quietly do
|
21
21
|
Archer::History.where(user: user).delete_all
|
22
22
|
end
|
23
|
-
Readline::HISTORY.clear
|
23
|
+
Readline::HISTORY.clear if defined?(Readline)
|
24
|
+
Reline::HISTORY.clear if defined?(Reline)
|
24
25
|
true
|
25
26
|
end
|
26
27
|
|
@@ -35,20 +36,35 @@ module Archer
|
|
35
36
|
end
|
36
37
|
|
37
38
|
if history
|
38
|
-
|
39
|
+
commands = history.commands.split("\n")
|
40
|
+
# can't use reline? yet, so push to all
|
41
|
+
Readline::HISTORY.push(*commands) if defined?(Readline)
|
42
|
+
Reline::HISTORY.push(*commands) if defined?(Reline)
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
46
|
def self.save
|
43
47
|
quietly do
|
44
48
|
history = Archer::History.where(user: user).first_or_initialize
|
45
|
-
history.commands =
|
46
|
-
history.save
|
49
|
+
history.commands = history_object.to_a.last(limit).join("\n")
|
50
|
+
history.save!
|
47
51
|
end
|
48
52
|
rescue ActiveRecord::StatementInvalid
|
49
53
|
warn "[archer] Unable to save history"
|
50
54
|
end
|
51
55
|
|
56
|
+
# private
|
57
|
+
def self.history_object
|
58
|
+
reline? ? Reline::HISTORY : Readline::HISTORY
|
59
|
+
end
|
60
|
+
|
61
|
+
# private
|
62
|
+
def self.reline?
|
63
|
+
IRB.CurrentContext.io.is_a?(IRB::ReidlineInputMethod)
|
64
|
+
rescue
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
52
68
|
# private
|
53
69
|
def self.quietly
|
54
70
|
ActiveRecord::Base.logger.silence do
|
data/lib/archer/version.rb
CHANGED
@@ -1,37 +1,17 @@
|
|
1
|
-
# taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
|
2
|
-
require "rails/generators"
|
3
|
-
require "rails/generators/migration"
|
4
|
-
require "active_record"
|
5
1
|
require "rails/generators/active_record"
|
6
2
|
|
7
3
|
module Archer
|
8
4
|
module Generators
|
9
5
|
class InstallGenerator < Rails::Generators::Base
|
10
|
-
include
|
11
|
-
source_root File.
|
12
|
-
|
13
|
-
# Implement the required interface for Rails::Generators::Migration.
|
14
|
-
def self.next_migration_number(dirname) #:nodoc:
|
15
|
-
next_migration_number = current_migration_number(dirname) + 1
|
16
|
-
if ::ActiveRecord::Base.timestamped_migrations
|
17
|
-
[Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
|
18
|
-
else
|
19
|
-
"%.3d" % next_migration_number
|
20
|
-
end
|
21
|
-
end
|
6
|
+
include ActiveRecord::Generators::Migration
|
7
|
+
source_root File.join(__dir__, "templates")
|
22
8
|
|
23
9
|
def copy_migration
|
24
10
|
migration_template "migration.rb", "db/migrate/create_archer_history.rb", migration_version: migration_version
|
25
11
|
end
|
26
12
|
|
27
13
|
def migration_version
|
28
|
-
|
29
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def rails5?
|
34
|
-
Rails::VERSION::MAJOR >= 5
|
14
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
35
15
|
end
|
36
16
|
end
|
37
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archer-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,15 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '2.
|
97
|
+
version: '2.4'
|
98
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
103
|
requirements: []
|
104
|
-
|
105
|
-
rubygems_version: 2.7.7
|
104
|
+
rubygems_version: 3.1.2
|
106
105
|
signing_key:
|
107
106
|
specification_version: 4
|
108
107
|
summary: Rails console history for Heroku, Docker, and more
|