coypond 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/VERSION +1 -1
  2. data/bin/coypond +20 -3
  3. data/coypond.gemspec +64 -0
  4. data/lib/coypond.rb +4 -1
  5. metadata +11 -10
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
data/bin/coypond CHANGED
@@ -31,6 +31,8 @@ while !$*.empty? and $*.first.start_with?("-")
31
31
  options[:class] = true
32
32
  when "-M"
33
33
  options[:module] = true
34
+ when "-g"
35
+ options[:gem] = $*.shift
34
36
  when "-a"
35
37
  options[:all] = true
36
38
  end
@@ -38,10 +40,25 @@ end
38
40
 
39
41
  options[:all] ||= (options.keys & [:class, :method, :module]).empty?
40
42
 
41
- coypond = Coypond::CoypondRunner.new($*)
42
- results = coypond.search(options)
43
+ def expand(file, pattern=["**"])
44
+ if File.directory?(file)
45
+ return Dir.glob(File.join(file, *pattern, '*.rb') )
46
+ else
47
+ return file
48
+ end
49
+ end
50
+
51
+ files = []
52
+ if options[:gem]
53
+ ENV["GEM_PATH"].split(":").each do |path|
54
+ files += expand(path, ["gems", "#{options[:gem]}*", "**"])
55
+ end
56
+ else
57
+ files = $*.map {|file| expand(file)}.flatten
58
+ end
43
59
 
44
- results.each do |file_name, res|
60
+ coypond = Coypond::CoypondRunner.new(files)
61
+ coypond.search(options) do |file_name, res|
45
62
  unless res.empty?
46
63
  puts "#{file_name}:"
47
64
  res.each do |dec, location, context|
data/coypond.gemspec ADDED
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{coypond}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Amit Levy"]
12
+ s.date = %q{2011-08-10}
13
+ s.default_executable = %q{coypond}
14
+ s.description = %q{Semantic grep for Ruby}
15
+ s.email = %q{aalevy@gmail.com}
16
+ s.executables = ["coypond"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bin/coypond",
30
+ "coypond.gemspec",
31
+ "lib/coypond.rb",
32
+ "lib/coypond/parser.rb",
33
+ "test/coypond/test_parser.rb",
34
+ "test/helper.rb",
35
+ "test/test_coypond.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/alevy/coypond}
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.6.2}
41
+ s.summary = %q{Semantic grep for Ruby}
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ else
52
+ s.add_dependency(%q<shoulda>, [">= 0"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ end
57
+ else
58
+ s.add_dependency(%q<shoulda>, [">= 0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
62
+ end
63
+ end
64
+
data/lib/coypond.rb CHANGED
@@ -21,6 +21,9 @@ module Coypond
21
21
  context = source.lines.to_a[location.first - 1]
22
22
  final_result[file_name] << [dec, location, context]
23
23
  end
24
+
25
+ yield(file_name, final_result[file_name]) if block_given?
26
+
24
27
  end
25
28
  return final_result
26
29
  end
@@ -32,7 +35,7 @@ module Coypond
32
35
  collection.select do |k,v|
33
36
  k = k.downcase if options[:ignore_case]
34
37
  if options[:regexp]
35
- Regexp.new("#{search_term}$").match(k)
38
+ Regexp.new("(#{search_term})$").match(k)
36
39
  else
37
40
  k.end_with?(search_term)
38
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coypond
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable: coypond
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: shoulda
17
- requirement: &2157206000 !ruby/object:Gem::Requirement
17
+ requirement: &2157682260 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2157206000
25
+ version_requirements: *2157682260
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
- requirement: &2157205080 !ruby/object:Gem::Requirement
28
+ requirement: &2157681200 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2157205080
36
+ version_requirements: *2157681200
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: jeweler
39
- requirement: &2157204160 !ruby/object:Gem::Requirement
39
+ requirement: &2157680300 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.4
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2157204160
47
+ version_requirements: *2157680300
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rcov
50
- requirement: &2157203060 !ruby/object:Gem::Requirement
50
+ requirement: &2157679040 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2157203060
58
+ version_requirements: *2157679040
59
59
  description: Semantic grep for Ruby
60
60
  email: aalevy@gmail.com
61
61
  executables:
@@ -73,6 +73,7 @@ files:
73
73
  - Rakefile
74
74
  - VERSION
75
75
  - bin/coypond
76
+ - coypond.gemspec
76
77
  - lib/coypond.rb
77
78
  - lib/coypond/parser.rb
78
79
  - test/coypond/test_parser.rb
@@ -94,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
95
  version: '0'
95
96
  segments:
96
97
  - 0
97
- hash: 3557283599531574218
98
+ hash: 1368082271380149158
98
99
  required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  none: false
100
101
  requirements: