ripl-fresh 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Fresh Ruby Enhanced SHell
2
2
 
3
- We love Ruby. We love the command line. So... the shell needs to be rubyfied ;).
3
+ We love Ruby. And we love the command line. So... the shell needs to be rubyfied ;).
4
4
 
5
5
  == How does it work?
6
6
 
@@ -22,6 +22,8 @@ Start it with:
22
22
 
23
23
  == Usage & configuration options
24
24
 
25
+ For an example session, see {this blog entry}[http://rbjl.net/43-use-fresh-ruby-as-your-shell].
26
+
25
27
  The main regexp to determine if the command should be interpreted as system command is similar to this one: <tt>/^[a-z_-]+\s+.*/i</tt> (match a single word followed by at least one space). It can be adjusted in <tt>Ripl.config[:fresh_system_regexp]</tt>.
26
28
 
27
29
  Of course, there are also exceptions that should still get interpreted as Ruby (e.g. <tt>def </tt>). These can be found and modified in the <tt>Ripl.config[:fresh_ruby_words]</tt> array.
@@ -69,6 +71,11 @@ There are lots of things which can get better:
69
71
 
70
72
  Feel free to fork in your improvements ;)
71
73
 
74
+ == Other gems you might find interesting
75
+
76
+ * {rush}[https://github.com/adamwiggins/rush] - Another Ruby shell, different concept
77
+ * {ripl}[https://github.com/cldwalker/ripl] - An irb alternative, +fresh+ is based on it
78
+
72
79
  == Copyright
73
80
 
74
81
  Copyright (c) 2010 Jan Lelis <http://code-needs-smileys.com> released under the MIT license.
@@ -1,5 +1,5 @@
1
1
  # no advanced auto completion, yet
2
- # only do some file completion - because it's the most important completion ;)
2
+ # todo: not only default options
3
3
 
4
4
  require 'readline'
5
5
 
@@ -7,11 +7,17 @@ file_completion = proc{ |input|
7
7
  ::Readline::FILENAME_COMPLETION_PROC.call(input) || []
8
8
  }
9
9
 
10
- complete :on => Ripl.config[:fresh_system_regexp],
11
- :search=>false,
10
+ system_command_completion = proc{ Ripl.config[:fresh_system_words] }
11
+
12
+ #everything_completion = proc{}
13
+
14
+ complete :on => Ripl.config[:fresh_match_regexp],
15
+ :search => false,
12
16
  &file_completion
13
17
 
14
18
  # TODO fires only when space after ^
15
19
  complete :on => Ripl::Fresh.option_array_to_regexp( Ripl.config[:fresh_system_prefix] ),
16
- :search=>false,
17
- &file_completion
20
+ # :search => false,
21
+ &system_command_completion
22
+
23
+ # J-_-L
data/lib/ripl/fresh.rb CHANGED
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
 
4
4
  module Ripl
5
5
  module Fresh
6
- VERSION = '0.1.0'
6
+ VERSION = '0.1.1'
7
7
 
8
8
  class << self
9
9
  # helper to parse options
@@ -31,8 +31,6 @@ module Ripl
31
31
  # register bond completion
32
32
  Ripl.config[:completion][:gems] ||= []
33
33
  Ripl.config[:completion][:gems] << 'ripl-fresh'
34
- # load :mixed commands
35
- require File.dirname(__FILE__) + '/fresh/commands'
36
34
  end
37
35
 
38
36
  # determine @command_mode
@@ -50,30 +48,20 @@ module Ripl
50
48
  when Ripl::Fresh.option_array_to_regexp( Ripl.config[:fresh_ruby_prefix] )
51
49
  input = input[$1.size..-1]
52
50
  :ruby
53
- # single words
54
- when /^\w+$/i
55
- if Ripl.config[:fresh_ruby_words].include?($&)
51
+ # single words, and main regex to match shell commands
52
+ when /^(\w+)$/i, Ripl.config[:fresh_match_regexp]
53
+ if Ripl.config[:fresh_ruby_words].include?($1)
56
54
  :ruby
57
- elsif Ripl.config[:fresh_mixed_words].include?($&)
55
+ elsif Ripl.config[:fresh_mixed_words].include?($1)
58
56
  :mixed
59
- elsif Ripl.config[:fresh_system_words].include?($&)
57
+ elsif Ripl.config[:fresh_system_words].include?($1)
60
58
  :system
61
59
  else
62
- :ruby
63
- end
64
- # set of commands that call the ruby method but have command line style calling (args without "")
65
- when Ripl::Fresh.option_array_to_regexp( Ripl.config[:fresh_mixed_words] )
66
- :mixed
67
- # here is the important magical regex for shell commands
68
- when Ripl.config[:fresh_system_regexp]
69
- if Ripl.config[:fresh_ruby_words].include? $1
70
- :ruby
71
- else
72
- :system
60
+ Ripl.config[:fresh_match_default]
73
61
  end
74
62
  # default is still ruby ;)
75
63
  else
76
- :ruby
64
+ Ripl.config[:fresh_default]
77
65
  end
78
66
 
79
67
  input
@@ -134,18 +122,28 @@ Ripl.config[:readline] = false
134
122
  require 'ripl/readline'
135
123
  Ripl::Shell.send :include, Ripl::Fresh::Shell
136
124
 
125
+ # load :mixed commands
126
+ require File.dirname(__FILE__) + '/fresh/commands'
127
+
137
128
  ## fresh config ###
138
129
 
139
130
  # prefixes
140
131
  Ripl.config[:fresh_system_prefix] = %w[^]
141
132
  Ripl.config[:fresh_ruby_prefix] = [' ']
142
133
  # single words
143
- Ripl.config[:fresh_system_words] = %w[top ls]
144
- Ripl.config[:fresh_ruby_words] = %w[begin case class def for if module undef unless until while puts warn print p pp ap raise fail loop require load lambda proc system]
134
+ Ripl.config[:fresh_ruby_words] = %w[begin case class def for if module undef unless until while puts warn print p pp ap raise fail loop require load lambda proc system]
135
+ Ripl.config[:fresh_system_words] =
136
+ ENV['PATH'].split(File::PATH_SEPARATOR).uniq.map {|e|
137
+ File.directory?(e) ? Dir.entries(e) : []
138
+ }.flatten.uniq - ['.', '..']
145
139
  # catch mix words
146
- Ripl.config[:fresh_mixed_words] = %w[cd]
140
+ Ripl.config[:fresh_mixed_words] = %w[cd]
147
141
  # main regexp
148
- Ripl.config[:fresh_system_regexp] = /^([a-z_-]+)\s+(?!(?:[=%*]|!=|\+=|-=|\/=))/i
142
+ Ripl.config[:fresh_match_regexp] = /^([a-z_-]+)\s+(?!(?:[=%*]|!=|\+=|-=|\/=))/i
143
+ # regex matched but word not in one of the three arrays, possible values: :ruby, :system, :mixed
144
+ Ripl.config[:fresh_match_default] = :ruby
145
+ # regex did not match
146
+ Ripl.config[:fresh_default] = :ruby
149
147
  # configure directory prompt
150
148
  Ripl.config[:prompt] = proc{
151
149
  path = FileUtils.pwd
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Lelis
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-24 00:00:00 +01:00
17
+ date: 2010-11-25 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency