source_locator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/showme CHANGED
@@ -2,10 +2,24 @@
2
2
 
3
3
  require 'source_locator'
4
4
 
5
- Rails.application.eager_load! if defined? Rails
5
+ rails_env_file = File.join(Dir.pwd, 'config', 'environment.rb')
6
6
 
7
- storage = SourceLocator::Dictionary.new
8
- storage.build
7
+ if File.exists? rails_env_file
8
+ puts "Loading Rails env..."
9
+ require rails_env_file
10
+ end
11
+
12
+ if defined? Rails
13
+ puts "Rails loaded."
14
+ puts "Loading classes from the Rails app..."
15
+ Rails.application.eager_load!
16
+ puts "Done."
17
+ end
18
+
19
+ class_loader = SourceLocator::ClassLoader.new
20
+ data = class_loader.build
21
+
22
+ storage = SourceLocator::Dictionary.new data
9
23
 
10
24
  locater = SourceLocator::Locater.new(storage, ARGV[0])
11
25
  results = locater.find
@@ -0,0 +1,29 @@
1
+ module SourceLocator
2
+ class ClassLoader
3
+
4
+ def build
5
+ h = Hash.new
6
+
7
+ all_classes.map do |c|
8
+ c.instance_methods.each do |m|
9
+ h[m] ||= []
10
+ s = c.instance_method(m).source_location
11
+ h[m] << s if s
12
+ end
13
+
14
+ c.public_methods.each do |m|
15
+ h[m] ||= []
16
+ s = c.method(m).source_location
17
+ h[m] << s if s
18
+ end
19
+ end
20
+ h
21
+ end
22
+
23
+ private
24
+ def all_classes
25
+ Object.constants.map {|c| Object.const_get(c)}.select {|c| c.is_a? Class}
26
+ end
27
+
28
+ end
29
+ end
@@ -1,29 +1,14 @@
1
1
  module SourceLocator
2
2
  class Dictionary
3
- def all_classes
4
- Object.constants.map {|c| Object.const_get(c)}.select {|c| c.is_a? Class}
5
- end
6
-
7
- def build
8
- @dict = {}
9
- all_classes.map{ |c|
10
- c.instance_methods.each do |m|
11
- @dict[m] ||= []
12
- s = c.instance_method(m).source_location
13
- @dict[m] << s if s
14
- end
15
-
16
- c.public_methods.each do |m|
17
- @dict[m] ||= []
18
- s = c.method(m).source_location
19
- @dict[m] << s if s
20
- end
21
- }
3
+ def initialize(data)
4
+ @dict = data
22
5
  end
23
6
 
24
7
  def find(method)
25
8
  @dict[method.to_sym]
26
9
  end
27
10
 
11
+ def export
12
+ end
28
13
  end
29
14
  end
@@ -1,3 +1,3 @@
1
1
  module SourceLocator
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,24 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: source_locator
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Unnikrishnan KP
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-11-18 00:00:00.000000000 Z
17
+
18
+ date: 2012-11-18 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description: Source code locater
15
- email:
22
+ email:
16
23
  - unni.tallman@gmail.com
17
- executables:
24
+ executables:
18
25
  - showme
19
26
  extensions: []
27
+
20
28
  extra_rdoc_files: []
21
- files:
29
+
30
+ files:
22
31
  - .gitignore
23
32
  - Gemfile
24
33
  - LICENSE
@@ -27,34 +36,44 @@ files:
27
36
  - bin/showme
28
37
  - lib/LICENSE
29
38
  - lib/source_locator.rb
39
+ - lib/source_locator/class_loader.rb
30
40
  - lib/source_locator/dictionary.rb
31
41
  - lib/source_locator/editors/sublime_text.rb
32
42
  - lib/source_locator/locater.rb
33
43
  - lib/source_locator/version.rb
34
44
  - source_locator.gemspec
35
- homepage: ''
45
+ homepage: ""
36
46
  licenses: []
47
+
37
48
  post_install_message:
38
49
  rdoc_options: []
39
- require_paths:
50
+
51
+ require_paths:
40
52
  - lib
41
- required_ruby_version: !ruby/object:Gem::Requirement
53
+ required_ruby_version: !ruby/object:Gem::Requirement
42
54
  none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
63
  none: false
49
- requirements:
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
53
71
  requirements: []
72
+
54
73
  rubyforge_project:
55
- rubygems_version: 1.8.17
74
+ rubygems_version: 1.8.24
56
75
  signing_key:
57
76
  specification_version: 3
58
77
  summary: Source code locater
59
78
  test_files: []
60
- has_rdoc:
79
+