yap-shell 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -24
  3. data/Gemfile +1 -5
  4. data/LICENSE.txt +17 -18
  5. data/README.md +28 -14
  6. data/Rakefile +4 -1
  7. data/bin/yap +1 -3
  8. data/lib/.gitkeep +0 -0
  9. data/yap-shell.gemspec +12 -11
  10. metadata +19 -184
  11. data/.rspec +0 -2
  12. data/.travis.yml +0 -11
  13. data/DESIGN.md +0 -87
  14. data/Gemfile.travis +0 -8
  15. data/Gemfile.travis.lock +0 -104
  16. data/WISHLIST.md +0 -54
  17. data/bin/yap-dev +0 -45
  18. data/lib/tasks/gem.rake +0 -62
  19. data/lib/yap.rb +0 -52
  20. data/lib/yap/addon.rb +0 -24
  21. data/lib/yap/addon/base.rb +0 -52
  22. data/lib/yap/addon/export_as.rb +0 -12
  23. data/lib/yap/addon/loader.rb +0 -84
  24. data/lib/yap/addon/path.rb +0 -56
  25. data/lib/yap/addon/rc_file.rb +0 -21
  26. data/lib/yap/addon/reference.rb +0 -22
  27. data/lib/yap/cli.rb +0 -4
  28. data/lib/yap/cli/commands.rb +0 -6
  29. data/lib/yap/cli/commands/addon.rb +0 -14
  30. data/lib/yap/cli/commands/addon/disable.rb +0 -35
  31. data/lib/yap/cli/commands/addon/enable.rb +0 -35
  32. data/lib/yap/cli/commands/addon/list.rb +0 -37
  33. data/lib/yap/cli/commands/addon/search.rb +0 -99
  34. data/lib/yap/cli/commands/generate.rb +0 -13
  35. data/lib/yap/cli/commands/generate/addon.rb +0 -258
  36. data/lib/yap/cli/commands/generate/addonrb.template +0 -22
  37. data/lib/yap/cli/commands/generate/gemspec.template +0 -25
  38. data/lib/yap/cli/commands/generate/license.template +0 -21
  39. data/lib/yap/cli/commands/generate/rakefile.template +0 -6
  40. data/lib/yap/cli/commands/generate/readme.template +0 -40
  41. data/lib/yap/cli/options.rb +0 -162
  42. data/lib/yap/cli/options/addon.rb +0 -64
  43. data/lib/yap/cli/options/addon/disable.rb +0 -62
  44. data/lib/yap/cli/options/addon/enable.rb +0 -63
  45. data/lib/yap/cli/options/addon/list.rb +0 -65
  46. data/lib/yap/cli/options/addon/search.rb +0 -76
  47. data/lib/yap/cli/options/generate.rb +0 -59
  48. data/lib/yap/cli/options/generate/addon.rb +0 -63
  49. data/lib/yap/configuration.rb +0 -74
  50. data/lib/yap/gem_helper.rb +0 -195
  51. data/lib/yap/gem_tasks.rb +0 -6
  52. data/lib/yap/shell.rb +0 -116
  53. data/lib/yap/shell/aliases.rb +0 -58
  54. data/lib/yap/shell/builtins.rb +0 -18
  55. data/lib/yap/shell/builtins/alias.rb +0 -42
  56. data/lib/yap/shell/builtins/cd.rb +0 -57
  57. data/lib/yap/shell/builtins/env.rb +0 -11
  58. data/lib/yap/shell/commands.rb +0 -163
  59. data/lib/yap/shell/evaluation.rb +0 -439
  60. data/lib/yap/shell/evaluation/shell_expansions.rb +0 -99
  61. data/lib/yap/shell/event_emitter.rb +0 -18
  62. data/lib/yap/shell/execution.rb +0 -16
  63. data/lib/yap/shell/execution/builtin_command_execution.rb +0 -20
  64. data/lib/yap/shell/execution/command_execution.rb +0 -30
  65. data/lib/yap/shell/execution/context.rb +0 -128
  66. data/lib/yap/shell/execution/file_system_command_execution.rb +0 -137
  67. data/lib/yap/shell/execution/result.rb +0 -18
  68. data/lib/yap/shell/execution/ruby_command_execution.rb +0 -80
  69. data/lib/yap/shell/execution/shell_command_execution.rb +0 -30
  70. data/lib/yap/shell/prompt.rb +0 -21
  71. data/lib/yap/shell/repl.rb +0 -237
  72. data/lib/yap/shell/version.rb +0 -5
  73. data/lib/yap/world.rb +0 -286
  74. data/rcfiles/yaprc +0 -390
  75. data/scripts/4 +0 -8
  76. data/scripts/bg-vim +0 -4
  77. data/scripts/fail +0 -3
  78. data/scripts/letters +0 -8
  79. data/scripts/lots-of-output +0 -6
  80. data/scripts/pass +0 -3
  81. data/scripts/simulate-long-running +0 -4
  82. data/scripts/write-to-stderr.rb +0 -3
  83. data/scripts/write-to-stdout.rb +0 -3
  84. data/spec/features/addons/generating_an_addon_spec.rb +0 -55
  85. data/spec/features/addons/using_an_addon_spec.rb +0 -182
  86. data/spec/features/aliases_spec.rb +0 -78
  87. data/spec/features/environment_variables_spec.rb +0 -69
  88. data/spec/features/filesystem_commands_spec.rb +0 -61
  89. data/spec/features/first_time_spec.rb +0 -45
  90. data/spec/features/grouping_spec.rb +0 -81
  91. data/spec/features/line_editing_spec.rb +0 -174
  92. data/spec/features/range_spec.rb +0 -35
  93. data/spec/features/redirection_spec.rb +0 -234
  94. data/spec/features/repetition_spec.rb +0 -118
  95. data/spec/features/shell_expansions_spec.rb +0 -127
  96. data/spec/spec_helper.rb +0 -172
  97. data/spec/support/matchers/have_not_printed.rb +0 -30
  98. data/spec/support/matchers/have_printed.rb +0 -68
  99. data/spec/support/very_soon.rb +0 -9
  100. data/spec/support/yap_spec_dsl.rb +0 -258
  101. data/test.rb +0 -206
  102. data/update-rawline.sh +0 -6
@@ -1,52 +0,0 @@
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
@@ -1,12 +0,0 @@
1
- module Yap
2
- module Addon
3
- module ExportAs
4
- def self.find_in_file(path)
5
- export_as = File.read(path).
6
- scan(/export_as\(?\s*:?(['"]?)(.*)\1/).
7
- flatten.
8
- last
9
- end
10
- end
11
- end
12
- end
@@ -1,84 +0,0 @@
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
@@ -1,56 +0,0 @@
1
- module Yap
2
- module Addon
3
- class Path
4
- def self.find_for_configuration(configuration)
5
- addons_config_hsh = {}
6
- if File.exists?(configuration.yap_addons_configuration_path)
7
- addons_config_hsh = YAML.load_file(configuration.yap_addons_configuration_path)
8
- end
9
-
10
- new(configuration.addon_paths.flatten, addons_config_hsh).
11
- references.sort_by(&:name)
12
- end
13
-
14
- attr_reader :references
15
-
16
- def initialize(paths, addons_config_hsh={})
17
- @paths = paths
18
- @addons_config_hsh = addons_config_hsh
19
- end
20
-
21
- def references
22
- @references ||= search_for_addons
23
- end
24
-
25
- private
26
-
27
- def search_for_addons
28
- @paths.each_with_object([]) do |path, results|
29
- Dir["#{path}/*"].map do |directory|
30
- next unless File.directory?(directory)
31
-
32
- if File.basename(directory) =~ /(yap-shell-addon-(.*))-\d+\.\d+\.\d+/
33
- require_as, name = $1, $2
34
-
35
- addonrb_path = directory + "/lib/" + require_as + ".rb"
36
- export_as = ExportAs.find_in_file(addonrb_path)
37
- name = export_as if export_as
38
- name = name.to_sym
39
-
40
- enabled = !@addons_config_hsh.fetch(
41
- name, { disabled: false }
42
- )[:disabled]
43
-
44
- results << Yap::Addon::Reference.new(
45
- name: name,
46
- require_as: require_as,
47
- path: File.expand_path(directory),
48
- enabled: enabled
49
- )
50
- end
51
- end
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,21 +0,0 @@
1
- module Yap
2
- module Addon
3
- class RcFile < Yap::Addon::Base
4
- attr_reader :file
5
-
6
- def initialize(file)
7
- super(enabled: true)
8
- @file = File.expand_path(file)
9
- end
10
-
11
- def addon_name
12
- @file
13
- end
14
-
15
- def initialize_world(world)
16
- Treefell['shell'].puts "initializing rcfile: #{file}"
17
- world.instance_eval File.read(@file), @file
18
- end
19
- end
20
- end
21
- end
@@ -1,22 +0,0 @@
1
- module Yap
2
- module Addon
3
- class Reference
4
- attr_reader :name, :require_as, :path
5
-
6
- def initialize(name:, require_as:, path:, enabled: true)
7
- @name = name
8
- @require_as = require_as
9
- @path = path
10
- @enabled = enabled
11
- end
12
-
13
- def disabled?
14
- !@enabled
15
- end
16
-
17
- def enabled?
18
- @enabled
19
- end
20
- end
21
- end
22
- end
@@ -1,4 +0,0 @@
1
- module Yap
2
- module Cli
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module Yap
2
- module Cli
3
- module Commands
4
- end
5
- end
6
- end
@@ -1,14 +0,0 @@
1
- module Yap
2
- module Cli
3
- module Commands
4
- class Addon
5
- def initialize(addon_name)
6
- @addon_name = addon_name
7
- end
8
-
9
- def process
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,35 +0,0 @@
1
- module Yap
2
- module Cli
3
- module Commands
4
- class Addon::Disable
5
- def initialize(addon_name)
6
- @addon_name = addon_name
7
- end
8
-
9
- def process
10
- configuration = Yap.configuration
11
- addon_refs = Yap::Addon::Path.find_for_configuration(configuration)
12
- addon_config_hsh = {}
13
- found_addon_ref = nil
14
- addon_refs.each do |addon_ref|
15
- is_disabled = addon_ref.disabled?
16
- if addon_ref.name.to_s == @addon_name.to_s
17
- is_disabled = true
18
- found_addon_ref = addon_ref
19
- end
20
- addon_config_hsh[addon_ref.name] = { disabled: is_disabled }
21
- end
22
-
23
- if found_addon_ref
24
- destination = configuration.yap_addons_configuration_path.to_s
25
- FileUtils.mkdir_p File.dirname(destination)
26
- File.write destination, addon_config_hsh.to_yaml
27
- puts "Addon #{found_addon_ref.name} has been disabled"
28
- else
29
- puts "Could not find addon with name #{@addon_name}"
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- module Yap
2
- module Cli
3
- module Commands
4
- class Addon::Enable
5
- def initialize(addon_name)
6
- @addon_name = addon_name
7
- end
8
-
9
- def process
10
- configuration = Yap.configuration
11
- addon_refs = Yap::Addon::Path.find_for_configuration(configuration)
12
- addon_config_hsh = {}
13
- found_addon_ref = nil
14
- addon_refs.each do |addon_ref|
15
- is_disabled = addon_ref.disabled?
16
- if addon_ref.name.to_s == @addon_name.to_s
17
- is_disabled = false
18
- found_addon_ref = addon_ref
19
- end
20
- addon_config_hsh[addon_ref.name] = { disabled: is_disabled }
21
- end
22
-
23
- if found_addon_ref
24
- destination = configuration.yap_addons_configuration_path.to_s
25
- FileUtils.mkdir_p File.dirname(destination)
26
- File.write destination, addon_config_hsh.to_yaml
27
- puts "Addon #{found_addon_ref.name} has been enabled"
28
- else
29
- puts "Could not find addon with name #{@addon_name}"
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,37 +0,0 @@
1
- module Yap
2
- module Cli
3
- module Commands
4
- class Addon::List
5
- def filter=(filter_kind)
6
- @filter = filter_kind
7
- end
8
-
9
- def process
10
- configuration = Yap.configuration
11
-
12
- addon_refs = ::Yap::Addon::Path.
13
- find_for_configuration(configuration)
14
- if addon_refs.empty?
15
- puts <<-MSG.strip_heredoc
16
- |No addons found searching paths:
17
- | - #{configuration.addon_paths.join("\n -")}
18
- MSG
19
- elsif @filter == :enabled
20
- addon_refs.select(&:enabled?).each do |addon_ref|
21
- puts "#{addon_ref.name}"
22
- end
23
- elsif @filter == :disabled
24
- addon_refs.select(&:disabled?).each do |addon_ref|
25
- puts "#{addon_ref.name}"
26
- end
27
- else
28
- addon_refs.each do |addon_ref|
29
- enabled_or_disabled = addon_ref.enabled? ? 'enabled' : 'disabled'
30
- puts "#{addon_ref.name} (#{enabled_or_disabled})"
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,99 +0,0 @@
1
- module Yap
2
- module Cli
3
- module Commands
4
- class Addon::Search
5
- attr_accessor :all, :local, :prerelease, :search_term, :version
6
- attr_accessor :show_gem_name
7
-
8
- def process
9
- options = []
10
-
11
- if search_term.nil?
12
- puts "No addons found. Please provide a search term."
13
- end
14
-
15
- options << '--all' if all
16
- options << '--local' if local
17
- options << '--prerelease' if prerelease
18
- options << "--version #{version}" if version
19
-
20
- print_addons gem_search(options)
21
- end
22
-
23
- def extract_gem_names_from_search(search_results)
24
- search_results.lines.map(&:chomp).map do |line|
25
- results = line.scan(/^(yap-shell-addon-(\S+))\s*\((\d+\.\d+\.\d+)\)/)
26
- gem_name, _, _ = results.flatten
27
- gem_name
28
- end.compact
29
- end
30
-
31
- def gem_search(options)
32
- search_results = `gem search #{options.join(' ')} yap-shell | grep #{search_term}`
33
- gem_names = extract_gem_names_from_search search_results
34
- gem_specs_for_gems gem_names
35
- end
36
-
37
- def gem_specs_for_gems(gem_names)
38
- options = []
39
- options << (local ? '-l' : '-r')
40
- options << "--version #{version}" if version
41
- gem_names.map do |gem_name|
42
- YAML.load `gem spec #{options.join(' ')} #{gem_name}`
43
- end
44
- end
45
-
46
- def print_addons(gemspecs)
47
- headers = {
48
- name: (show_gem_name ? "Rubygem" : "Addon Name"),
49
- version: "Version",
50
- date: "Date Released",
51
- author: "Author",
52
- summary: "Summary"
53
- }
54
- value_for = {
55
- name: -> (s) {
56
- if show_gem_name
57
- s.name
58
- else
59
- s.name.scan(/^yap-shell-addon-(\S+)/).flatten.first
60
- end
61
- },
62
- version: -> (s) { s.version.to_s },
63
- date: -> (s) { s.date.to_date.to_s },
64
- author: -> (s) { s.author },
65
- summary: -> (s) { s.summary }
66
- }
67
-
68
- longest = {
69
- name: gemspecs.map{ |s| value_for[:name].call(s) }.concat(Array(headers[:name])).map(&:length).max,
70
- version: gemspecs.map{ |s| value_for[:version].call(s) }.concat(Array(headers[:version])).map(&:length).max,
71
- date: gemspecs.map{ |s| value_for[:date].call(s) }.concat(Array(headers[:date])).map(&:length).max,
72
- author: gemspecs.map{ |s| value_for[:author].call(s) }.concat(Array(headers[:author])).map(&:length).max,
73
- summary: gemspecs.map{ |s| value_for[:summary].call(s) }.concat(Array(headers[:summary])).map(&:length).max
74
- }
75
-
76
- spacing = " "
77
- format_string = longest.reduce([]) do |str, (key, maxlength)|
78
- str << "%-#{maxlength}s"
79
- end.join(spacing)
80
-
81
- output = gemspecs.map do |gemspec|
82
- values = longest.keys.map { |key| value_for[key].call(gemspec) }
83
- sprintf "#{format_string}", *values
84
- end
85
- output = output.join("\n")
86
-
87
- highlighted_output = output.gsub(/(#{Regexp.escape(search_term)})/) do
88
- Term::ANSIColor.cyan($1)
89
- end
90
-
91
- puts Term::ANSIColor.bright_black(
92
- sprintf("#{format_string}", *longest.keys.map { |key| headers[key] })
93
- )
94
- puts highlighted_output
95
- end
96
- end
97
- end
98
- end
99
- end