looksee 1.0.3-universal-java-1.6 → 2.0.0-universal-java-1.6

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/spec/editor_spec.rb CHANGED
@@ -1,128 +1,110 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Looksee::Editor do
4
- def editor_command(command)
5
- Looksee::Editor.new(command).command_for('FILE', 'LINE')
6
- end
4
+ describe "#command_for" do
5
+ def editor_command(command)
6
+ Looksee::Editor.new(command).command_for('FILE', 'LINE')
7
+ end
7
8
 
8
- it "should infer the file and line arguments for 'vi'" do
9
- editor_command('vi').should == ['vi', '+LINE', 'FILE']
10
- end
9
+ it "should infer the file and line arguments for 'vi'" do
10
+ editor_command('vi').should == ['vi', '+LINE', 'FILE']
11
+ end
11
12
 
12
- it "should infer the file and line arguments for 'vim'" do
13
- editor_command('vim').should == ['vim', '+LINE', 'FILE']
14
- end
13
+ it "should infer the file and line arguments for 'vim'" do
14
+ editor_command('vim').should == ['vim', '+LINE', 'FILE']
15
+ end
15
16
 
16
- it "should infer the file and line arguments for 'gvim'" do
17
- editor_command('gvim').should == ['gvim', '+LINE', 'FILE']
18
- end
17
+ it "should infer the file and line arguments for 'gvim'" do
18
+ editor_command('gvim').should == ['gvim', '+LINE', 'FILE']
19
+ end
19
20
 
20
- it "should infer the file and line arguments for 'emacs'" do
21
- editor_command('emacs').should == ['emacs', '+LINE', 'FILE']
22
- end
21
+ it "should infer the file and line arguments for 'emacs'" do
22
+ editor_command('emacs').should == ['emacs', '+LINE', 'FILE']
23
+ end
23
24
 
24
- it "should infer the file and line arguments for 'xemacs'" do
25
- editor_command('xemacs').should == ['xemacs', '+LINE', 'FILE']
26
- end
25
+ it "should infer the file and line arguments for 'xemacs'" do
26
+ editor_command('xemacs').should == ['xemacs', '+LINE', 'FILE']
27
+ end
27
28
 
28
- it "should infer the file and line arguments for 'aquamacs'" do
29
- editor_command('aquamacs').should == ['aquamacs', '+LINE', 'FILE']
30
- end
29
+ it "should infer the file and line arguments for 'aquamacs'" do
30
+ editor_command('aquamacs').should == ['aquamacs', '+LINE', 'FILE']
31
+ end
31
32
 
32
- it "should infer the file and line arguments for 'pico'" do
33
- editor_command('pico').should == ['pico', '+LINE', 'FILE']
34
- end
33
+ it "should infer the file and line arguments for 'pico'" do
34
+ editor_command('pico').should == ['pico', '+LINE', 'FILE']
35
+ end
35
36
 
36
- it "should infer the file and line arguments for 'nano'" do
37
- editor_command('nano').should == ['nano', '+LINE', 'FILE']
38
- end
37
+ it "should infer the file and line arguments for 'nano'" do
38
+ editor_command('nano').should == ['nano', '+LINE', 'FILE']
39
+ end
39
40
 
40
- it "should infer the file and line arguments for 'mate'" do
41
- editor_command('mate').should == ['mate', '-lLINE', 'FILE']
42
- end
41
+ it "should infer the file and line arguments for 'mate'" do
42
+ editor_command('mate').should == ['mate', '-lLINE', 'FILE']
43
+ end
43
44
 
44
- it "should support escaped '%'-signs" do
45
- editor_command('%% %f %l').should == ['%', 'FILE', 'LINE']
46
- end
45
+ it "should support escaped '%'-signs" do
46
+ editor_command('%% %f %l').should == ['%', 'FILE', 'LINE']
47
+ end
47
48
 
48
- it "should not infer file and line arguments for unknown editors" do
49
- editor_command('wtfbbq').should == ['wtfbbq']
49
+ it "should not infer file and line arguments for unknown editors" do
50
+ editor_command('wtfbbq').should == ['wtfbbq']
51
+ end
50
52
  end
51
53
 
52
54
  describe "#edit" do
53
- TMP = "#{ROOT}/spec/tmp"
55
+ let(:tmp) { "#{ROOT}/spec/tmp" }
56
+ let(:editor_path) { "#{tmp}/edit" }
57
+ let(:editor_output) { "#{tmp}/edit.out" }
58
+ let(:editor) { Looksee::Editor.new("#{editor_path} %f %l") }
59
+ let(:editor_invocation) { File.exist?(editor_output) ? File.read(editor_output) : nil }
60
+ let(:source_location) { ["#{tmp}/c.rb", 2] }
61
+ let(:object) { C.new }
54
62
 
55
63
  before do
56
- FileUtils.mkdir_p TMP
57
- make_editor "#{TMP}/edit"
58
- @editor = Looksee::Editor.new("#{TMP}/edit %f %l")
64
+ FileUtils.mkdir_p tmp
65
+ set_up_editor
66
+
67
+ file, line = *source_location
68
+ FileUtils.touch file
69
+ Object.const_set(:C, Class.new { def f; end })
70
+ Looksee.adapter.set_methods(C, [:f], [], [], [])
71
+ Looksee.adapter.set_source_location(C, :f, source_location)
72
+ Looksee.adapter.ancestors[object] = [C, Object]
59
73
  end
60
74
 
61
75
  after do
62
- FileUtils.rm_rf TMP
76
+ Object.send(:remove_const, :C)
77
+ FileUtils.rm_rf tmp
63
78
  end
64
79
 
65
- def make_editor(path)
66
- open(path, 'w') { |f| f.puts <<-EOS.demargin }
80
+ def set_up_editor
81
+ open(editor_path, 'w') { |f| f.puts <<-EOS.demargin }
67
82
  |#!/bin/sh
68
- |echo $# $1 $2 > "#{TMP}/editor.out"
83
+ |echo $# $1 $2 > "#{editor_output}"
69
84
  EOS
70
- File.chmod 0755, path
85
+ File.chmod 0755, editor_path
71
86
  end
72
87
 
73
- def with_source_file
74
- path = "#{TMP}/c.rb"
75
- open(path, 'w') { |f| f.puts <<-EOS.demargin }
76
- |class C
77
- | def f
78
- | end
79
- |end
80
- EOS
81
- begin
82
- load path
83
- Looksee.adapter.set_methods(C, [:f], [], [], [])
84
- yield path
85
- ensure
86
- Object.send(:remove_const, :C)
87
- end
88
+ it "should run the editor on the method's source location if available" do
89
+ editor.edit(object, :f)
90
+ editor_invocation.should == "2 #{source_location.join(' ')}\n"
88
91
  end
89
92
 
90
- it "should run the editor on the method's source location if available" do
91
- with_source_file do |path|
92
- c = C.new
93
- Looksee.adapter.ancestors[c] = [C, Object]
94
- Looksee.adapter.set_source_location(C, :f, [path, 2])
95
- @editor.edit(c, :f)
96
- File.read("#{TMP}/editor.out").should == "2 #{path} 2\n"
97
- end
98
- end
99
-
100
- it "should not run the editor if the source file does not exist" do
101
- with_source_file do |path|
102
- FileUtils.rm_f path
103
- @editor.edit(C.new, :f)
104
- File.should_not exist("#{TMP}/editor.out")
105
- end
106
- end
107
-
108
- it "should not run the editor for methods defined with eval where no source file specified" do
109
- eval <<-EOS.demargin
110
- |class ::C
111
- | def f
112
- | end
113
- |end
114
- EOS
115
- begin
116
- @editor.edit(C.new, :f)
117
- File.should_not exist("#{TMP}/editor.out")
118
- ensure
119
- Object.send(:remove_const, :C)
120
- end
93
+ it "should raise NoMethodError and not run the editor if the method does not exist" do
94
+ expect { editor.edit(object, :x) }.to raise_error(Looksee::NoMethodError)
95
+ editor_invocation.should be_nil
96
+ end
97
+
98
+ it "should raise NoSourceFileError and not run the editor if the source file does not exist" do
99
+ FileUtils.rm_f source_location.first
100
+ expect { editor.edit(object, :f) }.to raise_error(Looksee::NoSourceFileError)
101
+ editor_invocation.should be_nil
121
102
  end
122
103
 
123
- it "should not run the editor for primitives" do
124
- @editor.edit('', :size)
125
- File.should_not exist("#{TMP}/editor.out")
104
+ it "should raise NoSourceLocationError and not run the editor if no source location is available" do
105
+ Looksee.adapter.set_source_location(C, :f, nil)
106
+ expect { editor.edit(object, :f) }.to raise_error(Looksee::NoSourceLocationError)
107
+ editor_invocation.should be_nil
126
108
  end
127
109
  end
128
110
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
- ENV['LOOKSEE_METHODS'] = nil
1
+ $:.unshift File.expand_path('..', File.dirname(__FILE__))
2
+ ENV['LOOKSEE_METHOD'] = nil
2
3
 
3
4
  require 'rspec'
4
5
  require 'looksee'
@@ -7,7 +8,7 @@ require 'rbconfig'
7
8
  require 'set'
8
9
  require 'fileutils'
9
10
 
10
- ROOT = File.dirname(File.dirname(__FILE__))
11
+ ROOT = File.expand_path('..', File.dirname(__FILE__))
11
12
 
12
13
  Dir['spec/support/*.rb'].each do |path|
13
14
  require path
@@ -18,8 +19,3 @@ NATIVE_ADAPTER = Looksee.adapter
18
19
  RSpec.configure do |config|
19
20
  config.before { Looksee.adapter = TestAdapter.new }
20
21
  end
21
-
22
- if Looksee.ruby_engine == 'jruby'
23
- require 'jruby'
24
- JRuby.objectspace = true
25
- end
@@ -42,29 +42,6 @@ module TemporaryClasses
42
42
  mod
43
43
  end
44
44
 
45
- #
46
- # Remove all methods defined exactly on the given module.
47
- #
48
- # As Ruby's reflection on singleton classes of classes isn't quite
49
- # adequate, you need to provide a :class_singleton option when such
50
- # a class is given.
51
- #
52
- def remove_methods(mod, opts={})
53
- names = all_instance_methods(mod)
54
-
55
- # all_instance_methods can't get just the methods on a class
56
- # singleton class. Filter out superclass methods here.
57
- if opts[:class_singleton]
58
- klass = ObjectSpace.each_object(mod){|klass| break klass}
59
- names -= all_instance_methods(klass.superclass.singleton_class)
60
- end
61
-
62
- names.sort_by{|name| name.in?([:remove_method, :send]) ? 1 : 0}.flatten
63
- names.each do |name|
64
- mod.send :remove_method, name
65
- end
66
- end
67
-
68
45
  #
69
46
  # Replace the methods of the given module with those named.
70
47
  #
@@ -78,8 +55,7 @@ module TemporaryClasses
78
55
  #
79
56
  # replace_methods MyClass, :public => [:a, :b]
80
57
  #
81
- def replace_methods(mod, options={})
82
- remove_methods(mod, options)
58
+ def add_methods(mod, options={})
83
59
  mod.module_eval do
84
60
  [:public, :protected, :private].each do |visibility|
85
61
  Array(options[visibility]).each do |name|
@@ -12,10 +12,9 @@ describe Looksee::WirbleCompatibility do
12
12
  |c.ls
13
13
  EOS
14
14
  code = code.chomp.gsub(/\n/, ';') # only print value of last line
15
- irb = File.join Looksee::Config::CONFIG['bindir'], 'irb'
16
- lib_dir = File.expand_path('lib')
15
+ lib = File.expand_path('lib')
17
16
  # irb hangs when using readline without a tty
18
- output = IO.popen("bundle exec #{irb} -f --noreadline --noprompt --noverbose -I#{lib_dir} 2>&1", 'r+') do |io|
17
+ output = IO.popen("bundle exec irb -f --noreadline --noprompt --noverbose -I#{lib}", 'r+') do |io|
19
18
  io.puts code
20
19
  io.flush
21
20
  io.close_write
metadata CHANGED
@@ -1,152 +1,115 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: looksee
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
6
5
  platform: universal-java-1.6
7
- authors:
8
- - George Ogata
9
- autorequire:
6
+ authors:
7
+ - George Ogata
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-09-05 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: ritual
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - "="
23
- - !ruby/object:Gem::Version
24
- version: 0.3.0
25
- type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - "="
34
- - !ruby/object:Gem::Version
35
- version: 2.5.0
36
- type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: wirble
40
- prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
47
- type: :development
48
- version_requirements: *id003
49
- description:
50
- email:
51
- - george.ogata@gmail.com
11
+ date: 2014-01-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - george.ogata@gmail.com
52
16
  executables: []
53
-
54
17
  extensions: []
55
-
56
- extra_rdoc_files:
57
- - CHANGELOG
58
- - LICENSE
59
- - README.markdown
60
- files:
61
- - lib/looksee.rb
62
- - lib/looksee/adapter.rb
63
- - lib/looksee/clean.rb
64
- - lib/looksee/columnizer.rb
65
- - lib/looksee/core_ext.rb
66
- - lib/looksee/editor.rb
67
- - lib/looksee/help.rb
68
- - lib/looksee/inspector.rb
69
- - lib/looksee/JRuby.jar
70
- - lib/looksee/lookup_path.rb
71
- - lib/looksee/shortcuts.rb
72
- - lib/looksee/version.rb
73
- - lib/looksee/wirble_compatibility.rb
74
- - lib/looksee/adapter/base.rb
75
- - lib/looksee/adapter/rubinius.rb
76
- - ext/mri/mri.c
77
- - ext/rbx/rbx.c
78
- - ext/mri/env-1.8.h
79
- - ext/mri/eval_c-1.8.h
80
- - ext/mri/node-1.9.h
81
- - ext/mri/1.9.2/debug.h
82
- - ext/mri/1.9.2/id.h
83
- - ext/mri/1.9.2/method.h
84
- - ext/mri/1.9.2/node.h
85
- - ext/mri/1.9.2/thread_pthread.h
86
- - ext/mri/1.9.2/vm_core.h
87
- - ext/mri/1.9.2/vm_opts.h
88
- - ext/mri/1.9.3/atomic.h
89
- - ext/mri/1.9.3/debug.h
90
- - ext/mri/1.9.3/id.h
91
- - ext/mri/1.9.3/internal.h
92
- - ext/mri/1.9.3/method.h
93
- - ext/mri/1.9.3/node.h
94
- - ext/mri/1.9.3/thread_pthread.h
95
- - ext/mri/1.9.3/vm_core.h
96
- - ext/mri/1.9.3/vm_opts.h
97
- - ext/extconf.rb
98
- - CHANGELOG
99
- - LICENSE
100
- - Rakefile
101
- - README.markdown
102
- - spec/adapter_spec.rb
103
- - spec/columnizer_spec.rb
104
- - spec/core_ext_spec.rb
105
- - spec/editor_spec.rb
106
- - spec/inspector_spec.rb
107
- - spec/lookup_path_spec.rb
108
- - spec/spec_helper.rb
109
- - spec/wirble_compatibility_spec.rb
110
- - spec/support/core_ext.rb
111
- - spec/support/temporary_classes.rb
112
- - spec/support/test_adapter.rb
113
- has_rdoc: true
18
+ extra_rdoc_files:
19
+ - CHANGELOG
20
+ - LICENSE
21
+ - README.markdown
22
+ files:
23
+ - CHANGELOG
24
+ - LICENSE
25
+ - README.markdown
26
+ - Rakefile
27
+ - ext/extconf.rb
28
+ - ext/mri/1.9.2/debug.h
29
+ - ext/mri/1.9.2/id.h
30
+ - ext/mri/1.9.2/method.h
31
+ - ext/mri/1.9.2/node.h
32
+ - ext/mri/1.9.2/thread_pthread.h
33
+ - ext/mri/1.9.2/vm_core.h
34
+ - ext/mri/1.9.2/vm_opts.h
35
+ - ext/mri/1.9.3/atomic.h
36
+ - ext/mri/1.9.3/debug.h
37
+ - ext/mri/1.9.3/id.h
38
+ - ext/mri/1.9.3/internal.h
39
+ - ext/mri/1.9.3/internal_falcon.h
40
+ - ext/mri/1.9.3/method.h
41
+ - ext/mri/1.9.3/node.h
42
+ - ext/mri/1.9.3/thread_pthread.h
43
+ - ext/mri/1.9.3/vm_core.h
44
+ - ext/mri/1.9.3/vm_opts.h
45
+ - ext/mri/2.0.0/internal.h
46
+ - ext/mri/2.0.0/method.h
47
+ - ext/mri/2.1.0/internal.h
48
+ - ext/mri/2.1.0/method.h
49
+ - ext/mri/env-1.8.h
50
+ - ext/mri/eval_c-1.8.h
51
+ - ext/mri/mri.c
52
+ - ext/mri/node-1.9.h
53
+ - ext/rbx/rbx.c
54
+ - lib/looksee.rb
55
+ - lib/looksee/JRuby.jar
56
+ - lib/looksee/adapter.rb
57
+ - lib/looksee/adapter/base.rb
58
+ - lib/looksee/adapter/rubinius.rb
59
+ - lib/looksee/clean.rb
60
+ - lib/looksee/columnizer.rb
61
+ - lib/looksee/core_ext.rb
62
+ - lib/looksee/editor.rb
63
+ - lib/looksee/help.rb
64
+ - lib/looksee/inspector.rb
65
+ - lib/looksee/lookup_path.rb
66
+ - lib/looksee/shortcuts.rb
67
+ - lib/looksee/version.rb
68
+ - lib/looksee/wirble_compatibility.rb
69
+ - spec/adapter_spec.rb
70
+ - spec/columnizer_spec.rb
71
+ - spec/core_ext_spec.rb
72
+ - spec/editor_spec.rb
73
+ - spec/inspector_spec.rb
74
+ - spec/lookup_path_spec.rb
75
+ - spec/spec_helper.rb
76
+ - spec/support/core_ext.rb
77
+ - spec/support/temporary_classes.rb
78
+ - spec/support/test_adapter.rb
79
+ - spec/wirble_compatibility_spec.rb
114
80
  homepage: http://github.com/oggy/looksee
115
- licenses: []
116
-
117
- post_install_message:
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
118
85
  rdoc_options: []
119
-
120
- require_paths:
121
- - lib
122
- required_ruby_version: !ruby/object:Gem::Requirement
123
- none: false
124
- requirements:
125
- - - ">="
126
- - !ruby/object:Gem::Version
127
- version: "0"
128
- required_rubygems_version: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: "0"
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
134
98
  requirements: []
135
-
136
- rubyforge_project:
137
- rubygems_version: 1.5.1
138
- signing_key:
99
+ rubyforge_project:
100
+ rubygems_version: 2.2.0
101
+ signing_key:
139
102
  specification_version: 3
140
103
  summary: Supercharged method introspection in IRB.
141
- test_files:
142
- - spec/adapter_spec.rb
143
- - spec/columnizer_spec.rb
144
- - spec/core_ext_spec.rb
145
- - spec/editor_spec.rb
146
- - spec/inspector_spec.rb
147
- - spec/lookup_path_spec.rb
148
- - spec/spec_helper.rb
149
- - spec/wirble_compatibility_spec.rb
150
- - spec/support/core_ext.rb
151
- - spec/support/temporary_classes.rb
152
- - spec/support/test_adapter.rb
104
+ test_files:
105
+ - spec/adapter_spec.rb
106
+ - spec/columnizer_spec.rb
107
+ - spec/core_ext_spec.rb
108
+ - spec/editor_spec.rb
109
+ - spec/inspector_spec.rb
110
+ - spec/lookup_path_spec.rb
111
+ - spec/spec_helper.rb
112
+ - spec/wirble_compatibility_spec.rb
113
+ - spec/support/core_ext.rb
114
+ - spec/support/temporary_classes.rb
115
+ - spec/support/test_adapter.rb