archer-rails 0.4.0 → 1.0.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: 3a1f9d3c7b148c95dd6aede5178c8da1311364dc16086c279b58f3305b87a31a
4
- data.tar.gz: 2bd7341c8e5c6fc4d4498e7b3f626a88ede8e4d1320ffb3485b33d6f4eb5e293
3
+ metadata.gz: cfa9d6ae65482f9657b535e1ca99438e16406e18558d73697b5575253276cab1
4
+ data.tar.gz: '0937dacd28a350d8915e03aac407b0478e174e760eea1c00f721da8e30b96a7e'
5
5
  SHA512:
6
- metadata.gz: 8d76f67720c53e7e93e6d8a2cc903b400e914ede767b51ea054b1dcded122316b101374afdd6a673ef97a0301b9a9ace819f9c151cfe7d2becc2fa6e1f59d197
7
- data.tar.gz: 319b4c14a5bdf5f7a103c1138dcbd5885436f4de317c04699ea71c55e4bc7d062c81a45aebd04fd4729df85641e9e59bc5dd319e26263c83df0ed75bee0faae2
6
+ metadata.gz: '08fe1b21ec6ae0fe7754b133080aba32c08fde40ad1db4915a8154527191b78353a43c6dacccfc7ce22360520bf90f8b4440ddd0c7672a2dc9d488f35bd3f0a9'
7
+ data.tar.gz: cece8d087aee4bfda33d3fb36984fa3b5f55cd2995c60c7fa5ad3c32a2c10d398274263ac00d4ad72a30006bf4e4234dca0207e648bf89b53bed4a0c08beabd9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.0.0 (2024-01-10)
2
+
3
+ - Added support for multi-line commands
4
+ - Changed command serialization to JSON
5
+ - Dropped support for Ruby < 3 and Rails < 6.1
6
+
7
+ ## 0.4.1 (2023-10-31)
8
+
9
+ - Fixed error with Rails 7.1
10
+
1
11
  ## 0.4.0 (2023-02-06)
2
12
 
3
13
  - Fixed error with irb 1.4.2+
@@ -0,0 +1,14 @@
1
+ module Archer
2
+ module Coder
3
+ def self.dump(value)
4
+ JSON.generate(value)
5
+ end
6
+
7
+ def self.load(value)
8
+ JSON.parse(value, {max_nesting: 1}) unless value.nil?
9
+ rescue JSON::ParserError
10
+ # previous format
11
+ value.split("\n")
12
+ end
13
+ end
14
+ end
data/lib/archer/engine.rb CHANGED
@@ -2,6 +2,7 @@ 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
  end
7
8
  end
@@ -1,5 +1,11 @@
1
1
  module Archer
2
2
  class History < ActiveRecord::Base
3
3
  self.table_name = "archer_history"
4
+
5
+ if ActiveRecord::VERSION::STRING.to_f >= 7.1
6
+ serialize :commands, coder: Coder
7
+ else
8
+ serialize :commands, Coder
9
+ end
4
10
  end
5
11
  end
@@ -1,3 +1,3 @@
1
1
  module Archer
2
- VERSION = "0.4.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/archer.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  # dependencies
2
2
  require "active_support/core_ext/module/attribute_accessors"
3
3
 
4
+ # stdlib
5
+ require "json"
6
+
4
7
  # modules
8
+ require_relative "archer/coder"
5
9
  require_relative "archer/engine" if defined?(Rails)
6
10
  require_relative "archer/irb"
7
11
  require_relative "archer/version"
@@ -35,12 +39,15 @@ module Archer
35
39
  end
36
40
 
37
41
  if history
38
- commands = history.commands.split("\n")
42
+ commands = history.commands
39
43
  history_object.clear
40
44
  history_object.push(*commands)
41
45
  end
42
46
 
43
47
  IRB.conf[:AT_EXIT].push(proc { Archer.save if Archer.save_session })
48
+ rescue
49
+ # never prevent console from booting
50
+ warn "[archer] Error loading history"
44
51
  end
45
52
 
46
53
  def save
@@ -48,7 +55,7 @@ module Archer
48
55
 
49
56
  quietly do
50
57
  history = Archer::History.where(user: user).first_or_initialize
51
- history.commands = history_object.to_a.last(limit).join("\n")
58
+ history.commands = history_object.to_a.last(limit)
52
59
  history.save!
53
60
  end
54
61
  rescue ActiveRecord::StatementInvalid
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.0
4
+ version: 1.0.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: 2023-02-07 00:00:00.000000000 Z
11
+ date: 2024-01-10 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: '6'
19
+ version: '6.1'
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: '6'
26
+ version: '6.1'
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: '6'
33
+ version: '6.1'
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: '6'
40
+ version: '6.1'
41
41
  description:
42
42
  email: andrew@ankane.org
43
43
  executables: []
@@ -49,6 +49,7 @@ files:
49
49
  - README.md
50
50
  - lib/archer-rails.rb
51
51
  - lib/archer.rb
52
+ - lib/archer/coder.rb
52
53
  - lib/archer/engine.rb
53
54
  - lib/archer/history.rb
54
55
  - lib/archer/irb.rb
@@ -67,14 +68,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
68
  requirements:
68
69
  - - ">="
69
70
  - !ruby/object:Gem::Version
70
- version: '2.7'
71
+ version: '3'
71
72
  required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  requirements:
73
74
  - - ">="
74
75
  - !ruby/object:Gem::Version
75
76
  version: '0'
76
77
  requirements: []
77
- rubygems_version: 3.4.6
78
+ rubygems_version: 3.5.3
78
79
  signing_key:
79
80
  specification_version: 4
80
81
  summary: Rails console history for Heroku, Docker, and more