akitaonrails-utility_belt 1.0.10 → 1.0.11

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/History.txt CHANGED
@@ -1,3 +1,31 @@
1
+ == 1.0.11 / 2008-09-21
2
+
3
+ * Fixed the h! command that was recursing within itself.
4
+
5
+ * Added Ruby2Ruby dependency to allow the developer to create
6
+ classes with IRB, by reopening and changing it and then
7
+ editing the whole thing within vi or textmate. by Fabio
8
+ Akita
9
+
10
+ * Editing from an outside editor doesn't change the history
11
+ so fixed with the reload of the externally edited program
12
+ within the history. by Fabio Akita
13
+
14
+ * Trying to fix the gemspec so Github can automatically
15
+ build the gem. by Fabio Akita
16
+
17
+ == 1.0.10 / 2008-09-20
18
+
19
+ * New "print_methods" for any class to print all the available methods
20
+ from itself and its superclass, included modules, etc with a more
21
+ visually compeling organization. by Fabio Akita
22
+
23
+ * Added 'clear_history' command to clear the Readline history. by
24
+ Fabio Akita
25
+
26
+ * Fixed the edit_interactively method that was failing for vi. And
27
+ fixed the \r line break to replace it to \n. by Fabio Akita
28
+
1
29
  == 1.0.0 / 2007-11-03
2
30
 
3
31
  * 1 major enhancement
@@ -43,8 +43,8 @@ class Object
43
43
  end
44
44
  alias :h :history
45
45
 
46
- # -2 because -1 is ourself
47
- def history_do(lines = (Readline::HISTORY.size - 2))
46
+ # -3 because -1 is nil and -2 is ourself
47
+ def history_do(lines = (Readline::HISTORY.size - 3))
48
48
  irb_eval lines
49
49
  end
50
50
  alias :h! :history_do
@@ -123,6 +123,7 @@ class Object
123
123
  def irb_eval(lines)
124
124
  to_eval = get_lines(lines)
125
125
  to_eval.each {|l| Readline::HISTORY << l}
126
+ to_eval.reject! { |l| l.strip == 'h' || l =~ /^h\!/ } # avoid infinite recursion of itself
126
127
  eval to_eval.join("\n")
127
128
  end
128
129
  end
@@ -34,7 +34,9 @@ class InteractiveEditor
34
34
  @file = Tempfile.new("irb_tempfile")
35
35
  end
36
36
  system("#{@editor} #{@file.path}")
37
- Object.class_eval(File.read(@file.path).gsub("\r", "\n"))
37
+ lines = File.read(@file.path).gsub("\r", "\n")
38
+ lines.split("\n").each { |l| Readline::HISTORY << l } # update history
39
+ Object.class_eval(lines)
38
40
  rescue Exception => error
39
41
  puts @file.path
40
42
  puts error
@@ -7,16 +7,32 @@
7
7
  # author: Fabio Akita (akitaonrails.com)
8
8
  module UtilityBelt
9
9
  module Editor
10
- # shortcut to textmate
11
- def mate
12
- edit_interactively 'mate'
10
+ def mate_class(obj)
11
+ edit_class 'mate', obj
13
12
  end
14
13
 
15
- # shortcut to vi
16
- def vi
17
- edit_interactively 'vi'
14
+ def vi_class(obj)
15
+ edit_class 'vi', obj
16
+ end
17
+
18
+ # allows you to create a class interactively bit by bit
19
+ # and then edit the whole thing within an editor
20
+ def edit_class(editor, obj)
21
+ require 'ruby2ruby'
22
+ unless @file
23
+ @file = Tempfile.new("irb_tempfile")
24
+ File.open(@file.path, 'w+') do |f|
25
+ f.write Ruby2Ruby.translate(obj)
26
+ end
27
+ end
28
+ system("#{editor} #{@file.path}")
29
+ Object.class_eval(File.read(@file.path).gsub("\r", "\n"))
30
+ rescue Exception => error
31
+ puts @file.path
32
+ puts error
18
33
  end
19
34
  end
35
+
20
36
  module PrintMethods
21
37
  INSPECTORS = [
22
38
  :public_methods,
@@ -39,6 +55,7 @@ module UtilityBelt
39
55
  clist.each do |klass|
40
56
  inspector_methods.each do |insmethod|
41
57
  mlist = klass.send(insmethod).sort
58
+ mlist -= klass.superclass.send(insmethod) if klass.respond_to?(:superclass) && clist.include?(klass.superclass)
42
59
  mlist -= Object.send(insmethod) unless klass == Object
43
60
  mlist -= ['append_features'] # dunno where this method comes from
44
61
  unless mlist.empty?
@@ -68,5 +85,8 @@ module UtilityBelt
68
85
  end
69
86
  end
70
87
  end
71
- Object.send(:extend, UtilityBelt::PrintMethods)
72
- String.send(:include, UtilityBelt::Inflector) if String.instance_methods.select { |m| m == 'constantize' }.empty?
88
+ if Object.const_defined? :IRB
89
+ Object.send(:extend, UtilityBelt::PrintMethods)
90
+ self.send(:extend, UtilityBelt::Editor)
91
+ String.send(:include, UtilityBelt::Inflector) if String.instance_methods.select { |m| m == 'constantize' }.empty?
92
+ end
data/utility_belt.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  #require 'rubygems'
2
2
  SPEC = Gem::Specification.new do |s|
3
3
  s.name = "utility_belt"
4
- s.version = "1.0.10"
4
+ s.version = "1.0.11"
5
5
  s.author = "Giles Bowkett"
6
6
  s.email = "gilesb@gmail.com"
7
7
  s.homepage = "http://utilitybelt.rubyforge.org"
@@ -17,6 +17,7 @@ SPEC = Gem::Specification.new do |s|
17
17
  s.has_rdoc = true
18
18
  s.extra_rdoc_files = ["README"]
19
19
  s.add_dependency("wirble", ">= 0.1.2")
20
- s.add_dependency("aws-s3", ">= 0.4.0")
20
+ s.add_dependency("aws-s3", ">= 0.5.1")
21
21
  s.add_dependency("Platform", ">= 0.4.0")
22
+ s.add_dependency("ruby2ruby", ">= 1.1.9")
22
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akitaonrails-utility_belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giles Bowkett
@@ -28,7 +28,7 @@ dependencies:
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: 0.4.0
31
+ version: 0.5.1
32
32
  version:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: Platform
@@ -39,6 +39,15 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.0
41
41
  version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: ruby2ruby
44
+ version_requirement:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.1.9
50
+ version:
42
51
  description:
43
52
  email: gilesb@gmail.com
44
53
  executables: