petfinder 0.1.0 → 0.1.1
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/Gemfile +9 -0
- data/LICENSE +1 -1
- data/Rakefile +134 -32
- data/lib/petfinder/client.rb +2 -1
- data/lib/petfinder.rb +9 -9
- data/petfinder.gemspec +77 -69
- data/spec/spec_helper.rb +3 -6
- metadata +12 -23
- data/.document +0 -5
- data/.gitignore +0 -21
- data/VERSION +0 -1
- data/spec/spec.opts +0 -1
data/Gemfile
ADDED
data/LICENSE
CHANGED
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
33
|
-
|
34
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
35
|
-
spec.rcov = true
|
22
|
+
def date
|
23
|
+
Date.today.to_s
|
36
24
|
end
|
37
25
|
|
38
|
-
|
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 = "
|
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
|
data/lib/petfinder/client.rb
CHANGED
@@ -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
|
-
|
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.
|
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.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
s.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
"
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
]
|
43
|
-
s.
|
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.
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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 '
|
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
|
-
-
|
10
|
-
version: 0.1.
|
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-
|
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
|
-
-
|
64
|
-
- 3
|
59
|
+
- 2
|
65
60
|
- 0
|
66
|
-
|
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:
|
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
|
-
-
|
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:
|
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
data/.gitignore
DELETED
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|