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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19712b8bc5685ad3770bb596c00281b60ea6c394ec3a748c2874121660d1d90f
4
- data.tar.gz: 2470e42aa3128bac2e2c59994a0aab8a8bfb04e9887bac37d951dd294e4a1004
3
+ metadata.gz: 3a1f9d3c7b148c95dd6aede5178c8da1311364dc16086c279b58f3305b87a31a
4
+ data.tar.gz: 2bd7341c8e5c6fc4d4498e7b3f626a88ede8e4d1320ffb3485b33d6f4eb5e293
5
5
  SHA512:
6
- metadata.gz: 14bb6c24f59394f76688c4eb75698d6d340a600e04c44f96f5214406cc7489fba74d68c3c4d5e953774915875f535eb2cbce3453f2a664d954308c4625c1395e
7
- data.tar.gz: 9809857aa33df6b242f104845e1eaa43185e79c28c4177ed7cc6de08750ca0e097cd44c853124b873ea7d1d65aea6b6a343c11d21dc132a8609831a53a6f0f95
6
+ metadata.gz: 8d76f67720c53e7e93e6d8a2cc903b400e914ede767b51ea054b1dcded122316b101374afdd6a673ef97a0301b9a9ace819f9c151cfe7d2becc2fa6e1f59d197
7
+ data.tar.gz: 319b4c14a5bdf5f7a103c1138dcbd5885436f4de317c04699ea71c55e4bc7d062c81a45aebd04fd4729df85641e9e59bc5dd319e26263c83df0ed75bee0faae2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.4.0 (2023-02-06)
2
+
3
+ - Fixed error with irb 1.4.2+
4
+ - Dropped support for Ruby < 2.7 and Rails < 6
5
+
6
+ ## 0.3.0 (2022-01-10)
7
+
8
+ - Dropped support for Ruby < 2.6 and Rails < 5.2
9
+
1
10
  ## 0.2.3 (2021-08-03)
2
11
 
3
12
  - Added `save_session` option
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018-2020 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,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 'archer-rails'
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 'archer-rails', group: [:production]
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
@@ -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.2.3"
2
+ VERSION = "0.4.0"
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,61 +18,63 @@ module Archer
18
18
  mattr_accessor :save_session
19
19
  self.save_session = true
20
20
 
21
- # TODO remove in 0.3.0
22
- mattr_accessor :history_file
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
- def self.clear
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
- def self.start
34
- history = nil
35
- begin
46
+ def save
47
+ return false unless history_object
48
+
36
49
  quietly do
37
- 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!
38
53
  end
39
54
  rescue ActiveRecord::StatementInvalid
40
- warn "[archer] Create table to enable history"
55
+ warn "[archer] Unable to save history"
56
+ false
41
57
  end
42
58
 
43
- if history
44
- commands = history.commands.split("\n")
45
- history_object.push(*commands)
46
- end
47
- end
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
- # private
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
- # private
66
- def self.reline?
67
- IRB.CurrentContext.io.is_a?(IRB::ReidlineInputMethod)
68
- rescue
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
- # private
73
- def self.quietly
74
- ActiveRecord::Base.logger.silence do
75
- yield
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.2.3
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: 2021-08-03 00:00:00.000000000 Z
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: '5'
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'
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'
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'
40
+ version: '6'
41
41
  description:
42
- email: andrew@chartkick.com
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.4'
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.2.22
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