Skip to content

Commit a216e4f

Browse files
putting things into a gem, adding stub for tests
1 parent 82da72a commit a216e4f

9 files changed

+161
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.project
66
._*
77
.DS_Store
8+
pkg/*

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2010 Scott Windsor
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.rdoc

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
= simplegeo-ruby
2+
3+
Description goes here.
4+
5+
== Note on Patches/Pull Requests
6+
7+
* Fork the project.
8+
* Make your feature addition or bug fix.
9+
* Add tests for it. This is important so I don't break it in a
10+
future version unintentionally.
11+
* Commit, do not mess with rakefile, version, or history.
12+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13+
* Send me a pull request. Bonus points for topic branches.
14+
15+
== Copyright
16+
17+
Copyright (c) 2010 Scott Windsor. See LICENSE for details.

Rakefile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require 'rubygems'
2+
require 'rake'
3+
4+
begin
5+
require 'jeweler'
6+
Jeweler::Tasks.new do |gem|
7+
gem.name = "simplegeo"
8+
gem.summary = %Q{a simplegeo client written in ruby}
9+
gem.description = %Q{a simplegeo client written in ruby}
10+
gem.email = "[email protected]"
11+
gem.homepage = "http://github.com/sentientmonkey/simplegeo-ruby"
12+
gem.authors = ["Scott Windsor"]
13+
gem.add_development_dependency "rspec", ">= 1.2.9"
14+
gem.add_dependency('httparty', '>= 0.5.2')
15+
gem.add_dependency('oauth', '>= 0.3.6')
16+
end
17+
Jeweler::GemcutterTasks.new
18+
rescue LoadError
19+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20+
end
21+
22+
require 'spec/rake/spectask'
23+
Spec::Rake::SpecTask.new(:spec) do |spec|
24+
spec.libs << 'lib' << 'spec'
25+
spec.spec_files = FileList['spec/**/*_spec.rb']
26+
end
27+
28+
Spec::Rake::SpecTask.new(:rcov) do |spec|
29+
spec.libs << 'lib' << 'spec'
30+
spec.pattern = 'spec/**/*_spec.rb'
31+
spec.rcov = true
32+
end
33+
34+
task :spec => :check_dependencies
35+
36+
task :default => :spec
37+
38+
require 'rake/rdoctask'
39+
Rake::RDocTask.new do |rdoc|
40+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
41+
42+
rdoc.rdoc_dir = 'rdoc'
43+
rdoc.title = "simplegeo #{version}"
44+
rdoc.rdoc_files.include('README*')
45+
rdoc.rdoc_files.include('lib/**/*.rb')
46+
end

lib/simplegeo/simplegeo.rb lib/simplegeo.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'rubygems'
2-
3-
require 'oauth'
42
require 'httparty'
3+
require 'oauth'
54

65
class Simplegeo
76
include HTTParty
@@ -10,8 +9,9 @@ class Simplegeo
109

1110
attr_accessor :layer
1211

13-
def self.get_request_token(key, secret)
14-
OAuth::Consumer.new(key,secret, :site => "http://simplegeo.com").get_request_token
12+
def self.get_access_token(key, secret)
13+
consumer = OAuth::Consumer.new(key,secret, :site => base_uri)
14+
OAuth::AccessToken.new(consumer)
1515
end
1616

1717
def initialize(layer)

simplegeo.gemspec

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
Gem::Specification.new do |s|
7+
s.name = %q{simplegeo}
8+
s.version = "0.0.0"
9+
10+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11+
s.authors = ["Scott Windsor"]
12+
s.date = %q{2010-03-05}
13+
s.description = %q{a simplegeo client written in ruby}
14+
s.email = %q{[email protected]}
15+
s.extra_rdoc_files = [
16+
"LICENSE",
17+
"README.rdoc"
18+
]
19+
s.files = [
20+
".gitignore",
21+
"VERSION"
22+
]
23+
s.homepage = %q{http://github.com/sentientmonkey/simplegeo-ruby}
24+
s.rdoc_options = ["--charset=UTF-8"]
25+
s.require_paths = ["lib"]
26+
s.rubygems_version = %q{1.3.5}
27+
s.summary = %q{a simplegeo client written in ruby}
28+
s.test_files = [
29+
"spec/simplegeo_spec.rb",
30+
"spec/spec_helper.rb"
31+
]
32+
33+
if s.respond_to? :specification_version then
34+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
35+
s.specification_version = 3
36+
37+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
38+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
39+
s.add_runtime_dependency(%q<httparty>, [">= 0.5.2"])
40+
s.add_runtime_dependency(%q<oauth>, [">= 0.3.6"])
41+
else
42+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
43+
s.add_dependency(%q<httparty>, [">= 0.5.2"])
44+
s.add_dependency(%q<oauth>, [">= 0.3.6"])
45+
end
46+
else
47+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
48+
s.add_dependency(%q<httparty>, [">= 0.5.2"])
49+
s.add_dependency(%q<oauth>, [">= 0.3.6"])
50+
end
51+
end
52+

spec/simplegeo_spec.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2+
3+
KEY = 'your key'
4+
SECRET = 'your secret'
5+
6+
describe "Simplegeo" do
7+
it "should be able to get an access token" do
8+
access_token = Simplegeo.get_access_token(KEY, SECRET)
9+
puts access_token.get("/records/com.simplegeo.global.flickr/4407858938.json")
10+
end
11+
end

spec/spec.opts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--color

spec/spec_helper.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$LOAD_PATH.unshift(File.dirname(__FILE__))
2+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3+
require 'simplegeo'
4+
require 'spec'
5+
require 'spec/autorun'
6+
7+
Spec::Runner.configure do |config|
8+
9+
end

0 commit comments

Comments
 (0)