yap-shell 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.travis.lock +104 -0
- data/bin/yap +6 -0
- data/bin/yap-dev +37 -0
- data/lib/yap.rb +29 -39
- data/lib/yap/addon.rb +24 -0
- data/lib/yap/addon/base.rb +52 -0
- data/lib/yap/addon/export_as.rb +12 -0
- data/lib/yap/addon/loader.rb +84 -0
- data/lib/yap/addon/path.rb +56 -0
- data/lib/yap/addon/rc_file.rb +21 -0
- data/lib/yap/addon/reference.rb +22 -0
- data/lib/yap/cli.rb +4 -0
- data/lib/yap/cli/commands.rb +6 -0
- data/lib/yap/cli/commands/addon.rb +14 -0
- data/lib/yap/cli/commands/addon/disable.rb +35 -0
- data/lib/yap/cli/commands/addon/enable.rb +35 -0
- data/lib/yap/cli/commands/addon/list.rb +37 -0
- data/lib/yap/cli/commands/addon/search.rb +99 -0
- data/lib/yap/cli/commands/generate.rb +13 -0
- data/lib/yap/cli/commands/generate/addon.rb +258 -0
- data/lib/yap/cli/commands/generate/addonrb.template +22 -0
- data/lib/yap/cli/commands/generate/gemspec.template +25 -0
- data/lib/yap/cli/commands/generate/license.template +21 -0
- data/lib/yap/cli/commands/generate/rakefile.template +6 -0
- data/lib/yap/cli/commands/generate/readme.template +40 -0
- data/lib/yap/cli/options.rb +162 -0
- data/lib/yap/cli/options/addon.rb +64 -0
- data/lib/yap/cli/options/addon/disable.rb +62 -0
- data/lib/yap/cli/options/addon/enable.rb +63 -0
- data/lib/yap/cli/options/addon/list.rb +65 -0
- data/lib/yap/cli/options/addon/search.rb +76 -0
- data/lib/yap/cli/options/generate.rb +59 -0
- data/lib/yap/cli/options/generate/addon.rb +63 -0
- data/lib/yap/configuration.rb +10 -3
- data/lib/yap/gem_helper.rb +195 -0
- data/lib/yap/gem_tasks.rb +6 -0
- data/lib/yap/shell.rb +1 -1
- data/lib/yap/shell/repl.rb +1 -1
- data/lib/yap/shell/version.rb +1 -1
- data/lib/yap/world.rb +45 -7
- data/rcfiles/yaprc +90 -10
- data/spec/features/addons/generating_an_addon_spec.rb +55 -0
- data/spec/features/addons/using_an_addon_spec.rb +182 -0
- data/spec/features/aliases_spec.rb +6 -6
- data/spec/features/grouping_spec.rb +18 -18
- data/spec/features/line_editing_spec.rb +9 -1
- data/spec/features/redirection_spec.rb +12 -3
- data/spec/spec_helper.rb +21 -11
- data/spec/support/matchers/have_printed.rb +38 -0
- data/spec/support/yap_spec_dsl.rb +24 -6
- data/yap-shell.gemspec +6 -11
- metadata +51 -45
- data/addons/history/README.md +0 -16
- data/addons/history/history.rb +0 -58
- data/addons/history_search/history_search.rb +0 -197
- data/addons/keyboard_macros/keyboard_macros.rb +0 -425
- data/addons/keyboard_macros/lib/keyboard_macros/cycle.rb +0 -38
- data/addons/prompt/Gemfile +0 -1
- data/addons/prompt/right_prompt.rb +0 -17
- data/addons/prompt_updates/prompt_updates.rb +0 -28
- data/addons/tab_completion/Gemfile +0 -0
- data/addons/tab_completion/lib/tab_completion/basic_completion.rb +0 -151
- data/addons/tab_completion/lib/tab_completion/completer.rb +0 -62
- data/addons/tab_completion/lib/tab_completion/custom_completion.rb +0 -33
- data/addons/tab_completion/lib/tab_completion/dsl_methods.rb +0 -7
- data/addons/tab_completion/tab_completion.rb +0 -174
- data/lib/tasks/addons.rake +0 -97
- data/lib/yap/world/addons.rb +0 -181
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b745bf1643f4cc00a8863cd3bd0ea4a418f1404a
|
4
|
+
data.tar.gz: 0db3fb4d29ec34e83176c5acb7c39f27106ec027
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac7bb1a89d06d54b01084d9ac30d4603e2d383f8f294b24470749aa9946cd8cb9bb0693a24ff05828ae14a1392266d782fa4a173ea09773ab36f3a1cfbfca754
|
7
|
+
data.tar.gz: 12347f2b492455fc8b9068c229cc8efae97bdac7bafaecc5faf343ab7d4cd02040a796c3d291c92879c86a7dfde549bbed0e3603720b01ca68e52dc1fef4d3ce
|
data/Gemfile.travis.lock
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/zdennis/rawline.git
|
3
|
+
revision: 242e1946383811297b6180f327233f6d2108ae15
|
4
|
+
specs:
|
5
|
+
yap-rawline (0.5.1)
|
6
|
+
highline (~> 1.7, >= 1.7.2)
|
7
|
+
term-ansicolor (~> 1.3.0)
|
8
|
+
terminal-layout (~> 0.4.0)
|
9
|
+
treefell (~> 0.2.3)
|
10
|
+
|
11
|
+
GIT
|
12
|
+
remote: https://github.com/zdennis/terminal-layout.git
|
13
|
+
revision: 976050c3a56a2a073934d4cfec2d0aeed163e857
|
14
|
+
specs:
|
15
|
+
terminal-layout (0.4.0)
|
16
|
+
highline (~> 1.7, >= 1.7.8)
|
17
|
+
ruby-terminfo (~> 0.1.1)
|
18
|
+
ruby-termios (~> 0.9.6)
|
19
|
+
treefell (~> 0.2.3)
|
20
|
+
|
21
|
+
GIT
|
22
|
+
remote: https://github.com/zdennis/treefell.git
|
23
|
+
revision: 09e527ba07b413947d93c52a13cd5dd470d7b1fc
|
24
|
+
specs:
|
25
|
+
treefell (0.2.3)
|
26
|
+
term-ansicolor (~> 1.3)
|
27
|
+
|
28
|
+
GIT
|
29
|
+
remote: https://github.com/zdennis/yap-shell-parser.git
|
30
|
+
revision: 6b8390ecdd47b58f2550d4844e7a285cc1bbc4aa
|
31
|
+
specs:
|
32
|
+
yap-shell-parser (0.7.0)
|
33
|
+
term-ansicolor (~> 1.3.0)
|
34
|
+
treefell (~> 0.2.3)
|
35
|
+
|
36
|
+
PATH
|
37
|
+
remote: .
|
38
|
+
specs:
|
39
|
+
yap-shell (0.6.0)
|
40
|
+
chronic (~> 0.10.2)
|
41
|
+
pry-byebug (~> 3.3)
|
42
|
+
ruby-terminfo (~> 0.1.1)
|
43
|
+
ruby-termios (~> 0.9.6)
|
44
|
+
term-ansicolor (~> 1.3)
|
45
|
+
treefell (~> 0.2.3)
|
46
|
+
yap-rawline (~> 0.5.1)
|
47
|
+
yap-shell-parser (~> 0.7.0)
|
48
|
+
|
49
|
+
GEM
|
50
|
+
remote: https://rubygems.org/
|
51
|
+
specs:
|
52
|
+
byebug (9.0.5)
|
53
|
+
childprocess (0.5.9)
|
54
|
+
ffi (~> 1.0, >= 1.0.11)
|
55
|
+
chronic (0.10.2)
|
56
|
+
coderay (1.1.1)
|
57
|
+
diff-lcs (1.2.5)
|
58
|
+
ffi (1.9.10)
|
59
|
+
highline (1.7.8)
|
60
|
+
method_source (0.8.2)
|
61
|
+
pry (0.10.3)
|
62
|
+
coderay (~> 1.1.0)
|
63
|
+
method_source (~> 0.8.1)
|
64
|
+
slop (~> 3.4)
|
65
|
+
pry-byebug (3.4.0)
|
66
|
+
byebug (~> 9.0)
|
67
|
+
pry (~> 0.10)
|
68
|
+
rake (11.2.2)
|
69
|
+
rspec (3.4.0)
|
70
|
+
rspec-core (~> 3.4.0)
|
71
|
+
rspec-expectations (~> 3.4.0)
|
72
|
+
rspec-mocks (~> 3.4.0)
|
73
|
+
rspec-core (3.4.4)
|
74
|
+
rspec-support (~> 3.4.0)
|
75
|
+
rspec-expectations (3.4.0)
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
+
rspec-support (~> 3.4.0)
|
78
|
+
rspec-mocks (3.4.1)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.4.0)
|
81
|
+
rspec-support (3.4.1)
|
82
|
+
ruby-terminfo (0.1.1)
|
83
|
+
ruby-termios (0.9.6)
|
84
|
+
slop (3.6.0)
|
85
|
+
term-ansicolor (1.3.2)
|
86
|
+
tins (~> 1.0)
|
87
|
+
tins (1.10.2)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
bundler (~> 1.6)
|
94
|
+
childprocess (~> 0.5.9)
|
95
|
+
rake (~> 11)
|
96
|
+
rspec (~> 3.0)
|
97
|
+
terminal-layout!
|
98
|
+
treefell!
|
99
|
+
yap-rawline!
|
100
|
+
yap-shell!
|
101
|
+
yap-shell-parser!
|
102
|
+
|
103
|
+
BUNDLED WITH
|
104
|
+
1.12.5
|
data/bin/yap
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
ENV['PWD'] = Dir.pwd
|
4
|
+
|
3
5
|
# Start YAP with a pristine environment
|
4
6
|
env2keep = {
|
5
7
|
# DISPLAY needs to be inherited in order to launch GUI apps
|
6
8
|
'DISPLAY' => ENV['DISPLAY'],
|
7
9
|
'HOME' => ENV['HOME'],
|
8
10
|
'PATH' => ENV['PATH'],
|
11
|
+
'PWD' => ENV['PWD'],
|
9
12
|
|
10
13
|
# For Yap's sanity
|
11
14
|
'RUBYOPT' => '-rubygems -EUTF-8',
|
@@ -13,6 +16,9 @@ env2keep = {
|
|
13
16
|
# Inherit the user's preferred shell
|
14
17
|
'SHELL' => ENV['SHELL'],
|
15
18
|
|
19
|
+
# Set the logged in user
|
20
|
+
'USER' => ENV['USER'],
|
21
|
+
|
16
22
|
# Necessary for ssh-agent
|
17
23
|
'SSH_AUTH_SOCK' => ENV['SSH_AUTH_SOCK'],
|
18
24
|
|
data/bin/yap-dev
CHANGED
@@ -4,5 +4,42 @@ require 'bundler'
|
|
4
4
|
Bundler.setup
|
5
5
|
require 'pry'
|
6
6
|
|
7
|
+
module SilenceWarnings
|
8
|
+
# Runs a block of code without warnings.
|
9
|
+
def self.silence_warnings(&block)
|
10
|
+
warn_level = $VERBOSE
|
11
|
+
$VERBOSE = nil
|
12
|
+
result = block.call
|
13
|
+
$VERBOSE = warn_level
|
14
|
+
result
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
### START debundle.rb ###
|
19
|
+
|
20
|
+
# MIT License
|
21
|
+
# Copyright (c) Conrad Irwin <conrad.irwin@gmail.com>
|
22
|
+
# Copyright (c) Jan Lelis <mail@janlelis.de>
|
23
|
+
|
24
|
+
module Debundle
|
25
|
+
VERSION = '1.0.0'
|
26
|
+
|
27
|
+
def self.debundle!
|
28
|
+
if Gem.post_reset_hooks.reject!{ |hook| hook.source_location.first =~ %r{/bundler/} }
|
29
|
+
Gem.clear_paths
|
30
|
+
SilenceWarnings.silence_warnings do
|
31
|
+
load 'rubygems/core_ext/kernel_require.rb'
|
32
|
+
load 'rubygems/core_ext/kernel_gem.rb'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
rescue => e
|
36
|
+
warn "DEBUNDLE.RB FAILED: #{e.class}\n#{e.message}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Debundle.debundle!
|
41
|
+
|
42
|
+
### END debundle.rb ###
|
43
|
+
|
7
44
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
8
45
|
load File.dirname(__FILE__) + '/yap'
|
data/lib/yap.rb
CHANGED
@@ -6,57 +6,47 @@ require "treefell"
|
|
6
6
|
require 'optparse'
|
7
7
|
|
8
8
|
module Yap
|
9
|
+
require 'yap/cli/options'
|
9
10
|
require 'yap/configuration'
|
10
11
|
require 'yap/shell'
|
11
12
|
require 'yap/world'
|
12
13
|
|
13
|
-
def self.
|
14
|
-
|
15
|
-
opts.on('-h', '--help', 'Prints this help') do
|
16
|
-
puts opts
|
17
|
-
exit
|
18
|
-
end
|
19
|
-
|
20
|
-
opts.on('--skip-first-time', 'Disables creating ~/.yap directory on shell startup') do
|
21
|
-
configuration.skip_first_time = true
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on('--no-addons', 'Disables auto-loading addons on shell startup') do
|
25
|
-
configuration.use_addons = false
|
26
|
-
end
|
27
|
-
|
28
|
-
opts.on('--no-history', 'Disables auto-loading or saving history') do
|
29
|
-
configuration.use_history = false
|
30
|
-
end
|
31
|
-
|
32
|
-
opts.on('--no-rcfiles', 'Disables auto-loading rcfiles on shell startup') do
|
33
|
-
configuration.use_rcfiles = false
|
34
|
-
end
|
35
|
-
end.parse!(args)
|
14
|
+
def self.root
|
15
|
+
Pathname.new File.join(File.dirname(__FILE__), '..')
|
36
16
|
end
|
37
17
|
|
38
18
|
def self.run_shell(argv)
|
39
19
|
Treefell['shell'].puts "#{self}.#{__callee__} booting shell"
|
40
20
|
|
41
|
-
|
21
|
+
yap_options = Yap::Cli::Options.new
|
22
|
+
yap_options.parse(argv)
|
42
23
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
addons_loaded
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
24
|
+
if configuration.run_shell?
|
25
|
+
configuration.yap_binpath = File.expand_path($0)
|
26
|
+
|
27
|
+
addons_loaded = []
|
28
|
+
if configuration.use_addons?
|
29
|
+
Treefell['shell'].puts "#{self}.#{__callee__} loading addons"
|
30
|
+
addons = Yap::Addon.load_for_configuration(configuration)
|
31
|
+
addons_loaded.concat addons
|
32
|
+
else
|
33
|
+
Treefell['shell'].puts "#{self}.#{__callee__} skipping addons"
|
34
|
+
end
|
35
|
+
|
36
|
+
if configuration.use_rcfiles?
|
37
|
+
Treefell['shell'].puts "#{self}.#{__callee__} loading rcfiles"
|
38
|
+
addons_loaded.concat \
|
39
|
+
Yap::Addon.load_rcfiles(configuration.rcfiles)
|
40
|
+
else
|
41
|
+
Treefell['shell'].puts "#{self}.#{__callee__} skipping rcfiles"
|
42
|
+
end
|
51
43
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
World::Addons.load_rcfiles(configuration.rcfiles)
|
44
|
+
Shell::Impl.new(addons: addons_loaded).repl
|
45
|
+
elsif yap_options.commands.any?
|
46
|
+
yap_options.commands.last.process
|
56
47
|
else
|
57
|
-
|
48
|
+
STDERR.puts "Honestly, I don't know what you're tring to do."
|
49
|
+
exit 1
|
58
50
|
end
|
59
|
-
|
60
|
-
Shell::Impl.new(addons: addons_loaded).repl
|
61
51
|
end
|
62
52
|
end
|
data/lib/yap/addon.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'yap/addon/base'
|
2
|
+
require 'yap/addon/export_as'
|
3
|
+
require 'yap/addon/loader'
|
4
|
+
require 'yap/addon/path'
|
5
|
+
require 'yap/addon/rc_file'
|
6
|
+
require 'yap/addon/reference'
|
7
|
+
|
8
|
+
module Yap
|
9
|
+
module Addon
|
10
|
+
def self.load_rcfiles(files)
|
11
|
+
Yap::Addon::Loader.load_rcfiles(files)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.load_for_configuration(configuration)
|
15
|
+
addon_references = Yap::Addon::Path.find_for_configuration(configuration)
|
16
|
+
Yap::Addon::Loader.new(addon_references).load_all
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.export_as_for_gemspec(gemspec)
|
20
|
+
addonrb_path = File.join('lib', gemspec.name + '.rb')
|
21
|
+
ExportAs.find_in_file(addonrb_path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Yap
|
2
|
+
module Addon
|
3
|
+
class Base
|
4
|
+
def self.load_addon
|
5
|
+
@instance ||= new
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.addon_name
|
9
|
+
@addon_name ||= begin
|
10
|
+
addon_name = self.name.split(/::/)
|
11
|
+
.last.scan(/[A-Z][^A-Z]+/)
|
12
|
+
.map(&:downcase).reject{ |f| f == "addon" }
|
13
|
+
.join("_")
|
14
|
+
.to_sym
|
15
|
+
addon_name.length == 0 ? self.name : addon_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.export_as(name=nil)
|
20
|
+
if name
|
21
|
+
@export_as = name.to_sym
|
22
|
+
end
|
23
|
+
@export_as
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.logger
|
27
|
+
calling_method = caller[1][/`.*'/][1..-2]
|
28
|
+
Treefell["addon:#{export_as}"]["#{name}##{calling_method}"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def addon_name
|
32
|
+
@addon_name ||= self.class.addon_name
|
33
|
+
end
|
34
|
+
|
35
|
+
def logger
|
36
|
+
self.class.logger
|
37
|
+
end
|
38
|
+
|
39
|
+
def export_as
|
40
|
+
self.class.export_as
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize(enabled: true)
|
44
|
+
@yap_enabled = enabled
|
45
|
+
end
|
46
|
+
|
47
|
+
def yap_enabled?
|
48
|
+
@yap_enabled
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Yap
|
2
|
+
module Addon
|
3
|
+
class Loader
|
4
|
+
def initialize(addon_references)
|
5
|
+
@addon_references = addon_references
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_all
|
9
|
+
@addon_references.map do |reference|
|
10
|
+
load_reference(reference)
|
11
|
+
end.compact
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def bring_addon_into_existence(reference)
|
17
|
+
require reference.require_as
|
18
|
+
classified_name = reference.require_as.split('-').map(&:capitalize).join
|
19
|
+
unless Object.const_defined?(classified_name)
|
20
|
+
fail LoadError, "Expected #{name}.rb to load #{classified_name}, but it didn't"
|
21
|
+
end
|
22
|
+
|
23
|
+
addon = Object.const_get(classified_name)
|
24
|
+
addon_class = if addon.is_a?(Addon)
|
25
|
+
addon
|
26
|
+
elsif addon.const_defined?(:Addon)
|
27
|
+
addon.const_get(:Addon)
|
28
|
+
else
|
29
|
+
fail LoadError, "Expected gem #{name} to define a constant, but nothing was found"
|
30
|
+
end
|
31
|
+
addon_class.new enabled: reference.enabled?
|
32
|
+
end
|
33
|
+
|
34
|
+
def load_reference(reference)
|
35
|
+
begin
|
36
|
+
if Gem.path.any? { |path| reference.path.include?(path) }
|
37
|
+
load_gem reference
|
38
|
+
else
|
39
|
+
load_non_gem reference
|
40
|
+
end
|
41
|
+
rescue Exception => ex
|
42
|
+
puts Term::ANSIColor.red("Rut roh! The #{reference.name} addon failed to load.")
|
43
|
+
puts
|
44
|
+
puts ex.message
|
45
|
+
puts
|
46
|
+
puts "To uninstall this addon:"
|
47
|
+
puts
|
48
|
+
puts " gem uninstall #{reference.require_as}"
|
49
|
+
puts
|
50
|
+
puts "Note: this did not stop yap from loading, but functionality from the addon will be missing."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_gem(reference)
|
55
|
+
gem reference.require_as
|
56
|
+
bring_addon_into_existence reference
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_non_gem(reference)
|
60
|
+
lib_path = File.expand_path File.join(reference.path, 'lib')
|
61
|
+
Treefell['addon'].puts "prepending addon path to $LOAD_PATH: #{lib_path}"
|
62
|
+
$LOAD_PATH.unshift lib_path
|
63
|
+
|
64
|
+
bring_addon_into_existence reference
|
65
|
+
ensure
|
66
|
+
Treefell['addon'].puts "Removing addon #{lib_path} path from $LOAD_PATH"
|
67
|
+
$LOAD_PATH.delete(lib_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.load_rcfiles(files)
|
71
|
+
Treefell['addon'].puts %|searching for rcfiles:\n * #{files.join("\n * ")}|
|
72
|
+
files.map do |file|
|
73
|
+
if File.exists?(file)
|
74
|
+
Treefell['addon'].puts "rcfile #{file} found, loading."
|
75
|
+
RcFile.new file
|
76
|
+
else
|
77
|
+
Treefell['addon'].puts "rcfile #{file} not found, skipping."
|
78
|
+
end
|
79
|
+
end.flatten.compact
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|