lib/lookup.rb in lookup-1.0.0.beta3 vs lib/lookup.rb in lookup-1.0.0.beta7
- old
+ new
@@ -5,33 +5,51 @@
require 'bundler'
ENV['BUNDLE_GEMFILE'] = gemfile
Bundler.require(:default)
module Lookup
- VERSION = "1.0.0.beta3"
+ VERSION = "1.0.0.beta7"
APIS = []
class APINotFound < StandardError; end
class << self
+ def config
+ YAML::load_file(ENV["HOME"] + "/.lookup/config")
+ end
+
def update!
- puts "Updating API, this may take a minute or two. Please be patient!"
+ puts "Updating API listings this may take a minute or two. Please be patient!"
+ puts "Big APIs (like Ruby + Rails) can take some time."
+ 2.times { puts " " }
[Constant, Entry, Api].map { |klass| klass.delete_all }
+ 2.times { puts " " }
+ puts "Loading the following APIs:"
+ apis = config["apis"].values
+ for api in apis
+ puts " " + api["name"]
+ end
- update_api!("Rails v3.0.0", "http://api.rubyonrails.org")
- update_api!("Rails v2.3.8", "http://api.rubyonrails.org/v2.3.8")
- update_api!("Ruby 1.8.7", "http://www.ruby-doc.org/core")
- update_api!("Ruby 1.9", "http://ruby-doc.org/ruby-1.9")
+ for api in apis
+ update_api!(api["name"], api["url"])
+ end
end
def update_api!(name, url)
- puts "Updating API for #{name}..."
+ puts " Loading API for #{name}"
api = Api.find_or_create_by_name_and_url(name, url)
APIS << api
+
+ print " methods..."
api.update_methods!
+ puts " ✓"
+
+ print " classes..."
api.update_classes!
- puts "DONE (with #{name})!"
+ puts " ✓"
+
+ puts " ✓ #{name}"
end
def find_constant(name, entry=nil, options={})
scope = options[:api].constants || Constant
# Find by specific name.
\ No newline at end of file