nib 1.4.1 → 1.4.2

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
  SHA1:
3
- metadata.gz: 1651bb01b23fef2f4e1415fa29fdf8285a95b5a1
4
- data.tar.gz: 0c90102a53cb0e68f884e8513b71f221eb5dd6ff
3
+ metadata.gz: fcfc968d8ee13c4739cb42a5afeddd81d5c45f1b
4
+ data.tar.gz: 04db626c3a278a91cba59bfef4d2707875e326fd
5
5
  SHA512:
6
- metadata.gz: 7b84daa061d383e755522257a97bf784d6a4179b8aeafb9f98f67e8cf909815d0c582a85cd1418f686ef25707810c9b4a7d397b373bd9349b9a466ac6b88e051
7
- data.tar.gz: 68b68e21a45334ce4405fe3f20baa2cb20ea7398327e1a3bf3f12174d6e40af1dca169fe86bd3038a8df0b3d7e42fa477a47315587176ca5f0d18d01b489161f
6
+ metadata.gz: 74ac8b08e4f48246cb6b6fb401225309cb2369175f83f1e3f2c394c0cb427880bebbe1f2e9392e7dff7e022482ad3700d5898e10227581ea0558907dbea27e50
7
+ data.tar.gz: 26cceb3d695fb319555683fc00728714670c69cf3801f3d1bc9f4d7b7af3299b232a7367342451a1b8642a431a74884f68b189b18539a9743ed19913a74b2bde
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'irb/completion'
3
+ require 'irb/ext/save-history'
4
+
5
+ # irb configuration
6
+ IRB.conf[:PROMPT_MODE] = :SIMPLE
7
+ IRB.conf[:AUTO_INDENT] = true
8
+
9
+ # irb history
10
+ IRB.conf[:EVAL_HISTORY] = 10
11
+ IRB.conf[:SAVE_HISTORY] = 1000
@@ -0,0 +1,17 @@
1
+ # === CUSTOM PROMPT ===
2
+ # This prompt shows the ruby version (useful for RVM)
3
+ Pry.prompt = [
4
+ proc { |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} > " },
5
+ proc { |obj, nest_level, _| "#{RUBY_VERSION} (#{obj}):#{nest_level} * " }
6
+ ]
7
+
8
+ # === Listing config ===
9
+ # Better colors - by default the headings for methods are too
10
+ # similar to method name colors leading to a "soup"
11
+ # These colors are optimized for use with Solarized scheme
12
+ # for your terminal
13
+ Pry.config.ls.separator = "\n" # new lines between methods
14
+ Pry.config.ls.heading_color = :magenta
15
+ Pry.config.ls.public_method_color = :green
16
+ Pry.config.ls.protected_method_color = :yellow
17
+ Pry.config.ls.private_method_color = :bright_black
data/lib/nib.rb CHANGED
@@ -27,4 +27,8 @@ module Nib
27
27
  def load_config(command, file_name)
28
28
  File.read("#{GEM_ROOT}/config/commands/#{command}/#{file_name}")
29
29
  end
30
+
31
+ def load_default_config(command, file_name)
32
+ load_config(command, file_name)
33
+ end
30
34
  end
data/lib/nib/history.rb CHANGED
@@ -1,32 +1,62 @@
1
- module Nib::History
2
- IRBRC = <<-'IRB'.freeze
3
- require \"rubygems\"
4
- require \"irb/completion\"
5
- require \"irb/ext/save-history\"
6
- # irb configuration
7
- IRB.conf[:PROMPT_MODE] = :SIMPLE
8
- IRB.conf[:AUTO_INDENT] = true
9
- # irb history
10
- IRB.conf[:EVAL_HISTORY] = 10
11
- IRB.conf[:SAVE_HISTORY] = 1000
12
- IRB.conf[:HISTORY_FILE] = \"#{Dir.pwd}/tmp/irb_history\"
13
- IRB
14
-
15
- PRYRC = 'Pry.config.history.file = \"#{Dir.pwd}/tmp/irb_history\"'.freeze
16
-
17
- def execute
18
- system('mkdir', '-p', './tmp')
19
- super
20
- end
1
+ require 'fileutils'
21
2
 
3
+ module Nib::History
22
4
  def command
23
5
  <<-COMMAND
24
6
  /bin/sh -c \"
25
7
  export HISTFILE=./tmp/shell_history
26
- echo '#{IRBRC}' > /root/.irbrc
27
- echo '#{PRYRC}' > /root/.pryrc
8
+ cp #{irbrc.container_path} /root/.irbrc 2>/dev/null
9
+ cp #{pryrc.container_path} /root/.pryrc 2>/dev/null
28
10
  #{super}
29
11
  \"
30
12
  COMMAND
31
13
  end
14
+
15
+ def irbrc
16
+ @irbrc ||= Config.new(
17
+ :irbrc,
18
+ 'IRB.conf[:HISTORY_FILE] = "#{Dir.pwd}/tmp/irb_history"'
19
+ )
20
+ end
21
+
22
+ def pryrc
23
+ @pryrc ||= Config.new(
24
+ :pryrc,
25
+ 'Pry.config.history.file = "#{Dir.pwd}/tmp/irb_history"'
26
+ )
27
+ end
28
+
29
+ class Config
30
+ attr_reader :type, :history_command, :host_path
31
+
32
+ def initialize(type, history_command)
33
+ @type = type
34
+ @history_command = history_command
35
+ @host_path = "#{ENV['HOME']}/.#{type}"
36
+
37
+ FileUtils.mkdir_p './tmp'
38
+ end
39
+
40
+ def container_path
41
+ config_file.path
42
+ end
43
+
44
+ private
45
+
46
+ def config
47
+ if File.exist?(host_path)
48
+ File.read(host_path)
49
+ else
50
+ Nib.load_default_config(:shell, type)
51
+ end
52
+ end
53
+
54
+ def config_file
55
+ @config_file ||= File.open("./tmp/#{type}", 'w+') do |file|
56
+ file.write(config)
57
+ file.write(history_command + "\n")
58
+ file
59
+ end
60
+ end
61
+ end
32
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-21 00:00:00.000000000 Z
12
+ date: 2017-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
@@ -150,6 +150,8 @@ files:
150
150
  - bin/nib
151
151
  - config/commands.json
152
152
  - config/commands/codeclimate/docker-compose.yml
153
+ - config/commands/shell/irbrc
154
+ - config/commands/shell/pryrc
153
155
  - config/options.yml
154
156
  - lib/core_extensions/hash.rb
155
157
  - lib/nib.rb