posterboard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem "httparty", ">= 0.6.1"
6
+
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem "rspec", "~> 2.3.0"
11
+ gem "yard", "~> 0.6.0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.0"
14
+ gem "rcov", ">= 0"
15
+ gem "webmock", ">= 1.6.2"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.2.5)
5
+ crack (0.1.8)
6
+ diff-lcs (1.1.2)
7
+ git (1.2.5)
8
+ httparty (0.7.7)
9
+ crack (= 0.1.8)
10
+ jeweler (1.6.0)
11
+ bundler (~> 1.0.0)
12
+ git (>= 1.2.5)
13
+ rake
14
+ rake (0.8.7)
15
+ rcov (0.9.9)
16
+ rspec (2.3.0)
17
+ rspec-core (~> 2.3.0)
18
+ rspec-expectations (~> 2.3.0)
19
+ rspec-mocks (~> 2.3.0)
20
+ rspec-core (2.3.1)
21
+ rspec-expectations (2.3.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.3.0)
24
+ webmock (1.6.2)
25
+ addressable (>= 2.2.2)
26
+ crack (>= 0.1.7)
27
+ yard (0.6.8)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.0.0)
34
+ httparty (>= 0.6.1)
35
+ jeweler (~> 1.6.0)
36
+ rcov
37
+ rspec (~> 2.3.0)
38
+ webmock (>= 1.6.2)
39
+ yard (~> 0.6.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Waylon Calabrese
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.
data/README.rdoc ADDED
@@ -0,0 +1,38 @@
1
+ = posterboard
2
+
3
+ Ruby API for reading posts from your Posterous account.
4
+
5
+ == How To
6
+ Install the gem
7
+ [sudo] gem install posterboard
8
+
9
+ Create a connection
10
+ connection = Posterboard::Connection.new('turkey2000', 'g0bbl3g0bbl3')
11
+
12
+ Get posts by site name
13
+ connection.turkey_blog.each do |post|
14
+ title = post[:title]
15
+ body = post[:body]
16
+ end
17
+
18
+ == Future features
19
+ * Command line tools for retrieving API token and site id. Library interfaces accepting these constants so they are not looked up on each request.
20
+
21
+ == Note
22
+ Since I am personally using this library to retrieve posts and display them on another site, I do not have any immediate plans to support posting to an account. I plan on using Posterous' email API to do that. Someone is welcome to fork and add that feature.
23
+
24
+ == Contributing to posterboard
25
+
26
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
27
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
28
+ * Fork the project
29
+ * Start a feature/bugfix branch
30
+ * Commit and push until you are happy with your contribution
31
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
32
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
33
+
34
+ == Copyright
35
+
36
+ Copyright (c) 2011 Waylon Calabrese. See LICENSE.txt for
37
+ further details.
38
+
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "posterboard"
18
+ gem.homepage = "http://github.com/hiwaylon/posterboard"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby API for reading posts from your Posterous account.}
21
+ gem.description = %Q{Ruby API for reading posts from your Posterous account.}
22
+ gem.email = "hiwaylon@gmail.com"
23
+ gem.authors = ["Waylon Calabrese"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'yard'
42
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1 @@
1
+ require 'posterboard/connection'
@@ -0,0 +1,38 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ module Posterboard
5
+ class Connection
6
+ include HTTParty
7
+ base_uri 'http://www.posterous.com/api/2'
8
+ # default behavior is to query the API key upon initialization
9
+ def initialize(username, password)
10
+ Connection.basic_auth username, password
11
+ # get the API token
12
+ response = Connection.get('/auth/token')
13
+ Connection.default_params :api_token => response['api_token']
14
+ end
15
+
16
+ # try to find posts on a site with a name that matches the method name
17
+ # posts are returned as an array of hashes each with a :title and :body
18
+ def method_missing(name)
19
+ site = sites.find { |site| site['name'] == name.to_s }
20
+ # => TODO : Error checking that site is valid and has "id".
21
+ response = Connection.get("/users/me/sites/#{site["id"]}/posts")
22
+ posts = []
23
+ ::JSON.parse(response.body).each do |body|
24
+ post = {}
25
+ post[:title] = body['title']
26
+ post[:body] = body['body_full']
27
+ posts << post
28
+ end
29
+ posts
30
+ end
31
+
32
+ private
33
+
34
+ def sites
35
+ Connection.get('/users/me/sites')
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{posterboard}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Waylon Calabrese"]
12
+ s.date = %q{2011-05-11}
13
+ s.description = %q{Ruby API for reading posts from your Posterous account.}
14
+ s.email = %q{hiwaylon@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/posterboard.rb",
29
+ "lib/posterboard/connection.rb",
30
+ "posterboard.gemspec",
31
+ "spec/posterboard/connection_spec.rb",
32
+ "spec/spec_helper.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/hiwaylon/posterboard}
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.7}
38
+ s.summary = %q{Ruby API for reading posts from your Posterous account.}
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<httparty>, [">= 0.6.1"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
47
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
50
+ s.add_development_dependency(%q<rcov>, [">= 0"])
51
+ s.add_development_dependency(%q<webmock>, [">= 1.6.2"])
52
+ else
53
+ s.add_dependency(%q<httparty>, [">= 0.6.1"])
54
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
55
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
58
+ s.add_dependency(%q<rcov>, [">= 0"])
59
+ s.add_dependency(%q<webmock>, [">= 1.6.2"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<httparty>, [">= 0.6.1"])
63
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ s.add_dependency(%q<webmock>, [">= 1.6.2"])
69
+ end
70
+ end
71
+
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Posterboard::Connection do
4
+ before do
5
+ username = 'user'
6
+ password = 'pass'
7
+ stub_request(:get, "http://#{username}:#{password}@www.posterous.com/api/2/auth/token")
8
+ stub_request(:get, "http://#{username}:#{password}@www.posterous.com/api/2/auth/token?api_token=")
9
+ stub_request(:get, "http://#{username}:#{password}@www.posterous.com/api/2/users/me/sites?api_token=").
10
+ to_return(:status => 200,
11
+ :body => [{"id" => "1234", "name" => "your_site_name"}, {"id" => "5678", "name" => "another_site_name"}])
12
+ stub_request(:get, "http://#{username}:#{password}@www.posterous.com/api/2/users/me/sites/1234/posts?api_token=").
13
+ to_return(:status => 200,
14
+ :body => [{:title => "ad litora", :body_full => "lorem ipsum"}, {:title => "sociosqu torquent", :body_full => "dolor set"}].to_json)
15
+ @connection = Posterboard::Connection.new(username, password)
16
+ end
17
+
18
+ context "when accessing sites by name" do
19
+ it "should find a site by name" do
20
+ @connection.your_site_name.should_not be_nil
21
+ end
22
+ end
23
+
24
+ context "when accessing posts" do
25
+ it "should provide post enumeration" do
26
+ @connection.your_site_name.each do |post|
27
+ post.should_not be_nil
28
+ end
29
+ end
30
+
31
+ it "should should give access to the posts' data" do
32
+ @connection.your_site_name.each do |post|
33
+ post[:title].should_not be_nil
34
+ post[:body].should_not be_nil
35
+ end
36
+ end
37
+ end
38
+ end
39
+
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'posterboard'
5
+ require 'webmock/rspec'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: posterboard
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Waylon Calabrese
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-11 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ prerelease: false
24
+ name: httparty
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 5
31
+ segments:
32
+ - 0
33
+ - 6
34
+ - 1
35
+ version: 0.6.1
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ type: :development
39
+ prerelease: false
40
+ name: rspec
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 2
49
+ - 3
50
+ - 0
51
+ version: 2.3.0
52
+ requirement: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ type: :development
55
+ prerelease: false
56
+ name: yard
57
+ version_requirements: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ hash: 7
63
+ segments:
64
+ - 0
65
+ - 6
66
+ - 0
67
+ version: 0.6.0
68
+ requirement: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ type: :development
71
+ prerelease: false
72
+ name: bundler
73
+ version_requirements: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ hash: 23
79
+ segments:
80
+ - 1
81
+ - 0
82
+ - 0
83
+ version: 1.0.0
84
+ requirement: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ type: :development
87
+ prerelease: false
88
+ name: jeweler
89
+ version_requirements: &id005 !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ hash: 15
95
+ segments:
96
+ - 1
97
+ - 6
98
+ - 0
99
+ version: 1.6.0
100
+ requirement: *id005
101
+ - !ruby/object:Gem::Dependency
102
+ type: :development
103
+ prerelease: false
104
+ name: rcov
105
+ version_requirements: &id006 !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ requirement: *id006
115
+ - !ruby/object:Gem::Dependency
116
+ type: :development
117
+ prerelease: false
118
+ name: webmock
119
+ version_requirements: &id007 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 11
125
+ segments:
126
+ - 1
127
+ - 6
128
+ - 2
129
+ version: 1.6.2
130
+ requirement: *id007
131
+ description: Ruby API for reading posts from your Posterous account.
132
+ email: hiwaylon@gmail.com
133
+ executables: []
134
+
135
+ extensions: []
136
+
137
+ extra_rdoc_files:
138
+ - LICENSE.txt
139
+ - README.rdoc
140
+ files:
141
+ - .document
142
+ - .rspec
143
+ - Gemfile
144
+ - Gemfile.lock
145
+ - LICENSE.txt
146
+ - README.rdoc
147
+ - Rakefile
148
+ - VERSION
149
+ - lib/posterboard.rb
150
+ - lib/posterboard/connection.rb
151
+ - posterboard.gemspec
152
+ - spec/posterboard/connection_spec.rb
153
+ - spec/spec_helper.rb
154
+ has_rdoc: true
155
+ homepage: http://github.com/hiwaylon/posterboard
156
+ licenses:
157
+ - MIT
158
+ post_install_message:
159
+ rdoc_options: []
160
+
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ hash: 3
178
+ segments:
179
+ - 0
180
+ version: "0"
181
+ requirements: []
182
+
183
+ rubyforge_project:
184
+ rubygems_version: 1.3.7
185
+ signing_key:
186
+ specification_version: 3
187
+ summary: Ruby API for reading posts from your Posterous account.
188
+ test_files: []
189
+