lookup 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -27,4 +27,23 @@ Jeweler::Tasks.new do |s|
27
27
  s.autorequire = "lookup"
28
28
  s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec,bin,doc}/**/*")
29
29
  end
30
- Jeweler::GemcutterTasks.new
30
+ Jeweler::GemcutterTasks.new
31
+
32
+ begin
33
+ require 'spec'
34
+ rescue LoadError
35
+ require 'rubygems'
36
+ require 'spec'
37
+ end
38
+
39
+ require 'spec/rake/spectask'
40
+ desc 'Default: run unit tests.'
41
+ task :default => :spec
42
+
43
+ desc "Run the specs under spec"
44
+ Spec::Rake::SpecTask.new do |t|
45
+ t.spec_files = FileList['spec/**/*_spec.rb']
46
+ t.libs = %w(lib spec)
47
+ t.spec_opts << "-c"
48
+ t.ruby_opts << "-rubygems"
49
+ end
@@ -81,19 +81,22 @@ class APILookup
81
81
  end
82
82
 
83
83
  def smart_rails_constant_substitutions(name)
84
- parts=name.split("::").map { |x| x.split(":")}.flatten
85
- rep = case parts.first.downcase
86
- # so it falls back on fuzzy and matches AR as well as ActiveResource
87
- when "ar" then "ActiveRecord"
88
- when "ares" then "ActiveResource"
89
- when "am" then "ActionMailer"
90
- when "as" then "ActiveSupport"
91
- when "ac" then "ActionController"
92
- when "av" then "ActionView"
93
- else
94
- parts.first
84
+ parts = name.split("::").map { |x| x.split(":")}.flatten
85
+ if parts.first
86
+ rep = case parts.first.downcase
87
+ # so it falls back on fuzzy and matches AR as well as ActiveResource
88
+ when "ar" then "ActiveRecord"
89
+ when "ares" then "ActiveResource"
90
+ when "am" then "ActionMailer"
91
+ when "as" then "ActiveSupport"
92
+ when "ac" then "ActionController"
93
+ when "av" then "ActionView"
94
+ else
95
+ parts.first
96
+ end
97
+ return ([rep] + parts[1..-1]).join("::")
95
98
  end
96
- ([rep] + parts[1..-1]).join("::")
99
+ name
97
100
  end
98
101
 
99
102
  # Find an entry.
@@ -41,4 +41,12 @@ describe "Lookup" do
41
41
  APILookup.search("ar::base#new").should eql([find_entry("ActiveRecord::Base", "new")])
42
42
  end
43
43
 
44
+ it "should be able to find it if a hash-symbol is specified" do
45
+ APILookup.search("#today?").should eql([
46
+ find_entry("ActiveSupport::CoreExtensions::Date::Calculations", "today?"),
47
+ find_entry("ActiveSupport::TimeWithZone", "today?"),
48
+ find_entry("ActiveSupport::CoreExtensions::Time::Calculations", "today?")
49
+ ])
50
+ end
51
+
44
52
  end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "testing for regressions" do
4
+ it "should not fail if an initial hash is specified" do
5
+ lambda { APILookup.search("#today?") }.should_not raise_error
6
+ end
7
+
8
+ end
@@ -4,4 +4,10 @@ ENV['HOME'] = File.dirname(__FILE__)
4
4
 
5
5
  require 'rubygems'
6
6
  require 'fakeweb'
7
- require 'lookup'
7
+ require 'lookup'
8
+ require 'spec'
9
+ require 'spec/autorun'
10
+
11
+ Spec::Runner.configure do |config|
12
+
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
@@ -9,7 +9,7 @@ autorequire: lookup
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-28 00:00:00 +10:00
12
+ date: 2009-12-28 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -45,6 +45,7 @@ files:
45
45
  - lib/methods
46
46
  - lib/models.rb
47
47
  - spec/lookup_spec.rb
48
+ - spec/regressions_spec.rb
48
49
  - spec/spec_helper.rb
49
50
  has_rdoc: true
50
51
  homepage: http://gitpilot.com
@@ -76,4 +77,5 @@ specification_version: 3
76
77
  summary: A gem that provides a lazy man's ri
77
78
  test_files:
78
79
  - spec/lookup_spec.rb
80
+ - spec/regressions_spec.rb
79
81
  - spec/spec_helper.rb