archer-rails 0.3.0 → 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 +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +2 -0
- data/lib/archer/engine.rb +0 -4
- 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 +49 -44
- metadata +8 -8
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,6 +6,8 @@ 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:
|
data/lib/archer/engine.rb
CHANGED
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,58 +18,63 @@ module Archer
|
|
18
18
|
mattr_accessor :save_session
|
19
19
|
self.save_session = true
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
42
|
+
|
43
|
+
IRB.conf[:AT_EXIT].push(proc { Archer.save if Archer.save_session })
|
24
44
|
end
|
25
|
-
Readline::HISTORY.clear if defined?(Readline)
|
26
|
-
Reline::HISTORY.clear if defined?(Reline)
|
27
|
-
true
|
28
|
-
end
|
29
45
|
|
30
|
-
|
31
|
-
|
32
|
-
|
46
|
+
def save
|
47
|
+
return false unless history_object
|
48
|
+
|
33
49
|
quietly do
|
34
|
-
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!
|
35
53
|
end
|
36
54
|
rescue ActiveRecord::StatementInvalid
|
37
|
-
warn "[archer]
|
38
|
-
|
39
|
-
|
40
|
-
if history
|
41
|
-
commands = history.commands.split("\n")
|
42
|
-
history_object.push(*commands)
|
55
|
+
warn "[archer] Unable to save history"
|
56
|
+
false
|
43
57
|
end
|
44
|
-
end
|
45
58
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
51
65
|
end
|
52
|
-
rescue ActiveRecord::StatementInvalid
|
53
|
-
warn "[archer] Unable to save history"
|
54
|
-
end
|
55
66
|
|
56
|
-
|
57
|
-
# TODO use IRB.CurrentContext.io.class::HISTORY
|
58
|
-
def self.history_object
|
59
|
-
reline? ? Reline::HISTORY : Readline::HISTORY
|
60
|
-
end
|
67
|
+
private
|
61
68
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
false
|
67
|
-
end
|
69
|
+
def history_object
|
70
|
+
cls = IRB.CurrentContext&.io&.class
|
71
|
+
cls && cls.const_defined?(:HISTORY) ? cls::HISTORY : nil
|
72
|
+
end
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
def quietly
|
75
|
+
ActiveRecord::Base.logger.silence do
|
76
|
+
yield
|
77
|
+
end
|
73
78
|
end
|
74
79
|
end
|
75
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,28 +16,28 @@ 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
42
|
email: andrew@ankane.org
|
43
43
|
executables: []
|
@@ -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
|