next_muni 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.1.3 Separated out directions and reorganized the get_stops hash.
2
+ Better route querying
3
+
1
4
  v0.1.2 Brief Documentation
2
5
 
3
6
  v0.1.1 Fixed gem for release
data/Manifest CHANGED
@@ -3,4 +3,5 @@ README.rdoc
3
3
  Rakefile
4
4
  lib/next_muni.rb
5
5
  lib/next_muni/api.rb
6
+ next_muni.gemspec
6
7
  Manifest
data/README.rdoc CHANGED
@@ -23,4 +23,6 @@ This will return you upcoming times for the next (up to four) buses coming to th
23
23
  == Todo
24
24
 
25
25
  • Cache the route stops
26
- Need to separate out stops between different bus directions
26
+ Inbound / Outbound parameters?
27
+ • Better error handling (No busses scheduled / Bad query)
28
+ • Need to integrate testing into gem
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('next_muni', '0.1.2') do |p|
5
+ Echoe.new('next_muni', '0.1.3') do |p|
6
6
  p.description = "A gem to access San Francisco's Next Muni API easily"
7
7
  p.url = "http://www.github.com/hjhart/next_muni_gem"
8
8
  p.author = "James Hart"
@@ -15,8 +15,6 @@ def name
15
15
  @name ||= Dir['*.gemspec'].first.split('.').first
16
16
  end
17
17
 
18
- task :default => [:test, :features]
19
-
20
18
  desc "Open an irb session preloaded with this library"
21
19
  task :console do
22
20
  sh "irb -rubygems -r ./lib/#{name}.rb"
data/lib/next_muni.rb CHANGED
@@ -7,18 +7,33 @@ require 'next_muni/api'
7
7
 
8
8
  module NextMuni
9
9
  def self.get_stops(route)
10
- url = NextMuni::Api.build_url(route)
10
+ url = NextMuni::Api.build_url(route.upcase)
11
11
  xml = Net::HTTP.get(URI.parse(url))
12
12
  doc = REXML::Document.new(xml)
13
+ directions = []
13
14
  stops = {}
15
+
14
16
  doc.elements.each('body/route/stop') do |ele|
15
17
  stops[ele.attributes['tag']] = ele.attributes['title']
16
18
  end
17
- stops
19
+
20
+ doc.elements.each('body/route/direction') do |direction|
21
+ direction_stops = {}
22
+ direction.elements.each('stop') do |stop|
23
+ direction_stops[stop.attributes['tag']] = stops[stop.attributes['tag']]
24
+ end
25
+
26
+ directions << {
27
+ :id => direction.attributes['tag'],
28
+ :name => direction.attributes['title'],
29
+ :stops => direction_stops
30
+ }
31
+ end
32
+ directions
18
33
  end
19
34
 
20
- def self.get_times(route_no, stop_no)
21
- url = NextMuni::Api.build_url(route_no, stop_no)
35
+ def self.get_times(route_no, stop_no, direction_id=nil)
36
+ url = NextMuni::Api.build_url(route_no.upcase, stop_no, direction_id)
22
37
  xml = Net::HTTP.get(URI.parse(url))
23
38
 
24
39
  doc = REXML::Document.new(xml)
data/next_muni.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{next_muni}
5
- s.version = "0.1.2"
5
+ s.version = "0.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["James Hart"]
9
- s.date = %q{2011-03-16}
9
+ s.date = %q{2011-03-18}
10
10
  s.description = %q{A gem to access San Francisco's Next Muni API easily}
11
11
  s.email = %q{hjhart@gmail.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/next_muni.rb", "lib/next_muni/api.rb"]
13
- s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "lib/next_muni.rb", "lib/next_muni/api.rb", "Manifest", "next_muni.gemspec"]
13
+ s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "lib/next_muni.rb", "lib/next_muni/api.rb", "next_muni.gemspec", "Manifest"]
14
14
  s.homepage = %q{http://www.github.com/hjhart/next_muni_gem}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Next_muni", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: next_muni
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.1.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Hart
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-16 00:00:00 -07:00
13
+ date: 2011-03-18 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -31,8 +31,8 @@ files:
31
31
  - Rakefile
32
32
  - lib/next_muni.rb
33
33
  - lib/next_muni/api.rb
34
- - Manifest
35
34
  - next_muni.gemspec
35
+ - Manifest
36
36
  has_rdoc: true
37
37
  homepage: http://www.github.com/hjhart/next_muni_gem
38
38
  licenses: []