archer-rails 0.2.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +4 -2
- data/lib/archer/engine.rb +0 -7
- data/lib/archer/irb.rb +1 -1
- data/lib/archer/version.rb +1 -1
- data/lib/archer-rails.rb +1 -1
- data/lib/archer.rb +48 -46
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a1f9d3c7b148c95dd6aede5178c8da1311364dc16086c279b58f3305b87a31a
|
4
|
+
data.tar.gz: 2bd7341c8e5c6fc4d4498e7b3f626a88ede8e4d1320ffb3485b33d6f4eb5e293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d76f67720c53e7e93e6d8a2cc903b400e914ede767b51ea054b1dcded122316b101374afdd6a673ef97a0301b9a9ace819f9c151cfe7d2becc2fa6e1f59d197
|
7
|
+
data.tar.gz: 319b4c14a5bdf5f7a103c1138dcbd5885436f4de317c04699ea71c55e4bc7d062c81a45aebd04fd4729df85641e9e59bc5dd319e26263c83df0ed75bee0faae2
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -6,12 +6,14 @@ Rails console history for Heroku, Docker, and more
|
|
6
6
|
|
7
7
|
Designed for platforms with ephemeral filesystems
|
8
8
|
|
9
|
+
[![Build Status](https://github.com/ankane/archer/workflows/build/badge.svg?branch=master)](https://github.com/ankane/archer/actions)
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add this line to your application’s Gemfile:
|
12
14
|
|
13
15
|
```ruby
|
14
|
-
gem
|
16
|
+
gem "archer-rails"
|
15
17
|
```
|
16
18
|
|
17
19
|
And run:
|
@@ -24,7 +26,7 @@ rails db:migrate
|
|
24
26
|
Lastly, update your Gemfile to only include it in environments where you need it:
|
25
27
|
|
26
28
|
```ruby
|
27
|
-
gem
|
29
|
+
gem "archer-rails", group: [:production]
|
28
30
|
```
|
29
31
|
|
30
32
|
## How It Works
|
data/lib/archer/engine.rb
CHANGED
@@ -1,15 +1,8 @@
|
|
1
1
|
module Archer
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
console do
|
4
|
-
# TODO remove in 0.3.0
|
5
|
-
Archer.history_file ||= Rails.root.join("tmp", ".irb-history")
|
6
|
-
|
7
4
|
# need IRB context to be ready before Archer.start
|
8
5
|
::IRB::Irb.prepend(Archer::Irb)
|
9
|
-
|
10
|
-
at_exit do
|
11
|
-
Archer.save if Archer.save_session
|
12
|
-
end
|
13
6
|
end
|
14
7
|
end
|
15
8
|
end
|
data/lib/archer/irb.rb
CHANGED
data/lib/archer/version.rb
CHANGED
data/lib/archer-rails.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
require_relative "archer"
|
data/lib/archer.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
require "active_support/core_ext/module/attribute_accessors"
|
3
3
|
|
4
4
|
# modules
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
require_relative "archer/engine" if defined?(Rails)
|
6
|
+
require_relative "archer/irb"
|
7
|
+
require_relative "archer/version"
|
8
8
|
|
9
9
|
module Archer
|
10
10
|
autoload :History, "archer/history"
|
@@ -18,61 +18,63 @@ module Archer
|
|
18
18
|
mattr_accessor :save_session
|
19
19
|
self.save_session = true
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
class << self
|
22
|
+
def start
|
23
|
+
if !history_object
|
24
|
+
warn "[archer] Skipping history"
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
history = nil
|
29
|
+
begin
|
30
|
+
quietly do
|
31
|
+
history = Archer::History.find_by(user: user)
|
32
|
+
end
|
33
|
+
rescue ActiveRecord::StatementInvalid
|
34
|
+
warn "[archer] Create table to enable history"
|
35
|
+
end
|
36
|
+
|
37
|
+
if history
|
38
|
+
commands = history.commands.split("\n")
|
39
|
+
history_object.clear
|
40
|
+
history_object.push(*commands)
|
41
|
+
end
|
23
42
|
|
24
|
-
|
25
|
-
quietly do
|
26
|
-
Archer::History.where(user: user).delete_all
|
43
|
+
IRB.conf[:AT_EXIT].push(proc { Archer.save if Archer.save_session })
|
27
44
|
end
|
28
|
-
Readline::HISTORY.clear if defined?(Readline)
|
29
|
-
Reline::HISTORY.clear if defined?(Reline)
|
30
|
-
true
|
31
|
-
end
|
32
45
|
|
33
|
-
|
34
|
-
|
35
|
-
|
46
|
+
def save
|
47
|
+
return false unless history_object
|
48
|
+
|
36
49
|
quietly do
|
37
|
-
history = Archer::History.
|
50
|
+
history = Archer::History.where(user: user).first_or_initialize
|
51
|
+
history.commands = history_object.to_a.last(limit).join("\n")
|
52
|
+
history.save!
|
38
53
|
end
|
39
54
|
rescue ActiveRecord::StatementInvalid
|
40
|
-
warn "[archer]
|
55
|
+
warn "[archer] Unable to save history"
|
56
|
+
false
|
41
57
|
end
|
42
58
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
def self.save
|
50
|
-
quietly do
|
51
|
-
history = Archer::History.where(user: user).first_or_initialize
|
52
|
-
history.commands = history_object.to_a.last(limit).join("\n")
|
53
|
-
history.save!
|
59
|
+
def clear
|
60
|
+
quietly do
|
61
|
+
Archer::History.where(user: user).delete_all
|
62
|
+
end
|
63
|
+
history_object.clear if history_object
|
64
|
+
true
|
54
65
|
end
|
55
|
-
rescue ActiveRecord::StatementInvalid
|
56
|
-
warn "[archer] Unable to save history"
|
57
|
-
end
|
58
66
|
|
59
|
-
|
60
|
-
# TODO use IRB.CurrentContext.io.class::HISTORY
|
61
|
-
def self.history_object
|
62
|
-
reline? ? Reline::HISTORY : Readline::HISTORY
|
63
|
-
end
|
67
|
+
private
|
64
68
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
false
|
70
|
-
end
|
69
|
+
def history_object
|
70
|
+
cls = IRB.CurrentContext&.io&.class
|
71
|
+
cls && cls.const_defined?(:HISTORY) ? cls::HISTORY : nil
|
72
|
+
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
def quietly
|
75
|
+
ActiveRecord::Base.logger.silence do
|
76
|
+
yield
|
77
|
+
end
|
76
78
|
end
|
77
79
|
end
|
78
80
|
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.4.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: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,30 +16,30 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
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: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '6'
|
41
41
|
description:
|
42
|
-
email: andrew@
|
42
|
+
email: andrew@ankane.org
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
@@ -67,14 +67,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
67
|
requirements:
|
68
68
|
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '2.
|
70
|
+
version: '2.7'
|
71
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
77
|
+
rubygems_version: 3.4.6
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: Rails console history for Heroku, Docker, and more
|