petfinder 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source :rubygems
2
+
3
+ gem 'httparty', '~>0.5.0'
4
+ gem 'happymapper', '~>0.3.2'
5
+
6
+ group :development do
7
+ gem 'fakeweb', '~>1.2.5'
8
+ gem 'rspec', '~>2.0.pre'
9
+ end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Eric Hutzelman
1
+ Copyright (c) Eric Hutzelman
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,50 +1,152 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'date'
4
+ require 'rspec'
5
+ require 'rspec/core/rake_task'
3
6
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "petfinder"
8
- gem.summary = %Q{Ruby gem wrapper for the Petfinder API}
9
- gem.description = %Q{Ruby gem wrapper for the Petfinder API}
10
- gem.email = "ehutzelman@gmail.com"
11
- gem.homepage = "http://github.com/ehutzelman/petfinder"
12
- gem.authors = ["Eric Hutzelman"]
13
-
14
- gem.add_dependency('happymapper', '>= 0.3.2')
15
- gem.add_dependency('httparty', '>= 0.5.0')
16
-
17
- gem.add_development_dependency "rspec", ">= 1.3.0"
18
- gem.add_development_dependency 'fakeweb', '>= 1.2.5'
19
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
20
- end
21
- Jeweler::GemcutterTasks.new
22
- rescue LoadError
23
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
7
+ #############################################################################
8
+ #
9
+ # Helper functions
10
+ #
11
+ #############################################################################
12
+
13
+ def name
14
+ @name ||= Dir['*.gemspec'].first.split('.').first
24
15
  end
25
16
 
26
- require 'spec/rake/spectask'
27
- Spec::Rake::SpecTask.new(:spec) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.spec_files = FileList['spec/**/*_spec.rb']
17
+ def version
18
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
19
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
30
20
  end
31
21
 
32
- Spec::Rake::SpecTask.new(:rcov) do |spec|
33
- spec.libs << 'lib' << 'spec'
34
- spec.pattern = 'spec/**/*_spec.rb'
35
- spec.rcov = true
22
+ def date
23
+ Date.today.to_s
36
24
  end
37
25
 
38
- task :spec => :check_dependencies
26
+ def rubyforge_project
27
+ name
28
+ end
29
+
30
+ def gemspec_file
31
+ "#{name}.gemspec"
32
+ end
33
+
34
+ def gem_file
35
+ "#{name}-#{version}.gem"
36
+ end
37
+
38
+ def replace_header(head, header_name)
39
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
40
+ end
41
+
42
+ #############################################################################
43
+ #
44
+ # Standard tasks
45
+ #
46
+ #############################################################################
39
47
 
40
48
  task :default => :spec
41
49
 
50
+ Rspec::Core::RakeTask.new(:spec) do |spec|
51
+ spec.pattern = "spec/**/*_spec.rb"
52
+ end
53
+
54
+ # require 'rake/testtask'
55
+ # Rake::TestTask.new(:test) do |test|
56
+ # test.libs << 'lib' << 'test'
57
+ # test.pattern = 'test/**/test_*.rb'
58
+ # test.verbose = true
59
+ # end
60
+
61
+ # desc "Generate RCov test coverage and open in your browser"
62
+ # task :coverage do
63
+ # require 'rcov'
64
+ # sh "rm -fr coverage"
65
+ # sh "rcov test/test_*.rb"
66
+ # sh "open coverage/index.html"
67
+ # end
68
+
42
69
  require 'rake/rdoctask'
43
70
  Rake::RDocTask.new do |rdoc|
44
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
-
46
71
  rdoc.rdoc_dir = 'rdoc'
47
- rdoc.title = "petfinder #{version}"
72
+ rdoc.title = "#{name} #{version}"
48
73
  rdoc.rdoc_files.include('README*')
49
74
  rdoc.rdoc_files.include('lib/**/*.rb')
50
75
  end
76
+
77
+ desc "Open an irb session preloaded with this library"
78
+ task :console do
79
+ sh "irb -rubygems -r ./lib/#{name}.rb"
80
+ end
81
+
82
+ #############################################################################
83
+ #
84
+ # Custom tasks (add your own tasks here)
85
+ #
86
+ #############################################################################
87
+
88
+
89
+
90
+ #############################################################################
91
+ #
92
+ # Packaging tasks
93
+ #
94
+ #############################################################################
95
+
96
+ task :release => :build do
97
+ unless `git branch` =~ /^\* master$/
98
+ puts "You must be on the master branch to release!"
99
+ exit!
100
+ end
101
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
102
+ sh "git tag v#{version}"
103
+ sh "git push origin master"
104
+ sh "git push origin v#{version}"
105
+ sh "gem push pkg/#{name}-#{version}.gem"
106
+ end
107
+
108
+ task :build => :gemspec do
109
+ sh "mkdir -p pkg"
110
+ sh "gem build #{gemspec_file}"
111
+ sh "mv #{gem_file} pkg"
112
+ end
113
+
114
+ task :gemspec => :validate do
115
+ # read spec file and split out manifest section
116
+ spec = File.read(gemspec_file)
117
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
118
+
119
+ # replace name version and date
120
+ replace_header(head, :name)
121
+ replace_header(head, :version)
122
+ replace_header(head, :date)
123
+ #comment this out if your rubyforge_project has a different name
124
+ replace_header(head, :rubyforge_project)
125
+
126
+ # determine file list from git ls-files
127
+ files = `git ls-files`.
128
+ split("\n").
129
+ sort.
130
+ reject { |file| file =~ /^\./ }.
131
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
132
+ map { |file| " #{file}" }.
133
+ join("\n")
134
+
135
+ # piece file back together and write
136
+ manifest = " s.files = %w[\n#{files}\n ]\n"
137
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
138
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
139
+ puts "Updated #{gemspec_file}"
140
+ end
141
+
142
+ task :validate do
143
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
144
+ unless libfiles.empty?
145
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
146
+ exit!
147
+ end
148
+ unless Dir['VERSION*'].empty?
149
+ puts "A `VERSION` file at root level violates Gem best practices."
150
+ exit!
151
+ end
152
+ end
@@ -25,7 +25,8 @@ module Petfinder
25
25
 
26
26
  # Options available: animal, breed, size, sex, location, shelterid
27
27
  def random_pet(options = {})
28
- response = perform_get("/pet.getRandom", :query => {:output => 'full'})
28
+ query = options.merge(:output => 'full')
29
+ response = perform_get("/pet.getRandom", :query => query)
29
30
  Pet.parse(response, :single => true)
30
31
  end
31
32
 
data/lib/petfinder.rb CHANGED
@@ -2,14 +2,21 @@ require 'httparty'
2
2
  require 'happymapper'
3
3
  require 'digest/md5'
4
4
 
5
+ require 'petfinder/client'
6
+ require 'petfinder/pet'
7
+ require 'petfinder/breeds'
8
+ require 'petfinder/shelter'
9
+ require 'petfinder/auth'
10
+
5
11
  module Petfinder
6
-
12
+ VERSION = '0.1.1'
13
+
7
14
  class PetfinderError < StandardError; end
8
15
 
9
16
  class << self
10
17
  attr_accessor :api_key, :api_secret
11
18
  end
12
-
19
+
13
20
  def self.configure
14
21
  yield self
15
22
  true
@@ -17,10 +24,3 @@ module Petfinder
17
24
 
18
25
  end
19
26
 
20
- directory = File.expand_path(File.dirname(__FILE__))
21
-
22
- require File.join(directory, 'petfinder', 'client')
23
- require File.join(directory, 'petfinder', 'pet')
24
- require File.join(directory, 'petfinder', 'breeds')
25
- require File.join(directory, 'petfinder', 'shelter')
26
- require File.join(directory, 'petfinder', 'auth')
data/petfinder.gemspec CHANGED
@@ -1,75 +1,83 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
1
  Gem::Specification.new do |s|
7
- s.name = %q{petfinder}
8
- s.version = "0.1.0"
9
-
2
+ s.specification_version = 2 if s.respond_to? :specification_version=
10
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Eric Hutzelman"]
12
- s.date = %q{2010-07-09}
13
- s.description = %q{Ruby gem wrapper for the Petfinder API}
14
- s.email = %q{ehutzelman@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/petfinder.rb",
27
- "lib/petfinder/auth.rb",
28
- "lib/petfinder/breeds.rb",
29
- "lib/petfinder/client.rb",
30
- "lib/petfinder/pet.rb",
31
- "lib/petfinder/shelter.rb",
32
- "petfinder.gemspec",
33
- "spec/fixtures/auth.xml",
34
- "spec/fixtures/breed_list.xml",
35
- "spec/fixtures/pet.xml",
36
- "spec/fixtures/pet_list.xml",
37
- "spec/fixtures/shelter.xml",
38
- "spec/fixtures/shelter_list.xml",
39
- "spec/petfinder_spec.rb",
40
- "spec/spec.opts",
41
- "spec/spec_helper.rb"
42
- ]
43
- s.homepage = %q{http://github.com/ehutzelman/petfinder}
4
+ s.rubygems_version = '1.3.5'
5
+
6
+ ## Leave these as is they will be modified for you by the rake gemspec task.
7
+ ## If your rubyforge_project name is different, then edit it and comment out
8
+ ## the sub! line in the Rakefile
9
+ s.name = 'petfinder'
10
+ s.version = '0.1.1'
11
+ s.date = '2010-09-22'
12
+ s.rubyforge_project = 'petfinder'
13
+
14
+ ## Make sure your summary is short. The description may be as long
15
+ ## as you like.
16
+ s.summary = "Ruby gem wrapper for the Petfinder API."
17
+ #s.description = "Ruby gem wrapper for the Petfinder API."
18
+
19
+ ## List the primary authors. If there are a bunch of authors, it's probably
20
+ ## better to set the email to an email list or something. If you don't have
21
+ ## a custom homepage, consider using your GitHub URL or the like.
22
+ s.authors = ["Eric Hutzelman"]
23
+ s.email = 'ehutzelman@gmail.com'
24
+ s.homepage = 'http://github.com/ehutzelman/petfinder'
25
+
26
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
27
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
28
+ s.require_paths = %w[lib]
29
+
30
+ ## This sections is only necessary if you have C extensions.
31
+ # s.require_paths << 'ext'
32
+ # s.extensions = %w[ext/extconf.rb]
33
+
34
+ ## If your gem includes any executables, list them here.
35
+ # s.executables = ["name"]
36
+ # s.default_executable = 'name'
37
+
38
+ ## Specify any RDoc options here. You'll want to add your README and
39
+ ## LICENSE files to the extra_rdoc_files list.
44
40
  s.rdoc_options = ["--charset=UTF-8"]
45
- s.require_paths = ["lib"]
46
- s.rubygems_version = %q{1.3.7}
47
- s.summary = %q{Ruby gem wrapper for the Petfinder API}
48
- s.test_files = [
49
- "spec/petfinder_spec.rb",
50
- "spec/spec_helper.rb"
51
- ]
41
+ s.extra_rdoc_files = %w[README.rdoc LICENSE]
52
42
 
53
- if s.respond_to? :specification_version then
54
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
- s.specification_version = 3
43
+ ## List your runtime dependencies here. Runtime dependencies are those
44
+ ## that are needed for an end user to actually USE your code.
45
+ s.add_dependency('happymapper', [">= 0.3.2"])
46
+ s.add_dependency('httparty', [">= 0.5.0"])
56
47
 
57
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
- s.add_runtime_dependency(%q<happymapper>, [">= 0.3.2"])
59
- s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
60
- s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
61
- s.add_development_dependency(%q<fakeweb>, [">= 1.2.5"])
62
- else
63
- s.add_dependency(%q<happymapper>, [">= 0.3.2"])
64
- s.add_dependency(%q<httparty>, [">= 0.5.0"])
65
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
66
- s.add_dependency(%q<fakeweb>, [">= 1.2.5"])
67
- end
68
- else
69
- s.add_dependency(%q<happymapper>, [">= 0.3.2"])
70
- s.add_dependency(%q<httparty>, [">= 0.5.0"])
71
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
72
- s.add_dependency(%q<fakeweb>, [">= 1.2.5"])
73
- end
74
- end
48
+ ## List your development dependencies here. Development dependencies are
49
+ ## those that are only needed during development
50
+ s.add_development_dependency('rspec', [">= 2.0.pre"])
51
+ s.add_development_dependency('fakeweb', [">= 1.2.5"])
52
+
53
+ ## Leave this section as-is. It will be automatically generated from the
54
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
55
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
56
+ # = MANIFEST =
57
+ s.files = %w[
58
+ Gemfile
59
+ LICENSE
60
+ README.rdoc
61
+ Rakefile
62
+ lib/petfinder.rb
63
+ lib/petfinder/auth.rb
64
+ lib/petfinder/breeds.rb
65
+ lib/petfinder/client.rb
66
+ lib/petfinder/pet.rb
67
+ lib/petfinder/shelter.rb
68
+ petfinder.gemspec
69
+ spec/fixtures/auth.xml
70
+ spec/fixtures/breed_list.xml
71
+ spec/fixtures/pet.xml
72
+ spec/fixtures/pet_list.xml
73
+ spec/fixtures/shelter.xml
74
+ spec/fixtures/shelter_list.xml
75
+ spec/petfinder_spec.rb
76
+ spec/spec_helper.rb
77
+ ]
78
+ # = MANIFEST =
75
79
 
80
+ ## Test files will be grabbed from the file list. Make sure the path glob
81
+ ## matches what you actually use.
82
+ s.test_files = s.files.select { |path| path =~ /^spec\/.*_spec\.rb/ }
83
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,20 +1,17 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
3
4
  require 'rubygems'
4
5
  require 'petfinder'
5
- require 'spec'
6
- require 'spec/autorun'
6
+ require 'rspec'
7
7
  require 'fakeweb'
8
8
 
9
- Spec::Runner.configure do |config|
10
- end
11
-
12
9
  def fixture_file(filename)
13
10
  File.read(File.dirname(__FILE__) + "/fixtures/#{filename}")
14
11
  end
15
12
 
16
13
  def stub_get(url, filename, options={})
17
14
  opts = {:body => fixture_file(filename)}.merge(options)
18
-
15
+
19
16
  FakeWeb.register_uri(:get, url, opts)
20
17
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petfinder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 0
10
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Eric Hutzelman
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-07-09 00:00:00 -05:00
17
+ date: 2010-09-22 00:00:00 -05:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 23
30
28
  segments:
31
29
  - 0
32
30
  - 3
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 11
46
43
  segments:
47
44
  - 0
48
45
  - 5
@@ -58,12 +55,11 @@ dependencies:
58
55
  requirements:
59
56
  - - ">="
60
57
  - !ruby/object:Gem::Version
61
- hash: 27
62
58
  segments:
63
- - 1
64
- - 3
59
+ - 2
65
60
  - 0
66
- version: 1.3.0
61
+ - pre
62
+ version: 2.0.pre
67
63
  type: :development
68
64
  version_requirements: *id003
69
65
  - !ruby/object:Gem::Dependency
@@ -74,7 +70,6 @@ dependencies:
74
70
  requirements:
75
71
  - - ">="
76
72
  - !ruby/object:Gem::Version
77
- hash: 21
78
73
  segments:
79
74
  - 1
80
75
  - 2
@@ -82,22 +77,20 @@ dependencies:
82
77
  version: 1.2.5
83
78
  type: :development
84
79
  version_requirements: *id004
85
- description: Ruby gem wrapper for the Petfinder API
80
+ description:
86
81
  email: ehutzelman@gmail.com
87
82
  executables: []
88
83
 
89
84
  extensions: []
90
85
 
91
86
  extra_rdoc_files:
92
- - LICENSE
93
87
  - README.rdoc
88
+ - LICENSE
94
89
  files:
95
- - .document
96
- - .gitignore
90
+ - Gemfile
97
91
  - LICENSE
98
92
  - README.rdoc
99
93
  - Rakefile
100
- - VERSION
101
94
  - lib/petfinder.rb
102
95
  - lib/petfinder/auth.rb
103
96
  - lib/petfinder/breeds.rb
@@ -112,7 +105,6 @@ files:
112
105
  - spec/fixtures/shelter.xml
113
106
  - spec/fixtures/shelter_list.xml
114
107
  - spec/petfinder_spec.rb
115
- - spec/spec.opts
116
108
  - spec/spec_helper.rb
117
109
  has_rdoc: true
118
110
  homepage: http://github.com/ehutzelman/petfinder
@@ -128,7 +120,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
120
  requirements:
129
121
  - - ">="
130
122
  - !ruby/object:Gem::Version
131
- hash: 3
132
123
  segments:
133
124
  - 0
134
125
  version: "0"
@@ -137,17 +128,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
128
  requirements:
138
129
  - - ">="
139
130
  - !ruby/object:Gem::Version
140
- hash: 3
141
131
  segments:
142
132
  - 0
143
133
  version: "0"
144
134
  requirements: []
145
135
 
146
- rubyforge_project:
136
+ rubyforge_project: petfinder
147
137
  rubygems_version: 1.3.7
148
138
  signing_key:
149
- specification_version: 3
150
- summary: Ruby gem wrapper for the Petfinder API
139
+ specification_version: 2
140
+ summary: Ruby gem wrapper for the Petfinder API.
151
141
  test_files:
152
142
  - spec/petfinder_spec.rb
153
- - spec/spec_helper.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.0
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color