[macruby-changes] [4881] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Nov 4 11:17:51 PDT 2010


Revision: 4881
          http://trac.macosforge.org/projects/ruby/changeset/4881
Author:   eloy.de.enige at gmail.com
Date:     2010-11-04 11:17:48 -0700 (Thu, 04 Nov 2010)
Log Message:
-----------
Update DietRB to 0.6.0 which adds auto-indentation and file path completion in strings.

Modified Paths:
--------------
    MacRuby/trunk/lib/irb/ext/completion.rb
    MacRuby/trunk/lib/irb/version.rb
    MacRuby/trunk/spec/dietrb/ext/completion_spec.rb

Modified: MacRuby/trunk/lib/irb/ext/completion.rb
===================================================================
--- MacRuby/trunk/lib/irb/ext/completion.rb	2010-11-04 14:06:42 UTC (rev 4880)
+++ MacRuby/trunk/lib/irb/ext/completion.rb	2010-11-04 18:17:48 UTC (rev 4881)
@@ -113,15 +113,28 @@
         end
         
         result = if call
-                   if m = (methods || methods_of_object(root))
-                     format_methods(receiver, m, filter)
-                   end
-                 else
-                   match_methods_vars_or_consts_in_scope(root)
-                 end
+          if m = (methods || methods_of_object(root))
+            format_methods(receiver, m, filter)
+          end
+        elsif root[TYPE] == :string_literal && root[VALUE][TYPE] == :string_content
+          # in the form of: "~/code/
+          expand_path(source)
+        else
+          match_methods_vars_or_consts_in_scope(root)
+        end
         result.sort.uniq if result
       end
     end
+
+    def expand_path(source)
+      tokens         = Ripper.lex(source)
+      path           = tokens[0][2]
+      string_open    = tokens[1][2]
+      end_with_slash = path.length > 1 && path.end_with?('/')
+      path           = File.expand_path(path)
+      path          << '/' if end_with_slash
+      Dir.glob("#{path}*", File::FNM_CASEFOLD).map { |f| "#{string_open}#{f}" }
+    end
     
     def unwind_callstack(root, stack = [])
       if root[TYPE] == :call

Modified: MacRuby/trunk/lib/irb/version.rb
===================================================================
--- MacRuby/trunk/lib/irb/version.rb	2010-11-04 14:06:42 UTC (rev 4880)
+++ MacRuby/trunk/lib/irb/version.rb	2010-11-04 18:17:48 UTC (rev 4881)
@@ -8,8 +8,8 @@
   module VERSION #:nodoc:
     NAME  = 'DietRB'
     MAJOR = 0
-    MINOR = 5
-    TINY  = 2
+    MINOR = 6
+    TINY  = 0
     
     STRING = [MAJOR, MINOR, TINY].join('.')
     DESCRIPTION = "#{NAME} (#{STRING})"

Modified: MacRuby/trunk/spec/dietrb/ext/completion_spec.rb
===================================================================
--- MacRuby/trunk/spec/dietrb/ext/completion_spec.rb	2010-11-04 14:06:42 UTC (rev 4880)
+++ MacRuby/trunk/spec/dietrb/ext/completion_spec.rb	2010-11-04 18:17:48 UTC (rev 4881)
@@ -249,6 +249,13 @@
     end
   end
 
+  it "completes file paths" do
+    complete("'/").should == Dir.glob('/*').sort.map { |f| "'#{f}" }
+    complete("'#{ROOT}/lib/../Ra").should == ["'#{File.join(ROOT, "Rakefile")}"]
+    complete("%{#{ROOT}/li").should == ['LICENSE', 'lib'].map { |f| "%{#{File.join(ROOT, f)}" }
+    complete("\"#{ROOT}/lib/").should == ['irb', 'irb.rb'].map { |f| "\"#{File.join(ROOT, 'lib', f)}" }
+  end
+
   it "does not crash when trying to complete garbage" do
     complete("/").should == nil
     complete("./Rake").should == nil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101104/a4476d6d/attachment.html>


More information about the macruby-changes mailing list