dietrb 0.4.2 → 0.4.3

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/Rakefile CHANGED
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  desc "Run dietrb with ruby19"
15
15
  task :run do
16
- sh "ruby19 -Ilib ./bin/dietrb -r irb/ext/completion -r irb/ext/colorize -r pp"
16
+ sh "ruby19 -Ilib ./bin/dietrb -r irb/ext/colorize -r pp"
17
17
  end
18
18
 
19
19
  desc "AOT compile for MacRuby"
@@ -42,7 +42,7 @@ begin
42
42
  gemspec.authors = ["Eloy Duran"]
43
43
 
44
44
  gemspec.required_ruby_version = ::Gem::Requirement.new("~> 1.9")
45
- gemspec.files.reject! { |file| file =~ /^extensions/ }
45
+ gemspec.files.reject! { |file| file =~ /^(extensions|\.gitignore)/ }
46
46
  end
47
47
  rescue LoadError
48
48
  end
data/TODO CHANGED
@@ -1,7 +1,5 @@
1
- * Add history manager support
2
- * Add colored output, possibly based on the Wirble code
1
+ * Configurable history file? (:HISTORY_FILE) Configurable number of saved history lines? (:SAVE_HISTORY)
3
2
  * Make sure the following formatters work: hirb, awesome_print, and looksee
4
3
  * Make sure the majority of the utils in utility_belt work
5
4
  * Possibly add copy-paste support as an ext
6
- * Make sure ported/used code is attributed and contact authors about Ruby license
7
5
  * Decide whether or not we need more control for colorizing which could be done with Ripper::SexpBuilder
data/dietrb.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dietrb}
8
- s.version = "0.4.2"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Eloy Duran"]
12
- s.date = %q{2010-05-02}
12
+ s.date = %q{2010-05-30}
13
13
  s.default_executable = %q{dietrb}
14
14
  s.description = %q{IRB on a diet, for MacRuby / Ruby 1.9}
15
15
  s.email = %q{eloy.de.enige@gmail.com}
@@ -20,15 +20,16 @@ Gem::Specification.new do |s|
20
20
  "TODO"
21
21
  ]
22
22
  s.files = [
23
- ".gitignore",
24
- "LICENSE",
23
+ "LICENSE",
25
24
  "README.rdoc",
26
25
  "Rakefile",
27
26
  "TODO",
28
27
  "bin/dietrb",
29
28
  "dietrb.gemspec",
30
29
  "lib/irb.rb",
30
+ "lib/irb/completion.rb",
31
31
  "lib/irb/context.rb",
32
+ "lib/irb/deprecated.rb",
32
33
  "lib/irb/ext/colorize.rb",
33
34
  "lib/irb/ext/completion.rb",
34
35
  "lib/irb/ext/history.rb",
@@ -41,6 +42,7 @@ Gem::Specification.new do |s|
41
42
  "spec/context_spec.rb",
42
43
  "spec/formatter_spec.rb",
43
44
  "spec/history_spec.rb",
45
+ "spec/regression/context_spec.rb",
44
46
  "spec/source_spec.rb",
45
47
  "spec/spec_helper.rb"
46
48
  ]
@@ -56,6 +58,7 @@ Gem::Specification.new do |s|
56
58
  "spec/context_spec.rb",
57
59
  "spec/formatter_spec.rb",
58
60
  "spec/history_spec.rb",
61
+ "spec/regression/context_spec.rb",
59
62
  "spec/source_spec.rb",
60
63
  "spec/spec_helper.rb"
61
64
  ]
data/lib/irb.rb CHANGED
@@ -1,8 +1,17 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+
1
7
  require 'irb/context'
2
8
  require 'irb/source'
3
9
  require 'irb/version'
4
10
 
11
+ require 'irb/deprecated'
12
+
5
13
  require 'irb/ext/history'
14
+ require 'irb/ext/completion'
6
15
 
7
16
  if !ENV['SPECCING'] && defined?(RUBY_ENGINE) && RUBY_ENGINE == "macruby"
8
17
  require 'irb/ext/macruby'
@@ -0,0 +1 @@
1
+ IRB.deprecated "The file `irb/completion' has moved to `irb/ext/ecompletion' and is loaded by default.", caller
data/lib/irb/context.rb CHANGED
@@ -1,3 +1,9 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+
1
7
  require 'irb/formatter'
2
8
  require 'readline'
3
9
 
@@ -28,6 +34,7 @@ module IRB
28
34
  @line = 1
29
35
  clear_buffer
30
36
 
37
+ @underscore_assigner = __evaluate__("_ = nil; proc { |val| _ = val }")
31
38
  @processors = self.class.processors.map { |processor| processor.new(self) }
32
39
  end
33
40
 
@@ -36,7 +43,8 @@ module IRB
36
43
  end
37
44
 
38
45
  def evaluate(source)
39
- result = __evaluate__("_ = (#{source})", '(irb)', @line - @source.buffer.size + 1)
46
+ result = __evaluate__(source.to_s, '(irb)', @line - @source.buffer.size + 1)
47
+ store_result(result)
40
48
  puts formatter.result(result)
41
49
  result
42
50
  rescue Exception => e
@@ -102,6 +110,10 @@ module IRB
102
110
  def clear_buffer
103
111
  @source = Source.new
104
112
  end
113
+
114
+ def store_result(result)
115
+ @underscore_assigner.call(result)
116
+ end
105
117
  end
106
118
  end
107
119
 
@@ -0,0 +1,43 @@
1
+ module IRB
2
+ def self.deprecated(message, caller)
3
+ caller = caller.first.split(':')[0..-2].join(':')
4
+ warn "[!] Deprecation warning from #{caller}: #{message}"
5
+ end
6
+
7
+ def self.deprecated_feature(old_feature, new_feature, caller)
8
+ deprecated "Usage of #{old_feature} will be deprecated, #{new_feature}", caller
9
+ end
10
+
11
+ def self.conf
12
+ @conf ||= DeprecatedConf.new
13
+ end
14
+
15
+ class DeprecatedConf
16
+ DEFAULT_MESSAGE = "please create a patch/ticket"
17
+
18
+ def deprecated_conf(key, message, caller)
19
+ message ||= DEFAULT_MESSAGE
20
+ IRB.deprecated_feature("IRB.conf[:#{key}]", message, caller)
21
+ end
22
+
23
+ def [](key)
24
+ IRB.deprecated("Usage of the IRB.conf hash for configuration is, currently, not supported", caller)
25
+ nil
26
+ end
27
+
28
+ def []=(key, value)
29
+ message = nil
30
+ case key
31
+ when :PROMPT_MODE
32
+ message = "use `IRB.formatter.prompt = :#{value.downcase}'"
33
+ IRB.formatter.prompt = "#{value.to_s.downcase}".to_sym
34
+ when :USE_READLINE
35
+ message = "for now DietRB only has a readline module"
36
+ when :SAVE_HISTORY
37
+ message = "history is always saved"
38
+ end
39
+ deprecated_conf key, message, caller
40
+ value
41
+ end
42
+ end
43
+ end
@@ -1,6 +1,14 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+ #
7
+ # Portions Copyright (C) 2006-2010 Paul Duncan <pabs@pablotron.org> (Wirble)
8
+ # Portions Copyright (C) 2009-2010 Jens Wille <jens.wille@gmail.com> (Wirble)
9
+ # Portions Copyright (C) 2006-2010 Giles Bowkett (light background color scheme)
10
+
1
11
  module IRB
2
- # This code is based upon Wirble (http://pablotron.org/software/wirble/) by
3
- # Paul Duncan and Jens Wille.
4
12
  class ColoredFormatter < Formatter
5
13
  TYPE_ALIASES = {
6
14
  :on_comma => :comma,
@@ -1,3 +1,9 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+
1
7
  require 'ripper'
2
8
 
3
9
  module IRB
@@ -1,6 +1,12 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+ #
7
+ # Portions Copyright (C) 2006-2010 Ben Bleything <ben@bleything.net> (Kernel#history & Kernel#history!)
8
+
1
9
  module IRB
2
- # The util methods, history and history!, were taken from Ben Bleything's
3
- # command_history.rb in utility_belt.
4
10
  class History
5
11
  class << self
6
12
  attr_accessor :file, :max_entries_in_overview
@@ -1,3 +1,9 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+
1
7
  framework 'AppKit'
2
8
 
3
9
  module IRB
data/lib/irb/formatter.rb CHANGED
@@ -1,3 +1,9 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+
1
7
  module IRB
2
8
  class << self
3
9
  attr_accessor :formatter
data/lib/irb/source.rb CHANGED
@@ -1,3 +1,9 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+
1
7
  require 'ripper'
2
8
 
3
9
  module IRB
data/lib/irb/version.rb CHANGED
@@ -1,8 +1,14 @@
1
+ # MacRuby implementation of IRB.
2
+ #
3
+ # This file is covered by the Ruby license. See COPYING for more details.
4
+ #
5
+ # Copyright (C) 2009-2010, Eloy Duran <eloy.de.enige@gmail.com>
6
+
1
7
  module IRB
2
8
  module VERSION #:nodoc:
3
9
  MAJOR = 0
4
10
  MINOR = 4
5
- TINY = 2
11
+ TINY = 3
6
12
 
7
13
  STRING = [MAJOR, MINOR, TINY].join('.')
8
14
  DESCRIPTION = "#{STRING} (DietRB)"
data/spec/context_spec.rb CHANGED
@@ -81,6 +81,7 @@ describe "IRB::Context, when evaluating source" do
81
81
  @context = IRB::Context.new(main)
82
82
  def @context.printed; @printed ||= '' end
83
83
  def @context.puts(string); printed << "#{string}\n" end
84
+ IRB.formatter = IRB::Formatter.new
84
85
  end
85
86
 
86
87
  it "evaluates code with the object's binding" do
@@ -57,7 +57,7 @@ describe "IRB::Formatter" do
57
57
  it "prints the result with object#pretty_inspect, if it responds to it" do
58
58
  object = Object.new
59
59
  def object.pretty_inspect; "foo"; end
60
- @formatter.result(object).should == "foo"
60
+ @formatter.result(object).should == "=> foo"
61
61
  end
62
62
 
63
63
  it "prints that a syntax error occurred on the last line and reset the buffer to the previous line" do
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ main = self
4
+
5
+ describe "IRB::Context, when evaluating source" do
6
+ before do
7
+ @context = IRB::Context.new(main)
8
+ def @context.printed; @printed ||= '' end
9
+ def @context.puts(string); printed << "#{string}\n" end
10
+ end
11
+
12
+ it "does not assign the result to the `_' variable in one go, so it doesn't show up in a syntax error" do
13
+ @context.evaluate("'banana;")
14
+ @context.printed.should.not.include "_ = ('banana;)"
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dietrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-05-02 00:00:00 +02:00
12
+ date: 2010-05-30 00:00:00 +02:00
13
13
  default_executable: dietrb
14
14
  dependencies: []
15
15
 
@@ -24,7 +24,6 @@ extra_rdoc_files:
24
24
  - README.rdoc
25
25
  - TODO
26
26
  files:
27
- - .gitignore
28
27
  - LICENSE
29
28
  - README.rdoc
30
29
  - Rakefile
@@ -32,7 +31,9 @@ files:
32
31
  - bin/dietrb
33
32
  - dietrb.gemspec
34
33
  - lib/irb.rb
34
+ - lib/irb/completion.rb
35
35
  - lib/irb/context.rb
36
+ - lib/irb/deprecated.rb
36
37
  - lib/irb/ext/colorize.rb
37
38
  - lib/irb/ext/completion.rb
38
39
  - lib/irb/ext/history.rb
@@ -45,6 +46,7 @@ files:
45
46
  - spec/context_spec.rb
46
47
  - spec/formatter_spec.rb
47
48
  - spec/history_spec.rb
49
+ - spec/regression/context_spec.rb
48
50
  - spec/source_spec.rb
49
51
  - spec/spec_helper.rb
50
52
  has_rdoc: true
@@ -81,5 +83,6 @@ test_files:
81
83
  - spec/context_spec.rb
82
84
  - spec/formatter_spec.rb
83
85
  - spec/history_spec.rb
86
+ - spec/regression/context_spec.rb
84
87
  - spec/source_spec.rb
85
88
  - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- pkg