Permalink
Browse files

remove dumb files

  • Loading branch information...
1 parent 5915ee2 commit f980dbd269359b4d4ec390bb364d9ed002050406 Josh Crews committed Aug 20, 2010
View
@@ -0,0 +1,3 @@
+Manifest
+pkg
+doc
View
@@ -1,9 +0,0 @@
-README.textile
-Rakefile
-init.rb
-lib/mapquest_directions.rb
-spec/lib/mapquest_directions.xml
-spec/lib/mapquest_directions_fail.xml
-spec/lib/mapquest_directions_spec.rb
-spec/spec_helper.rb
-Manifest
Binary file not shown.
Binary file not shown.
@@ -1,9 +0,0 @@
-README.textile
-Rakefile
-init.rb
-lib/mapquest_directions.rb
-spec/lib/mapquest_directions.xml
-spec/lib/mapquest_directions_fail.xml
-spec/lib/mapquest_directions_spec.rb
-spec/spec_helper.rb
-Manifest
@@ -1,70 +0,0 @@
-h2. Usage
-
-Get a MapQuest API key, and store in your app under MAPQUEST_KEY
-<pre>MAPQUEST_KEY = 'your_api_key'</pre>
-
-<pre>directions = MapQuestDirections.new(origin, destination)</pre>
-where _origin_ and _destination_ are strings of addresses or places that MapQuest can find an address for. Example: "816 Meridian St., 37207"
-
-Get drive time or distance of whole trip
-<pre>
-drive_time_in_minutes = directions.drive_time_in_minutes
-distance_in_miles = directions.distance_in_miles
-</pre>
-
-Get the XML MapQuest returns with every turn, or the API call URL
-<pre>
-xml = directions.xml
-xml_call = directions.xml_call
-</pre>
-
-h3. Error situations
-
-<pre>directions.status</pre> shows you the status code returned by MapQuest. 0 means worked. Other codes (500, 403) mean problem.
-
-If MapQuest can't recognize your places or gives an error, the distance_in_miles and drive_time_in_minutes will each return 0. You can call <pre>directions.status</pre> and it should tell you a number code for the problem. You can call <pre>directions.xml</pre> to read the full text.
-
-h2. Installation
-
-h3. gem
-
-rails 2.3
-# gem install mapquest_directions
-# add config.gem "mapquest_directions" to your environment.rb file
-
-rails 3.0
-# gem 'mapquest_directions' in your Gemfile
-# <pre>bundle install</pre> from command line
-
-h3. Rails plugin
-
-Rails 2.3
-<pre>script/plugin install git://github.com/joshcrews/mapquest-directions-ruby.git</pre>
-
-Rails 3.0
-<pre>rails plugin install git://github.com/joshcrews/mapquest-directions-ruby.git</pre>
-
-h3. Compatibility
-
-Tested on Rails 2.3.8
-
-Not yet tested on Rails 3. It probably is Rails 3 compatible, because it's just a single class with a few methods. It's probably compatible with every ruby project ever.
-
-h3. MapQuest maps API key
-
-You'll need a MapQuest Map API key
-
-http://developer.mapquest.com/
-
-Include it as the constant MAPQUEST_KEY in an app configuration file (environment.rb, config/initializers/api_keys.rb)
-
-h3. Need turn-by-turn directions?
-
-Not yet included in this gem, but you can do it with nokogiri to parse the XML that comes back when you do
-<pre>MapQuestDirections.new(origin, destination).xml</pre>
-And then nokogiri can cycle through each <maneuver> and you can pick out what you need.
-
-h2. License
-
-Anyone can use this code in any way.
-
@@ -1,15 +0,0 @@
-# Rakefile
-require 'rubygems'
-require 'rake'
-require 'echoe'
-
-Echoe.new('mapquest_directions', '0.1.0') do |p|
- p.description = "Ruby-wrapper for MapQuest Directions API. Can return the drive time and driving distance between two places"
- p.url = "http://github.com/joshcrews/MapQuest-Directions-Ruby"
- p.author = "Josh Crews"
- p.email = "josh@joshcrews.com"
- p.ignore_pattern = ["tmp/*", "script/*"]
- p.development_dependencies = ['nokogiri >=1.4.1']
-end
-
-Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -1 +0,0 @@
-require 'mapquest_directions'
@@ -1,69 +0,0 @@
-require 'net/http'
-require 'nokogiri'
-
-class MapQuestDirections
-
- def initialize(location_1, location_2)
- @base_url = "http://www.mapquestapi.com/directions/v1/route?key=#{MAPQUEST_KEY}&outFormat=xml&"
- @location_1 = location_1
- @location_2 = location_2
- options = "from=#{transcribe(@location_1)}&to=#{transcribe(@location_2)}"
- @xml_call = @base_url + options
- @status = find_status
- end
-
- def find_status
- doc = Nokogiri::XML(xml)
- doc.css("statusCode").text
- end
-
- def xml
- unless @xml.nil?
- @xml
- else
- @xml ||= get_url(@xml_call)
- end
- end
-
- def xml_call
- @xml_call
- end
-
- def drive_time_in_minutes
- if @status != "0"
- drive_time = 0
- else
- doc = Nokogiri::XML(xml)
- drive_time = doc.css("time").first.text
- convert_to_minutes(drive_time)
- end
- end
-
- def distance_in_miles
- if @status != "0"
- distance_in_miles = 0
- else
- doc = Nokogiri::XML(xml)
- distance_in_miles = doc.css("distance").first.text.to_i
- end
- end
-
- def status
- @status
- end
-
- private
-
- def convert_to_minutes(text)
- (text.to_i / 60).ceil
- end
-
- def transcribe(location)
- location.gsub(" ", "+")
- end
-
- def get_url(url)
- Net::HTTP.get(::URI.parse(url))
- end
-
-end
@@ -1,33 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{mapquest_directions}
- s.version = "0.1.0"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
- s.authors = ["Josh Crews"]
- s.date = %q{2010-08-19}
- s.description = %q{Ruby-wrapper for MapQuest Directions API. Can return the drive time and driving distance between two places}
- s.email = %q{josh@joshcrews.com}
- s.extra_rdoc_files = ["README.textile", "lib/mapquest_directions.rb"]
- s.files = ["README.textile", "Rakefile", "init.rb", "lib/mapquest_directions.rb", "spec/lib/mapquest_directions.xml", "spec/lib/mapquest_directions_fail.xml", "spec/lib/mapquest_directions_spec.rb", "spec/spec_helper.rb", "Manifest", "mapquest_directions.gemspec"]
- s.homepage = %q{http://github.com/joshcrews/MapQuest-Directions-Ruby}
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mapquest_directions", "--main", "README.textile"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{mapquest_directions}
- s.rubygems_version = %q{1.3.7}
- s.summary = %q{Ruby-wrapper for MapQuest Directions API. Can return the drive time and driving distance between two places}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<nokogiri>, [">= 1.4.1"])
- else
- s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
- end
- else
- s.add_dependency(%q<nokogiri>, [">= 1.4.1"])
- end
-end

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<response><info><statusCode>500</statusCode><messages><message>Server is not configured to authorize geocode requests from this client</message></messages><copyright><imageUrl>http://tile21.mqcdn.com/res/mqlogo.gif</imageUrl><imageAltText>© 2010 MapQuest, Inc.</imageAltText><text>© 2010 MapQuest, Inc.</text></copyright></info><collections/></response>
@@ -1,58 +0,0 @@
-require 'spec_helper'
-
-context "Mapquest API" do
- before(:all) do
- @origin = "816 Meridian St., 37207"
- @destination = "1963 Canary Dr., 36830"
- end
-
- context "API working" do
-
- describe "directions work" do
-
- before(:each) do
- MapQuestDirections.any_instance.stubs(:xml).returns(File.read("spec/lib/mapquest_directions.xml"))
- @directions = MapQuestDirections.new(@origin, @destination)
- end
-
- it "should return distance in miles" do
- @directions.distance_in_miles.should == 310
- end
-
- it "should return drive time in minutes" do
- @directions.drive_time_in_minutes.should == 303
- end
-
- it "should have a status code of 0" do
- @directions.status.should == "0"
- end
-
- end #describe
- end # API working
-
- context "API not working" do
-
- describe "Geocode distance estimation work" do
-
- before(:each) do
- MapQuestDirections.any_instance.stubs(:xml).returns(File.read("spec/lib/mapquest_directions_fail.xml"))
- @directions = MapQuestDirections.new(@origin, @destination)
- end
-
- it "should return distance in miles" do
- @directions.distance_in_miles.should == 0
- end
-
- it "should return drive time in minutes" do
- @directions.drive_time_in_minutes.should == 0
- end
-
- it "should have a status code other than 0" do
- @directions.status.should_not == "0"
- end
-
- end #describe
- end # API not working
-
-
-end
@@ -1,13 +0,0 @@
-require 'rubygems'
-require 'mocha'
-require 'ruby-debug'
-
-$:.unshift File.expand_path('../lib', __FILE__)
-require 'mapquest_directions'
-
-MAPQUEST_KEY = "replace_me"
-# http://developer.mapquest.com/
-
-Spec::Runner.configure do |config|
- config.mock_with :mocha
-end

0 comments on commit f980dbd

Please sign in to comment.