archer-rails 0.1.1 → 0.2.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: 83355041e7d4db676c39d7578272e2ad5b1f485a1d3ce93f19c0ecf997afc270
4
- data.tar.gz: 6dbafdf30bdd43a6866b25f137f3e9c23218d6f756b7f1e31a37f07cf321f5b2
3
+ metadata.gz: 7efb1ead011d342fecc5b05028013de7a07fd101bbda3610b67f11d2707b8e59
4
+ data.tar.gz: 26e4472b7a6e5402a4319fd148d4b921225b19cd4d47215a1f6e45b20d1300d1
5
5
  SHA512:
6
- metadata.gz: 2b4638dcf53e8b2fc7883a992ae5a2234406298ebd7cb2a8d3a4eaf78e06fb81eb80cc7c892b7f8996c4785e7b60a55b702d85655587f4ee4989c7bff4f72f25
7
- data.tar.gz: 4e2da0efaa2218f940ec22d62ef20d5f0747a1b5e63fe15189860306013cbb736440b96bec783d4774bdf5e5886218d908faaaeb60bf2ac5ae1be500a994456d
6
+ metadata.gz: 452c0c2b502e99e1d88694751ab538cab0134193ecff8de09ae27adc130cb37ab488162d48998c4e935165cf18c9c517298c7c33a04c89c4156a5ce997ac449e
7
+ data.tar.gz: 7adbb6348c77d01d5a3e9ddf5bd61ef4071e54f1a5b2018d7b877f67b04a05160025852408498a2fff6fa25d45cf4c38b4663135708fa517af9569844f9e0784
@@ -1,7 +1,12 @@
1
- ## 0.1.1
1
+ ## 0.2.0 (2020-04-09)
2
+
3
+ - Added support for Reline
4
+ - Dropped support for Rails 4.2
5
+
6
+ ## 0.1.1 (2018-10-23)
2
7
 
3
8
  - Fixed issue with not loading history on Heroku
4
9
 
5
- ## 0.1.0
10
+ ## 0.1.0 (2018-10-23)
6
11
 
7
12
  - First release
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Andrew Kane
3
+ Copyright (c) 2018-2019 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
@@ -59,6 +59,8 @@ Clear history for current user with:
59
59
  Archer.clear
60
60
  ```
61
61
 
62
+ You should do this after running sensitive commands.
63
+
62
64
  ## Configuration
63
65
 
64
66
  Change the number of commands to remember
@@ -105,3 +107,11 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
105
107
  - Fix bugs and [submit pull requests](https://github.com/ankane/archer/pulls)
106
108
  - Write, clarify, or fix documentation
107
109
  - Suggest or add new features
110
+
111
+ To get started with development:
112
+
113
+ ```sh
114
+ git clone https://github.com/ankane/archer.git
115
+ cd archer
116
+ bundle install
117
+ ```
@@ -20,7 +20,8 @@ module Archer
20
20
  quietly do
21
21
  Archer::History.where(user: user).delete_all
22
22
  end
23
- Readline::HISTORY.clear
23
+ Readline::HISTORY.clear if defined?(Readline)
24
+ Reline::HISTORY.clear if defined?(Reline)
24
25
  true
25
26
  end
26
27
 
@@ -35,20 +36,35 @@ module Archer
35
36
  end
36
37
 
37
38
  if history
38
- Readline::HISTORY.push(*history.commands.split("\n"))
39
+ commands = history.commands.split("\n")
40
+ # can't use reline? yet, so push to all
41
+ Readline::HISTORY.push(*commands) if defined?(Readline)
42
+ Reline::HISTORY.push(*commands) if defined?(Reline)
39
43
  end
40
44
  end
41
45
 
42
46
  def self.save
43
47
  quietly do
44
48
  history = Archer::History.where(user: user).first_or_initialize
45
- history.commands = Readline::HISTORY.to_a.last(limit).join("\n")
46
- history.save
49
+ history.commands = history_object.to_a.last(limit).join("\n")
50
+ history.save!
47
51
  end
48
52
  rescue ActiveRecord::StatementInvalid
49
53
  warn "[archer] Unable to save history"
50
54
  end
51
55
 
56
+ # private
57
+ def self.history_object
58
+ reline? ? Reline::HISTORY : Readline::HISTORY
59
+ end
60
+
61
+ # private
62
+ def self.reline?
63
+ IRB.CurrentContext.io.is_a?(IRB::ReidlineInputMethod)
64
+ rescue
65
+ false
66
+ end
67
+
52
68
  # private
53
69
  def self.quietly
54
70
  ActiveRecord::Base.logger.silence do
@@ -1,3 +1,3 @@
1
1
  module Archer
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,37 +1,17 @@
1
- # taken from https://github.com/collectiveidea/audited/blob/master/lib/generators/audited/install_generator.rb
2
- require "rails/generators"
3
- require "rails/generators/migration"
4
- require "active_record"
5
1
  require "rails/generators/active_record"
6
2
 
7
3
  module Archer
8
4
  module Generators
9
5
  class InstallGenerator < Rails::Generators::Base
10
- include Rails::Generators::Migration
11
- source_root File.expand_path("../templates", __FILE__)
12
-
13
- # Implement the required interface for Rails::Generators::Migration.
14
- def self.next_migration_number(dirname) #:nodoc:
15
- next_migration_number = current_migration_number(dirname) + 1
16
- if ::ActiveRecord::Base.timestamped_migrations
17
- [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
18
- else
19
- "%.3d" % next_migration_number
20
- end
21
- end
6
+ include ActiveRecord::Generators::Migration
7
+ source_root File.join(__dir__, "templates")
22
8
 
23
9
  def copy_migration
24
10
  migration_template "migration.rb", "db/migrate/create_archer_history.rb", migration_version: migration_version
25
11
  end
26
12
 
27
13
  def migration_version
28
- if rails5?
29
- "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
30
- end
31
- end
32
-
33
- def rails5?
34
- Rails::VERSION::MAJOR >= 5
14
+ "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
35
15
  end
36
16
  end
37
17
  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.1.1
4
+ version: 0.2.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: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '5'
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: '4.2'
26
+ version: '5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,15 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: '2.2'
97
+ version: '2.4'
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.7.7
104
+ rubygems_version: 3.1.2
106
105
  signing_key:
107
106
  specification_version: 4
108
107
  summary: Rails console history for Heroku, Docker, and more