Skip to content

Commit

Permalink
renaming the project guppy
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Barron committed Oct 29, 2009
1 parent 7eaef7c commit 6d5fc36
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 101 deletions.
11 changes: 5 additions & 6 deletions README.rdoc
@@ -1,10 +1,10 @@
= Garmin - Ruby library for handling tcx files
= Guppy - Ruby library for handling tcx files

This library provides a set of classes for working with tcx dumps from
Garmin devices such as the Forerunner 305.
This library provides a set of classes for working with tcx and gpx
dumps from GPS devices such as the Garmin Forerunner 305.

== Examples
db = Garmin::Db.open('foo.tcx')
db = Guppy::Db.open('foo.tcx')
db.activities.each do |activity|
puts activity.date
end
Expand All @@ -25,15 +25,14 @@ Garmin devices such as the Forerunner 305.
* Get aggregated pace and heart rate signals for an activity
* Make it faster and avoid re-parsing the db in some instances
* A nicer way to find a specific activity
* Support gpx format

= Other Stuff

Author:: Scott Barron <scott at elitists dot net>
License:: Copyright 2009 by Scott Barron.
Released under an MIT-style license. See the MIT-LICENSE
file included in the distribution.
GitHub:: http://github.com/rubyist/garmin/tree/master
GitHub:: http://github.com/rubyist/guppy/tree/master

== Warranty

Expand Down
8 changes: 4 additions & 4 deletions Rakefile
@@ -1,15 +1,15 @@
# Rakefile for garmin -*- ruby -*-
# Rakefile for guppy -*- ruby -*-
require 'rubygems'
require 'rake'

begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = 'garmin'
gemspec.name = 'guppy'
gemspec.summary = 'Ruby library for parsing tcx and gpx files'
gemspec.description = 'foo'
gemspec.email = 'scott@elitists.net'
gemspec.homepage = 'http://github.com/rubyist/garmin'
gemspec.homepage = 'http://github.com/rubyist/guppy'
gemspec.authors = ['Scott Barron']
gemspec.add_development_dependency "thoughtbot-shoulda", ">= 0"
end
Expand Down Expand Up @@ -48,7 +48,7 @@ Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "garmin #{version}"
rdoc.title = "guppy #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
8 changes: 4 additions & 4 deletions garmin.gemspec → guppy.gemspec
Expand Up @@ -4,12 +4,12 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{garmin}
s.name = %q{guppy}
s.version = "0.0.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Scott Barron"]
s.date = %q{2009-10-28}
s.date = %q{2009-10-29}
s.description = %q{foo}
s.email = %q{scott@elitists.net}
s.extra_rdoc_files = [
Expand All @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
"Rakefile",
"VERSION",
"doc/jamis.rb",
"garmin.gemspec",
"guppy.gemspec",
"lib/garmin.rb",
"lib/garmin/activity.rb",
"lib/garmin/db.rb",
Expand All @@ -40,7 +40,7 @@ Gem::Specification.new do |s|
"test/test_tcx_parser.rb",
"test/test_track_point.rb"
]
s.homepage = %q{http://github.com/rubyist/garmin}
s.homepage = %q{http://github.com/rubyist/guppy}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.5}
Expand Down
18 changes: 0 additions & 18 deletions lib/garmin.rb

This file was deleted.

18 changes: 18 additions & 0 deletions lib/guppy.rb
@@ -0,0 +1,18 @@
require 'nokogiri'
require 'time'

require File.join(File.dirname(__FILE__), 'guppy', 'activity')
require File.join(File.dirname(__FILE__), 'guppy', 'track_point')
require File.join(File.dirname(__FILE__), 'guppy', 'tcx_parser')
require File.join(File.dirname(__FILE__), 'guppy', 'gpx_parser')
require File.join(File.dirname(__FILE__), 'guppy', 'db')
require File.join(File.dirname(__FILE__), 'guppy', 'lap')

module Guppy
TCX = 'tcx'
GPX = 'gpx'

def self.version
"0.0.1"
end
end
2 changes: 1 addition & 1 deletion lib/garmin/activity.rb → lib/guppy/activity.rb
@@ -1,4 +1,4 @@
module Garmin
module Guppy
class Activity
attr_accessor :sport
attr_accessor :date
Expand Down
6 changes: 3 additions & 3 deletions lib/garmin/db.rb → lib/guppy/db.rb
@@ -1,4 +1,4 @@
module Garmin
module Guppy
class Db
def self.file_type(file_name)
case File.extname(file_name).downcase
Expand All @@ -24,9 +24,9 @@ def initialize(file)
def parse
case self.class.file_type(@file_name)
when TCX
@doc = Garmin::TcxParser.open(@file_name)
@doc = Guppy::TcxParser.open(@file_name)
when GPX
@doc = Garmin::GpxParser.open(@file_name)
@doc = Guppy::GpxParser.open(@file_name)
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/garmin/gpx_parser.rb → lib/guppy/gpx_parser.rb
@@ -1,4 +1,4 @@
module Garmin
module Guppy
class GpxParser
def self.open(file)
parser = self.new(file)
Expand Down Expand Up @@ -43,7 +43,7 @@ def build_activity(activity_node)
end

def build_lap(lap_node)
lap = Garmin::Lap.new
lap = Guppy::Lap.new
total_distance = 0.0
lap_node.xpath('xmlns:trkpt', namespaces).each do |track_point_node|
track_point = build_track_point(track_point_node, total_distance)
Expand All @@ -55,7 +55,7 @@ def build_lap(lap_node)
end

def build_track_point(track_point_node, total_distance)
track_point = Garmin::TrackPoint.new
track_point = Guppy::TrackPoint.new
track_point.latitude = track_point_node['lat'].to_f
track_point.longitude = track_point_node['lon'].to_f
track_point.altitude = track_point_node.xpath('xmlns:ele', namespaces).inner_text.to_f
Expand Down
2 changes: 1 addition & 1 deletion lib/garmin/lap.rb → lib/guppy/lap.rb
@@ -1,4 +1,4 @@
module Garmin
module Guppy
class Lap
attr_accessor :distance
attr_accessor :max_speed
Expand Down
6 changes: 3 additions & 3 deletions lib/garmin/tcx_parser.rb → lib/guppy/tcx_parser.rb
@@ -1,4 +1,4 @@
module Garmin
module Guppy
class TcxParser
def self.open(file)
parser = self.new(file)
Expand Down Expand Up @@ -45,7 +45,7 @@ def build_activity(activity_node)
end

def build_lap(lap_node)
lap = Garmin::Lap.new
lap = Guppy::Lap.new
lap.distance = lap_node.xpath('xmlns:DistanceMeters', namespaces).inner_text.to_f
lap.max_speed = lap_node.xpath('xmlns:MaximumSpeed', namespaces).inner_text.to_f
lap.time = lap_node.xpath('xmlns:TotalTimeSeconds', namespaces).inner_text.to_f
Expand All @@ -61,7 +61,7 @@ def build_lap(lap_node)
end

def build_track_point(track_point_node)
track_point = Garmin::TrackPoint.new
track_point = Guppy::TrackPoint.new
track_point.latitude = track_point_node.xpath('xmlns:Position/xmlns:LatitudeDegrees', namespaces).inner_text.to_f
track_point.longitude = track_point_node.xpath('xmlns:Position/xmlns:LongitudeDegrees', namespaces).inner_text.to_f
track_point.altitude = track_point_node.xpath('xmlns:AltitudeMeters', namespaces).inner_text.to_f
Expand Down
2 changes: 1 addition & 1 deletion lib/garmin/track_point.rb → lib/guppy/track_point.rb
@@ -1,4 +1,4 @@
module Garmin
module Guppy
class TrackPoint
attr_accessor :latitude
attr_accessor :longitude
Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
Expand Up @@ -6,7 +6,7 @@

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'garmin'
require 'guppy'

def tcx_fixture_file
File.join(File.dirname(__FILE__), 'fixtures', 'example.tcx')
Expand Down
6 changes: 3 additions & 3 deletions test/test_activity.rb
Expand Up @@ -2,20 +2,20 @@

class TestActivity < Test::Unit::TestCase
should "have a date" do
a = Garmin::Activity.new
a = Guppy::Activity.new
t = Time.now
a.date = t
assert_equal t, a.date
end

should "have a distance" do
a = Garmin::Activity.new
a = Guppy::Activity.new
a.laps << flexmock('lap', :distance => 325.5)
assert_equal 325.5, a.distance
end

should "have laps" do
a = Garmin::Activity.new
a = Guppy::Activity.new
assert_equal [], a.laps
end
end
32 changes: 16 additions & 16 deletions test/test_db.rb
Expand Up @@ -3,69 +3,69 @@
class TestDb < Test::Unit::TestCase
context "exist" do
should "exist" do
assert Garmin::Db.new('file.tcx')
assert Guppy::Db.new('file.tcx')
end
end
context "determining file type" do
should "determine tcx for files with a tcx extension" do
assert_equal Garmin::TCX, Garmin::Db.file_type("foo.tcx")
assert_equal Guppy::TCX, Guppy::Db.file_type("foo.tcx")
end

should "determin gpx for files with a gpx extension" do
assert_equal Garmin::GPX, Garmin::Db.file_type("foo.gpx")
assert_equal Guppy::GPX, Guppy::Db.file_type("foo.gpx")
end

should "raise an exception if it can't determine the type" do
assert_raise RuntimeError do
Garmin::Db.file_type('foobar')
Guppy::Db.file_type('foobar')
end
end
end

context "opening database files" do
should "create a new Db object" do
flexmock(Garmin::Db).should_receive(:new).with('foo.tcx').and_return(flexmock('db', :parse => '')).once
flexmock(Guppy::Db).should_receive(:new).with('foo.tcx').and_return(flexmock('db', :parse => '')).once

Garmin::Db.open('foo.tcx')
Guppy::Db.open('foo.tcx')
end

should "parse it" do
db = flexmock('db')
db.should_receive(:parse).once

flexmock(Garmin::Db).should_receive(:new).with('foo.tcx').and_return(db)
flexmock(Guppy::Db).should_receive(:new).with('foo.tcx').and_return(db)

Garmin::Db.open('foo.tcx')
Guppy::Db.open('foo.tcx')
end

should "return the Db object" do
db = flexmock('db', :parse => '')
flexmock(Garmin::Db).should_receive(:new).with('foo.tcx').and_return(db)
flexmock(Guppy::Db).should_receive(:new).with('foo.tcx').and_return(db)

assert_equal db, Garmin::Db.open('foo.tcx')
assert_equal db, Guppy::Db.open('foo.tcx')
end
end

context "parsing" do
should "use TcxParser for tcx files" do
flexmock(Garmin::TcxParser).should_receive(:open).with('foo.tcx').once
Garmin::Db.new('foo.tcx').parse
flexmock(Guppy::TcxParser).should_receive(:open).with('foo.tcx').once
Guppy::Db.new('foo.tcx').parse
end

should "use GpxParser for gpx files" do
flexmock(Garmin::GpxParser).should_receive(:open).with('foo.gpx').once
Garmin::Db.new('foo.gpx').parse
flexmock(Guppy::GpxParser).should_receive(:open).with('foo.gpx').once
Guppy::Db.new('foo.gpx').parse
end
end

context "activities" do
should "have one activity" do
db = Garmin::Db.open(tcx_fixture_file)
db = Guppy::Db.open(tcx_fixture_file)
assert_equal 1, db.activities.size
end

should "find an activity" do
db = Garmin::Db.open(tcx_fixture_file)
db = Guppy::Db.open(tcx_fixture_file)
assert db.activity('2009-01-12T19:28:18Z')
end
end
Expand Down
14 changes: 7 additions & 7 deletions test/test_gpx_parser.rb
Expand Up @@ -3,29 +3,29 @@
class TestGpxParser < Test::Unit::TestCase
context "existence" do
should "exist" do
assert Garmin::GpxParser.new('foo.gpx')
assert Guppy::GpxParser.new('foo.gpx')
end
end

context "opening" do
should "should create the tcx parser object" do
flexmock(Garmin::TcxParser).should_receive(:new).with('foo.tcx').and_return(flexmock('parser', :parse => '')).once
Garmin::TcxParser.open('foo.tcx')
flexmock(Guppy::TcxParser).should_receive(:new).with('foo.tcx').and_return(flexmock('parser', :parse => '')).once
Guppy::TcxParser.open('foo.tcx')
end

should "parse the file" do
parser = flexmock('parser')
parser.should_receive(:parse).once
flexmock(Garmin::TcxParser).should_receive(:new).and_return(parser)
flexmock(Guppy::TcxParser).should_receive(:new).and_return(parser)

Garmin::TcxParser.open('foo.tcx')
Guppy::TcxParser.open('foo.tcx')
end

should "return the TcxParser object" do
parser = flexmock('parser', :parse => '')
flexmock(Garmin::TcxParser).should_receive(:new).with('foo.tcx').and_return(parser)
flexmock(Guppy::TcxParser).should_receive(:new).with('foo.tcx').and_return(parser)

assert_equal parser, Garmin::TcxParser.open('foo.tcx')
assert_equal parser, Guppy::TcxParser.open('foo.tcx')
end
end
end
4 changes: 2 additions & 2 deletions test/test_garmin.rb → test/test_guppy.rb
@@ -1,9 +1,9 @@
require 'helper'

class TestGarmin < Test::Unit::TestCase
class TestGuppy < Test::Unit::TestCase
context "methods" do
should "have a version" do
assert Garmin.version
assert Guppy.version
end
end

Expand Down

1 comment on commit 6d5fc36

@vasilakisfil
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to update the gemspec file

Please sign in to comment.