archer-rails 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: 35a51652ad167e88ab4359b2a007746f46c1e15ed689ab252cda60631adaef45
4
- data.tar.gz: 71f8034c47eeb7f6f0ed618544332f32a318e04a6419963bfa4a8dc9a9413c94
3
+ metadata.gz: 5c3fdea9c7dd926570591aa18df85e82ffec3759feb6ae3768446c263db5f0e2
4
+ data.tar.gz: b778542bba600b0c2146750769cc19779d7366176b19690be1ef8d91b2e7af43
5
5
  SHA512:
6
- metadata.gz: fa0caa5c6ef56a53b2e76b2b753eed6e02695584ecc23f57ae4e46b939e4bdd53288b8d997ffd24b1e3eb85a8210d3c61c3755b52c98f8f83ae65ccca9453507
7
- data.tar.gz: 7150fd672798cb21d465fb9247093c2e1b220e56106f5e38a5fdc3cbbb26f9c2bce2e3f5fb856035d53e33a3641e767ea5603d20aab851db6862a06510400fe8
6
+ metadata.gz: ef40368afbd616f17f31e93892c100f855634f7c7d74fd41f3b66538e81bf8663b68c9e83d135d64a159ce8879433d43b59092280df8dbdb33d5f560e6440b33
7
+ data.tar.gz: 59cbbd96bfe605d295057571aa70ec04ec4d9a851c10c0bf9a7d564283b589b31ebdf4de1241da5e2d945c42ddd34edc6ff89813ceacd8566a93d6c58518b4d7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.4.1 (2023-10-31)
2
+
3
+ - Fixed error with Rails 7.1
4
+
5
+ ## 0.4.0 (2023-02-06)
6
+
7
+ - Fixed error with irb 1.4.2+
8
+ - Dropped support for Ruby < 2.7 and Rails < 6
9
+
1
10
  ## 0.3.0 (2022-01-10)
2
11
 
3
12
  - Dropped support for Ruby < 2.6 and Rails < 5.2
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018-2022 Andrew Kane
3
+ Copyright (c) 2018-2023 Andrew Kane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
@@ -2,11 +2,8 @@ module Archer
2
2
  class Engine < Rails::Engine
3
3
  console do
4
4
  # need IRB context to be ready before Archer.start
5
+ require "irb"
5
6
  ::IRB::Irb.prepend(Archer::Irb)
6
-
7
- at_exit do
8
- Archer.save if Archer.save_session
9
- end
10
7
  end
11
8
  end
12
9
  end
data/lib/archer/irb.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Archer
2
2
  module Irb
3
3
  # needs to run after conf[:MAIN_CONTEXT] is set
4
- def eval_input(*)
4
+ def eval_input(...)
5
5
  Archer.start
6
6
  super
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module Archer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/lib/archer-rails.rb CHANGED
@@ -1 +1 @@
1
- require "archer"
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
- require "archer/engine" if defined?(Rails)
6
- require "archer/irb"
7
- require "archer/version"
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
- def self.clear
22
- quietly do
23
- Archer::History.where(user: user).delete_all
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
- def self.start
31
- history = nil
32
- begin
46
+ def save
47
+ return false unless history_object
48
+
33
49
  quietly do
34
- history = Archer::History.find_by(user: user)
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] Create table to enable history"
38
- end
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
- def self.save
47
- quietly do
48
- history = Archer::History.where(user: user).first_or_initialize
49
- history.commands = history_object.to_a.last(limit).join("\n")
50
- 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
51
65
  end
52
- rescue ActiveRecord::StatementInvalid
53
- warn "[archer] Unable to save history"
54
- end
55
66
 
56
- # private
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
- # private
63
- def self.reline?
64
- IRB.CurrentContext.io.is_a?(IRB::ReidlineInputMethod)
65
- rescue
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
- # private
70
- def self.quietly
71
- ActiveRecord::Base.logger.silence do
72
- yield
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.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2023-10-31 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: '5.2'
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: '5.2'
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: '5.2'
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: '5.2'
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.6'
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.3.3
77
+ rubygems_version: 3.4.10
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: Rails console history for Heroku, Docker, and more