progressions-postly 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/LICENSE +22 -0
- data/README.markdown +118 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/bin/postly +23 -0
- data/config/posterous.sample.yml +2 -0
- data/etc/posterous.tmbundle/Commands/Post Selection.tmCommand +39 -0
- data/etc/posterous.tmbundle/info.plist +10 -0
- data/lib/postly.rb +39 -0
- data/lib/postly/blog_importer.rb +38 -0
- data/lib/postly/comment.rb +17 -0
- data/lib/postly/connection.rb +50 -0
- data/lib/postly/many_proxy.rb +21 -0
- data/lib/postly/post.rb +47 -0
- data/lib/postly/site.rb +29 -0
- data/postly.gemspec +77 -0
- data/progressions-postly.gemspec +78 -0
- data/test/fixtures/cthulhu.png +0 -0
- data/test/fixtures/fennec-fox.jpg +0 -0
- data/test/fixtures/wp.xml +137 -0
- data/test/growler.rb +9 -0
- data/test/test_helper.rb +11 -0
- data/test/test_importer.rb +36 -0
- data/test/test_post.rb +40 -0
- data/test/test_site.rb +72 -0
- metadata +105 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
The MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/README.markdown
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
postly
|
2
|
+
---------
|
3
|
+
API wrapper for the [posterous.com](http://posterous.com/api "Postly API") API.
|
4
|
+
|
5
|
+
|
6
|
+
###Install & Setup
|
7
|
+
|
8
|
+
postly is hosted on [gemcutter.org](http://gemcutter.org). The source is available at [http://github.com/twoism/postly](http://github.com/twoism/postly).
|
9
|
+
|
10
|
+
$ gem install postly
|
11
|
+
|
12
|
+
Create the YAML file.
|
13
|
+
|
14
|
+
username: email
|
15
|
+
password: pass
|
16
|
+
|
17
|
+
And pass it into config.
|
18
|
+
|
19
|
+
Postly.config = "#{ENV['HOME']}/.posterous"
|
20
|
+
|
21
|
+
The postly console looks for `.posterous` in your home directory.
|
22
|
+
|
23
|
+
|
24
|
+
###Usage
|
25
|
+
|
26
|
+
# launch the postly console
|
27
|
+
$ postly
|
28
|
+
|
29
|
+
### In IRB
|
30
|
+
|
31
|
+
> my_sites = Postly::Site.find
|
32
|
+
=> [#<Postly::Site:0x1015a8d48 @num_posts="21", @commentsenabled="true",@name="twoism",
|
33
|
+
@private="false", @url="http://twoism.posterous.com", @hostname="twoism", @id="85691", @primary="true">]
|
34
|
+
|
35
|
+
> my_sites.first.posts.create(:title => "New API Post", :body => "Post body")
|
36
|
+
=> <Postly::Post:0x102541f70 @title="New API Post">
|
37
|
+
|
38
|
+
> post = Postly::Post.create(:site_id => my_sites.first.id, :title => "New API Post", :body => "Post body")
|
39
|
+
=> <Postly::Post:0x102541f70 @title="New API Post">
|
40
|
+
|
41
|
+
> post.comments.create(:comment => "New Comment", :email => "some@one.com")
|
42
|
+
=> <Postly::Comment:0x102541f70 @id=123456>
|
43
|
+
|
44
|
+
> Postly::Post.update(post.id, :title => "New Title", :body => "New Body")
|
45
|
+
=> <Postly::Post:0x102541f70 @title="New Title">
|
46
|
+
|
47
|
+
### TextMate Integration
|
48
|
+
|
49
|
+
|
50
|
+
A TextMate bundle can be found in the `etc/` directory. After installing to TextMate press `⌥+⌘-p` to post any selection to your posterous blog. The bundle looks for `.posterous` in your HOME directory for login info.
|
51
|
+
|
52
|
+
###Blog Importing
|
53
|
+
Blogs can be imported from any XML data that can be mapped to a Post's attributes. If any element needs special treatment, just implement
|
54
|
+
a #process\_<attr_name> method class method on your sub-class.
|
55
|
+
|
56
|
+
###The Importer Sub-class
|
57
|
+
|
58
|
+
class WordPressBlogImporter < Postly::BlogImporter
|
59
|
+
|
60
|
+
# map values from the xml to the post attrs
|
61
|
+
# that you would like to set.
|
62
|
+
def self.entity_map
|
63
|
+
{ :entry => "item", :body => "encoded", :title => "title" }
|
64
|
+
end
|
65
|
+
|
66
|
+
# any post attr can be pre-processed during import.
|
67
|
+
def self.process_body item
|
68
|
+
CGI.unescapeHTML(item.css("encoded").to_s).gsub(/<encoded>|<\/encoded>|\]\]>/,"")
|
69
|
+
end
|
70
|
+
|
71
|
+
# extract tags from the node if needed
|
72
|
+
def self.handle_tags_for node
|
73
|
+
node.css("category").css("category").collect \
|
74
|
+
{ |n| n.attributes["nicename"].text if n.attributes["nicename"].present? }.compact!.join(",")
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.handle_comments post, node; end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
@dir = File.dirname(__FILE__) + '/fixtures'
|
83
|
+
@wp_xml = File.open("#{@dir}/wp.xml", 'r')
|
84
|
+
|
85
|
+
WordPressBlogImporter.import @wp_xml.read, Postly::Site.find.last.id
|
86
|
+
|
87
|
+
###License
|
88
|
+
|
89
|
+
The MIT License
|
90
|
+
|
91
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
92
|
+
of this software and associated documentation files (the "Software"), to deal
|
93
|
+
in the Software without restriction, including without limitation the rights
|
94
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
95
|
+
copies of the Software, and to permit persons to whom the Software is
|
96
|
+
furnished to do so, subject to the following conditions:
|
97
|
+
|
98
|
+
The above copyright notice and this permission notice shall be included in
|
99
|
+
all copies or substantial portions of the Software.
|
100
|
+
|
101
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
102
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
103
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
104
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
105
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
106
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
107
|
+
THE SOFTWARE.
|
108
|
+
|
109
|
+
|
110
|
+
###Credits
|
111
|
+
christopher burnett ( github.com/twoism || twoism.posterous.com )
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |g|
|
9
|
+
|
10
|
+
g.name = 'progressions-postly'
|
11
|
+
g.summary = %(API Wrapper for posterous.com)
|
12
|
+
g.description = %(API Wrapper and IRB console for posterous.com)
|
13
|
+
g.email = 'signalstatic@gmail.com'
|
14
|
+
g.homepage = 'http://github.com/progressions/postly'
|
15
|
+
g.authors = %w(twoism progressions)
|
16
|
+
|
17
|
+
g.add_dependency 'nokogiri'
|
18
|
+
g.add_dependency 'httparty'
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts 'Jeweler not available. Install it with: sudo gem install jeweler'
|
23
|
+
end
|
24
|
+
|
25
|
+
Rake::TestTask.new do |t|
|
26
|
+
t.libs = %w(lib)
|
27
|
+
t.pattern = 'test/*_test.rb'
|
28
|
+
end
|
29
|
+
|
30
|
+
task :default => :test
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.2
|
data/bin/postly
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
%w{rubygems postly irb}.each { |f| require f }
|
3
|
+
|
4
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
5
|
+
|
6
|
+
Postly.config = "#{ENV['HOME']}/.posterous"
|
7
|
+
|
8
|
+
include Postly
|
9
|
+
|
10
|
+
IRB.setup(nil)
|
11
|
+
irb = IRB::Irb.new
|
12
|
+
|
13
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
14
|
+
|
15
|
+
irb.context.evaluate("require 'irb/completion'", 0)
|
16
|
+
|
17
|
+
trap("SIGINT") do
|
18
|
+
irb.signal_handle
|
19
|
+
end
|
20
|
+
|
21
|
+
catch(:IRB_EXIT) do
|
22
|
+
irb.eval_input
|
23
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>beforeRunningCommand</key>
|
6
|
+
<string>nop</string>
|
7
|
+
<key>command</key>
|
8
|
+
<string>#!/usr/bin/env ruby
|
9
|
+
|
10
|
+
require 'rubygems'
|
11
|
+
require 'posterous'
|
12
|
+
|
13
|
+
Postly.config = "#{ENV['HOME']}/.posterous"
|
14
|
+
include Postly
|
15
|
+
|
16
|
+
tags = `\"#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog\" inputbox --title 'Posting to posterous.com' --informative-text 'Add Tags (Comma seperated): ' --text '' --button1 'Get' --button2 'Cancel'`
|
17
|
+
|
18
|
+
post = Site.last.posts.create( :title=>"#{ENV['TM_FILENAME']}", :body => "<pre>#{ENV['TM_SELECTED_TEXT']}</pre>", :tags => tags )
|
19
|
+
|
20
|
+
puts "Your snippet can be found at: #{post.url} or on your clipboard."
|
21
|
+
|
22
|
+
system "echo \"#{post.url}\" | pbcopy"
|
23
|
+
system "open #{post.url}"</string>
|
24
|
+
<key>fallbackInput</key>
|
25
|
+
<string>document</string>
|
26
|
+
<key>input</key>
|
27
|
+
<string>selection</string>
|
28
|
+
<key>keyEquivalent</key>
|
29
|
+
<string>^@p</string>
|
30
|
+
<key>name</key>
|
31
|
+
<string>Post Selection</string>
|
32
|
+
<key>output</key>
|
33
|
+
<string>showAsTooltip</string>
|
34
|
+
<key>scope</key>
|
35
|
+
<string>source.ruby</string>
|
36
|
+
<key>uuid</key>
|
37
|
+
<string>D77E28AF-A285-4554-89FB-E14F1DF8F391</string>
|
38
|
+
</dict>
|
39
|
+
</plist>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>name</key>
|
6
|
+
<string>posterous</string>
|
7
|
+
<key>uuid</key>
|
8
|
+
<string>BFBE205A-06AE-4311-A989-807DCCF150E3</string>
|
9
|
+
</dict>
|
10
|
+
</plist>
|
data/lib/postly.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
%w{rubygems nokogiri active_support httparty base64}.each { |f| require f }
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
module Postly
|
6
|
+
|
7
|
+
SITE_ATTRS = [:name, :url, :private, :primary, :hostname, :commentsenabled, :num_posts, :id]
|
8
|
+
POST_ATTRS = [:site_id, :title, :body, :autopost, :private, :date, :tags, :source, :sourceLink, :id, :url]
|
9
|
+
COMMENT_ATTRS = [:post_id, :comment, :name, :email, :date]
|
10
|
+
|
11
|
+
extend self
|
12
|
+
|
13
|
+
# Base64 Encoding credentials for Basic Auth
|
14
|
+
def encoded_credentials
|
15
|
+
@credentials ||= Base64.encode64("#{config['username']}:#{config['password']}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def config
|
19
|
+
@config ||= File.open(File.join(Dir.getwd, 'config/posterous.yml'), 'r') { |f| YAML.load(f) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def config=(path)
|
23
|
+
@config = File.open(path, 'r') { |f| YAML.load(f) }
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
def base_uri
|
28
|
+
@base_uri ||= "http://posterous.com/api"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Not sure if I need this yet
|
32
|
+
class PostlyError < StandardError; end
|
33
|
+
end
|
34
|
+
|
35
|
+
%w{connection many_proxy post site blog_importer comment}.each {|f| require "postly/#{f}"}
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
module Postly
|
3
|
+
class BlogImporter
|
4
|
+
|
5
|
+
def self.import xml, site_id
|
6
|
+
@doc = Nokogiri::HTML xml
|
7
|
+
@doc.css( entry_root ).inject([]) do | entries, item |
|
8
|
+
params = { :site_id => site_id }
|
9
|
+
(POST_ATTRS - [:id]).each do | attr_name |
|
10
|
+
params[attr_name] = case
|
11
|
+
when self.respond_to?( callback_for(attr_name) ) then self.send( callback_for(attr_name), item )
|
12
|
+
when entity_map.keys.include?( attr_name ) then item.css( entity_map[attr_name] ).text
|
13
|
+
else next
|
14
|
+
end
|
15
|
+
end
|
16
|
+
tags = handle_tags_for( item ) if respond_to? :handle_tags_for
|
17
|
+
post = create_post( params.merge(:tags => tags) )
|
18
|
+
handle_comments_for( post, item ) if respond_to? :handle_comments_for
|
19
|
+
entries << post
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.callback_for attr_name
|
24
|
+
"process_#{attr_name}".to_sym
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.entry_root
|
28
|
+
entity_map[:entry]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.create_post params
|
32
|
+
post = Postly::Post.create(params)
|
33
|
+
puts "Created: #{params.inspect}"
|
34
|
+
post
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Postly
|
2
|
+
class Comment < Connection
|
3
|
+
attr_accessor *COMMENT_ATTRS
|
4
|
+
# URL
|
5
|
+
# http://postly.com/api/newcomment
|
6
|
+
# Fields
|
7
|
+
# "post_id" - The post id to comment on
|
8
|
+
# "comment" - The comment body
|
9
|
+
# "name" - Optional. The name to use
|
10
|
+
# "email" - Optional. The email address to use
|
11
|
+
# "date" - Optional. In GMT. Any parsable format. Cannot be in the future.
|
12
|
+
def self.create params={}
|
13
|
+
conform post "/newcomment", defaults.merge( :query => params )
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Postly
|
2
|
+
class Connection
|
3
|
+
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
base_uri Postly.base_uri
|
7
|
+
|
8
|
+
def initialize attrs={}
|
9
|
+
attrs.each_pair {|k,v| send("#{k}=".to_sym, v) if respond_to? "#{k}=".to_sym }
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.defaults
|
13
|
+
{ :basic_auth => {:username => Postly.config["username"],
|
14
|
+
:password => Postly.config["password"]} }
|
15
|
+
end
|
16
|
+
|
17
|
+
# quack! quack!
|
18
|
+
def self.conform response
|
19
|
+
result = array_or_hash response
|
20
|
+
case result
|
21
|
+
when Hash
|
22
|
+
self.new result
|
23
|
+
when Array
|
24
|
+
result.collect { |item| self.new item }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.array_or_hash response
|
29
|
+
response["rsp"][self.class_name.downcase]
|
30
|
+
end
|
31
|
+
|
32
|
+
# Split off the Namespace
|
33
|
+
def self.class_name
|
34
|
+
@class_name ||= self.to_s.split("::").last
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def self.many collection_name
|
39
|
+
define_method collection_name do
|
40
|
+
ManyProxy.new self, singularized_class_name(collection_name)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def singularized_class_name collection_name
|
45
|
+
"Postly::#{collection_name.to_s.singularize.camelize}".constantize
|
46
|
+
# collection_name.to_s.singularize.camelize.constantize
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Postly
|
2
|
+
# Quick and Dirty has_many proxy class.
|
3
|
+
# #create is the only methods currently needed in the API.
|
4
|
+
# Otherwise this would be a bit more robust.
|
5
|
+
class ManyProxy
|
6
|
+
|
7
|
+
def initialize proxied, klass
|
8
|
+
@klass = klass
|
9
|
+
@proxied = proxied
|
10
|
+
end
|
11
|
+
|
12
|
+
def create attrs={}
|
13
|
+
@klass.create( attrs.merge( foreign_key => @proxied.id ) )
|
14
|
+
end
|
15
|
+
|
16
|
+
def foreign_key
|
17
|
+
(@proxied.class.to_s.split("::").last.downcase << '_id').to_sym
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/postly/post.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Postly
|
2
|
+
class Post < Connection
|
3
|
+
many :comments
|
4
|
+
attr_accessor *POST_ATTRS
|
5
|
+
|
6
|
+
# URL
|
7
|
+
# http://posterous.com/api/newpost
|
8
|
+
# Fields
|
9
|
+
# "site_id" - Optional. Id of the site to post to. If not supplied, posts to the user's default site
|
10
|
+
# "media" - Optional. File data for single file.
|
11
|
+
# "media[]" - Optional. File data for multiple file upload. Can be specified multiple times.
|
12
|
+
# "title" - Optional. Title of post
|
13
|
+
# "body" - Optional. Body of post
|
14
|
+
# "autopost" - Optional. 0 or 1.
|
15
|
+
# "private" - Optional. 0 or 1.
|
16
|
+
# "date" - Optional. In GMT. Any parsable format. Cannot be in the future.
|
17
|
+
# "tags" - Optional. Comma separate tags
|
18
|
+
# "source" - Optional. The name of your application or website
|
19
|
+
# "sourceLink" - Optional. Link to your application or website
|
20
|
+
def self.create params={}
|
21
|
+
params[:body] = add_download_class params[:body]
|
22
|
+
conform post "/newpost", defaults.merge( :query => params )
|
23
|
+
end
|
24
|
+
|
25
|
+
# URL
|
26
|
+
# http://postly.com/api/updatepost
|
27
|
+
# Fields
|
28
|
+
# "post_id" - Id of the post to update.
|
29
|
+
# "media" - Optional. File data for single file. Will append to post.
|
30
|
+
# "media[]" - Optional. File data for multiple file upload. Can be specified multiple times. Will append to post.
|
31
|
+
# "title" - Optional. Title of post. Will update post if present.
|
32
|
+
# "body" - Optional. Body of post. Will update post if present.
|
33
|
+
def self.update post_id, params={}
|
34
|
+
params[:post_id] = post_id
|
35
|
+
conform post "/updatepost", defaults.merge( :query => params )
|
36
|
+
end
|
37
|
+
|
38
|
+
# there is probably a better way nodes for the body
|
39
|
+
# but this works for now.
|
40
|
+
def self.add_download_class html
|
41
|
+
doc = Nokogiri::HTML(html)
|
42
|
+
doc.css( "img" ).each { |img| img["class"] = "posterous_download_image" }.to_s
|
43
|
+
doc.css("body").children.first.to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/postly/site.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Postly
|
2
|
+
|
3
|
+
class Site < Connection
|
4
|
+
many :posts
|
5
|
+
attr_accessor *SITE_ATTRS
|
6
|
+
|
7
|
+
# URL
|
8
|
+
# http://posterous.com/api/getsites
|
9
|
+
# Fields
|
10
|
+
# None
|
11
|
+
def self.find
|
12
|
+
conform get("/getsites", defaults)
|
13
|
+
end
|
14
|
+
|
15
|
+
# for readability
|
16
|
+
def self.all
|
17
|
+
find
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.first
|
21
|
+
find.first
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.last
|
25
|
+
find.last
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/postly.gemspec
ADDED
@@ -0,0 +1,77 @@
|
|
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{postly}
|
8
|
+
s.version = "0.2.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["twoism"]
|
12
|
+
s.date = %q{2010-01-22}
|
13
|
+
s.default_executable = %q{postly}
|
14
|
+
s.description = %q{API Wrapper and IRB console for posterous.com}
|
15
|
+
s.email = %q{signalstatic@gmail.com}
|
16
|
+
s.executables = ["postly"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.markdown"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".gitignore",
|
23
|
+
"LICENSE",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/postly",
|
28
|
+
"config/posterous.sample.yml",
|
29
|
+
"etc/posterous.tmbundle/Commands/Post Selection.tmCommand",
|
30
|
+
"etc/posterous.tmbundle/info.plist",
|
31
|
+
"lib/postly.rb",
|
32
|
+
"lib/postly/blog_importer.rb",
|
33
|
+
"lib/postly/comment.rb",
|
34
|
+
"lib/postly/connection.rb",
|
35
|
+
"lib/postly/many_proxy.rb",
|
36
|
+
"lib/postly/post.rb",
|
37
|
+
"lib/postly/site.rb",
|
38
|
+
"postly.gemspec",
|
39
|
+
"test/fixtures/cthulhu.png",
|
40
|
+
"test/fixtures/fennec-fox.jpg",
|
41
|
+
"test/fixtures/wp.xml",
|
42
|
+
"test/growler.rb",
|
43
|
+
"test/test_helper.rb",
|
44
|
+
"test/test_importer.rb",
|
45
|
+
"test/test_post.rb",
|
46
|
+
"test/test_site.rb"
|
47
|
+
]
|
48
|
+
s.homepage = %q{http://github.com/twoism/postly}
|
49
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
50
|
+
s.require_paths = ["lib"]
|
51
|
+
s.rubygems_version = %q{1.3.5}
|
52
|
+
s.summary = %q{API Wrapper for posterous.com}
|
53
|
+
s.test_files = [
|
54
|
+
"test/growler.rb",
|
55
|
+
"test/test_helper.rb",
|
56
|
+
"test/test_importer.rb",
|
57
|
+
"test/test_post.rb",
|
58
|
+
"test/test_site.rb"
|
59
|
+
]
|
60
|
+
|
61
|
+
if s.respond_to? :specification_version then
|
62
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
63
|
+
s.specification_version = 3
|
64
|
+
|
65
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
66
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
67
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
70
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
74
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,78 @@
|
|
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{progressions-postly}
|
8
|
+
s.version = "0.2.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["twoism", "progressions"]
|
12
|
+
s.date = %q{2010-03-13}
|
13
|
+
s.default_executable = %q{postly}
|
14
|
+
s.description = %q{API Wrapper and IRB console for posterous.com}
|
15
|
+
s.email = %q{signalstatic@gmail.com}
|
16
|
+
s.executables = ["postly"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.markdown"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".gitignore",
|
23
|
+
"LICENSE",
|
24
|
+
"README.markdown",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/postly",
|
28
|
+
"config/posterous.sample.yml",
|
29
|
+
"etc/posterous.tmbundle/Commands/Post Selection.tmCommand",
|
30
|
+
"etc/posterous.tmbundle/info.plist",
|
31
|
+
"lib/postly.rb",
|
32
|
+
"lib/postly/blog_importer.rb",
|
33
|
+
"lib/postly/comment.rb",
|
34
|
+
"lib/postly/connection.rb",
|
35
|
+
"lib/postly/many_proxy.rb",
|
36
|
+
"lib/postly/post.rb",
|
37
|
+
"lib/postly/site.rb",
|
38
|
+
"postly.gemspec",
|
39
|
+
"progressions-postly.gemspec",
|
40
|
+
"test/fixtures/cthulhu.png",
|
41
|
+
"test/fixtures/fennec-fox.jpg",
|
42
|
+
"test/fixtures/wp.xml",
|
43
|
+
"test/growler.rb",
|
44
|
+
"test/test_helper.rb",
|
45
|
+
"test/test_importer.rb",
|
46
|
+
"test/test_post.rb",
|
47
|
+
"test/test_site.rb"
|
48
|
+
]
|
49
|
+
s.homepage = %q{http://github.com/progressions/postly}
|
50
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
51
|
+
s.require_paths = ["lib"]
|
52
|
+
s.rubygems_version = %q{1.3.5}
|
53
|
+
s.summary = %q{API Wrapper for posterous.com}
|
54
|
+
s.test_files = [
|
55
|
+
"test/growler.rb",
|
56
|
+
"test/test_helper.rb",
|
57
|
+
"test/test_importer.rb",
|
58
|
+
"test/test_post.rb",
|
59
|
+
"test/test_site.rb"
|
60
|
+
]
|
61
|
+
|
62
|
+
if s.respond_to? :specification_version then
|
63
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
64
|
+
s.specification_version = 3
|
65
|
+
|
66
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
67
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
68
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
71
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
72
|
+
end
|
73
|
+
else
|
74
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
75
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
Binary file
|
Binary file
|
@@ -0,0 +1,137 @@
|
|
1
|
+
-:44: namespace error : Namespace prefix atom on link is not defined
|
2
|
+
f="http://chrisburnett.wordpress.com/osd.xml" title="Chrisburnett’s Blog"
|
3
|
+
^
|
4
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
5
|
+
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
|
6
|
+
<!-- It contains information about your blog's posts, comments, and categories. -->
|
7
|
+
<!-- You may use this file to transfer that content from one site to another. -->
|
8
|
+
<!-- This file is not intended to serve as a complete backup of your blog. -->
|
9
|
+
<!-- To import this information into a WordPress blog follow these steps. -->
|
10
|
+
<!-- 1. Log in to that blog as an administrator. -->
|
11
|
+
<!-- 2. Go to Tools: Import in the blog's admin panels (or Manage: Import in older versions of WordPress). -->
|
12
|
+
<!-- 3. Choose "WordPress" from the list. -->
|
13
|
+
<!-- 4. Upload this file using the form provided on that page. -->
|
14
|
+
<!-- 5. You will first be asked to map the authors in this export file to users -->
|
15
|
+
<!-- on the blog. For each author, you may choose to map to an -->
|
16
|
+
<!-- existing user on the blog or to create a new user -->
|
17
|
+
<!-- 6. WordPress will then import each of the posts, comments, and categories -->
|
18
|
+
<!-- contained in this file into your blog -->
|
19
|
+
<!-- generator="WordPress.com" created="2010-01-10 19:28"-->
|
20
|
+
<rss xmlns:excerpt="http://wordpress.org/export/1.0/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.0/" version="2.0">
|
21
|
+
<channel>
|
22
|
+
<title>Chrisburnett's Blog</title>
|
23
|
+
<link>http://chrisburnett.wordpress.com</link>
|
24
|
+
<description>Just another WordPress.com weblog</description>
|
25
|
+
<pubDate>Sun, 10 Jan 2010 19:27:58 +0000</pubDate>
|
26
|
+
<generator>http://wordpress.org/?v=MU</generator>
|
27
|
+
<language>en</language>
|
28
|
+
<wp:wxr_version>1.0</wp:wxr_version>
|
29
|
+
<wp:base_site_url>http://wordpress.com/</wp:base_site_url>
|
30
|
+
<wp:base_blog_url>http://chrisburnett.wordpress.com</wp:base_blog_url>
|
31
|
+
<wp:category>
|
32
|
+
<wp:category_nicename>uncategorized</wp:category_nicename>
|
33
|
+
<wp:category_parent/>
|
34
|
+
<wp:cat_name><![CDATA[Uncategorized]]></wp:cat_name>
|
35
|
+
</wp:category>
|
36
|
+
<cloud domain="chrisburnett.wordpress.com" port="80" path="/?rsscloud=notify" registerProcedure="" protocol="http-post"/>
|
37
|
+
<image>
|
38
|
+
<url>http://www.gravatar.com/blavatar/ff96316ea716f39ca623e6079442500e?s=96&d=https://s-ssl.wordpress.com/i/buttonw-com.png</url>
|
39
|
+
<title>Chrisburnett's Blog</title>
|
40
|
+
<link>http://chrisburnett.wordpress.com</link>
|
41
|
+
</image>
|
42
|
+
<link rel="search" type="application/opensearchdescription+xml" href="http://chrisburnett.wordpress.com/osd.xml" title="Chrisburnett’s Blog"/>
|
43
|
+
<item>
|
44
|
+
<title>Yes, this is a lemur</title>
|
45
|
+
<link>http://chrisburnett.wordpress.com/2010/01/10/yes-this-is-a-lemur/</link>
|
46
|
+
<pubDate>Sun, 10 Jan 2010 19:27:58 +0000</pubDate>
|
47
|
+
<dc:creator><![CDATA[chrisburnett]]></dc:creator>
|
48
|
+
<category><![CDATA[Uncategorized]]></category>
|
49
|
+
<category domain="category" nicename="uncategorized"><![CDATA[Uncategorized]]></category>
|
50
|
+
<guid isPermaLink="false">http://chrisburnett.wordpress.com/?p=17</guid>
|
51
|
+
<description/>
|
52
|
+
<content:encoded><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, <img src="http://farm3.static.flickr.com/2407/2243020634_9508a65fe3.jpg" alt="" /> sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
53
|
+
]]></content:encoded>
|
54
|
+
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
55
|
+
<wp:post_id>17</wp:post_id>
|
56
|
+
<wp:post_date>2010-01-10 19:27:58</wp:post_date>
|
57
|
+
<wp:post_date_gmt>2010-01-10 19:27:58</wp:post_date_gmt>
|
58
|
+
<wp:comment_status>open</wp:comment_status>
|
59
|
+
<wp:ping_status>open</wp:ping_status>
|
60
|
+
<wp:post_name>yes-this-is-a-lemur</wp:post_name>
|
61
|
+
<wp:status>publish</wp:status>
|
62
|
+
<wp:post_parent>0</wp:post_parent>
|
63
|
+
<wp:menu_order>0</wp:menu_order>
|
64
|
+
<wp:post_type>post</wp:post_type>
|
65
|
+
<wp:post_password/>
|
66
|
+
<wp:is_sticky>0</wp:is_sticky>
|
67
|
+
<wp:postmeta>
|
68
|
+
<wp:meta_key>_edit_lock</wp:meta_key>
|
69
|
+
<wp:meta_value><![CDATA[1263151679]]></wp:meta_value>
|
70
|
+
</wp:postmeta>
|
71
|
+
<wp:postmeta>
|
72
|
+
<wp:meta_key>_edit_last</wp:meta_key>
|
73
|
+
<wp:meta_value><![CDATA[6273077]]></wp:meta_value>
|
74
|
+
</wp:postmeta>
|
75
|
+
<wp:postmeta>
|
76
|
+
<wp:meta_key>_pingme</wp:meta_key>
|
77
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
78
|
+
</wp:postmeta>
|
79
|
+
<wp:postmeta>
|
80
|
+
<wp:meta_key>_encloseme</wp:meta_key>
|
81
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
82
|
+
</wp:postmeta>
|
83
|
+
<wp:postmeta>
|
84
|
+
<wp:meta_key>_searchme</wp:meta_key>
|
85
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
86
|
+
</wp:postmeta>
|
87
|
+
</item>
|
88
|
+
<item>
|
89
|
+
<title>Yes, this is a lemur 2</title>
|
90
|
+
<link>http://chrisburnett.wordpress.com/2010/01/10/yes-this-is-a-lemur/</link>
|
91
|
+
<pubDate>Sun, 10 Jan 2010 19:27:58 +0000</pubDate>
|
92
|
+
<dc:creator><![CDATA[chrisburnett]]></dc:creator>
|
93
|
+
<category><![CDATA[Uncategorized]]></category>
|
94
|
+
<category><![CDATA[Social Networking]]></category>
|
95
|
+
|
96
|
+
<category domain="category" nicename="social-networking"><![CDATA[Social Networking]]></category>
|
97
|
+
<category domain="category" nicename="uncategorized"><![CDATA[Uncategorized]]></category>
|
98
|
+
<guid isPermaLink="false">http://chrisburnett.wordpress.com/?p=17</guid>
|
99
|
+
<description/>
|
100
|
+
<content:encoded><![CDATA[<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, <img src="http://farm3.static.flickr.com/2407/2243020634_9508a65fe3.jpg" alt="" /> sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
101
|
+
]]></content:encoded>
|
102
|
+
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
103
|
+
<wp:post_id>17</wp:post_id>
|
104
|
+
<wp:post_date>2010-01-10 19:27:58</wp:post_date>
|
105
|
+
<wp:post_date_gmt>2010-01-10 19:27:58</wp:post_date_gmt>
|
106
|
+
<wp:comment_status>open</wp:comment_status>
|
107
|
+
<wp:ping_status>open</wp:ping_status>
|
108
|
+
<wp:post_name>yes-this-is-a-lemur</wp:post_name>
|
109
|
+
<wp:status>publish</wp:status>
|
110
|
+
<wp:post_parent>0</wp:post_parent>
|
111
|
+
<wp:menu_order>0</wp:menu_order>
|
112
|
+
<wp:post_type>post</wp:post_type>
|
113
|
+
<wp:post_password/>
|
114
|
+
<wp:is_sticky>0</wp:is_sticky>
|
115
|
+
<wp:postmeta>
|
116
|
+
<wp:meta_key>_edit_lock</wp:meta_key>
|
117
|
+
<wp:meta_value><![CDATA[1263151679]]></wp:meta_value>
|
118
|
+
</wp:postmeta>
|
119
|
+
<wp:postmeta>
|
120
|
+
<wp:meta_key>_edit_last</wp:meta_key>
|
121
|
+
<wp:meta_value><![CDATA[6273077]]></wp:meta_value>
|
122
|
+
</wp:postmeta>
|
123
|
+
<wp:postmeta>
|
124
|
+
<wp:meta_key>_pingme</wp:meta_key>
|
125
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
126
|
+
</wp:postmeta>
|
127
|
+
<wp:postmeta>
|
128
|
+
<wp:meta_key>_encloseme</wp:meta_key>
|
129
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
130
|
+
</wp:postmeta>
|
131
|
+
<wp:postmeta>
|
132
|
+
<wp:meta_key>_searchme</wp:meta_key>
|
133
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
134
|
+
</wp:postmeta>
|
135
|
+
</item>
|
136
|
+
</channel>
|
137
|
+
</rss>
|
data/test/growler.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
%w{rubygems test/unit shoulda mocha cgi}.each { |lib| require lib }
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/postly')
|
4
|
+
|
5
|
+
class Test::Unit::TestCase
|
6
|
+
def teardown; end
|
7
|
+
|
8
|
+
def inherited base
|
9
|
+
base.define_method teardown { super }
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
include Postly
|
4
|
+
|
5
|
+
class WordPressBlogImporter < Postly::BlogImporter
|
6
|
+
|
7
|
+
def self.entity_map
|
8
|
+
{ :entry => "item", :body => "encoded", :title => "title" }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.process_body item
|
12
|
+
CGI.unescapeHTML(item.css("encoded").to_s).gsub(/<encoded>|<\/encoded>|\]\]>/,"")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.handle_tags_for node
|
16
|
+
node.css("category").css("category").collect \
|
17
|
+
{ |n| n.attributes["nicename"].text if n.attributes["nicename"].present? }.compact!.join(",")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
class Postly::BlogImporterTest < Test::Unit::TestCase
|
24
|
+
context "A Importer" do
|
25
|
+
setup do
|
26
|
+
@dir = File.dirname(__FILE__) + '/fixtures'
|
27
|
+
@wp_xml = File.open("#{@dir}/wp.xml", 'r')
|
28
|
+
# @imported = WordPressBlogImporter.import(@wp_xml.read, Site.last.id)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "be an array" do
|
32
|
+
#assert @imported.is_a? Array
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/test/test_post.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
include Postly
|
4
|
+
|
5
|
+
class Postly::PostTest < Test::Unit::TestCase
|
6
|
+
context "Postly::Post" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@params = {
|
10
|
+
:site_id => 85691,
|
11
|
+
:title => "New from API",
|
12
|
+
:body => 'Sample Body with an <img src="http://farm3.static.flickr.com/2407/2243020634_9508a65fe3.jpg"> inline.'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
[:site_id, :title, :body, :autopost, :private,
|
17
|
+
:date, :tags, :source, :sourceLink, :id].each do |method|
|
18
|
+
should "respond to #{method}" do
|
19
|
+
assert Post.new.respond_to? method
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#create" do
|
24
|
+
setup do
|
25
|
+
Post.stubs(:create).with(@params).returns(Post.new)
|
26
|
+
@post = Post.create(@params)
|
27
|
+
end
|
28
|
+
|
29
|
+
should "return a post" do
|
30
|
+
assert @post.is_a? Post
|
31
|
+
end
|
32
|
+
|
33
|
+
should "add posterous_download_image class to images" do
|
34
|
+
assert_contains Post.add_download_class(@params[:body]) , /posterous_download_image/
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/test/test_site.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
include Postly
|
4
|
+
|
5
|
+
class Postly::SiteTest < Test::Unit::TestCase
|
6
|
+
context "Postly::Site" do
|
7
|
+
|
8
|
+
setup do
|
9
|
+
sites = [Site.new,Site.new]
|
10
|
+
Site.expects(:find).returns(sites)
|
11
|
+
@sites = Site.find
|
12
|
+
end
|
13
|
+
|
14
|
+
[:id,:name,:hostname,:url,:private,
|
15
|
+
:primary,:commentsenabled,:num_posts].each do |method|
|
16
|
+
should "respond to #{method}" do
|
17
|
+
assert Site.new.respond_to? method
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
should "be an array" do
|
22
|
+
assert @sites.is_a? Array
|
23
|
+
end
|
24
|
+
|
25
|
+
should "contain sites" do
|
26
|
+
@sites.each { |s| assert s.is_a? Site }
|
27
|
+
end
|
28
|
+
|
29
|
+
should "respond to create through posts" do
|
30
|
+
assert @sites.last.posts.respond_to? :create
|
31
|
+
end
|
32
|
+
|
33
|
+
should "be a ManyProxy" do
|
34
|
+
assert_equal ManyProxy, @sites.last.posts.class
|
35
|
+
end
|
36
|
+
|
37
|
+
should "gen the correct foreign key" do
|
38
|
+
assert_equal( :site_id, @sites.last.posts.foreign_key )
|
39
|
+
end
|
40
|
+
|
41
|
+
context "#all" do
|
42
|
+
setup do
|
43
|
+
Site.expects(:all).returns(@sites)
|
44
|
+
@all = Site.all
|
45
|
+
end
|
46
|
+
should "eql #find" do
|
47
|
+
assert_equal(@sites.count, @all.count)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
#
|
51
|
+
context "#first" do
|
52
|
+
setup do
|
53
|
+
Site.expects(:first).returns(@sites.first)
|
54
|
+
@first = Site.first
|
55
|
+
end
|
56
|
+
should "eql first site" do
|
57
|
+
assert_equal(@sites.first.name, @first.name)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
#
|
61
|
+
context "#last" do
|
62
|
+
setup do
|
63
|
+
Site.expects(:last).returns(@sites.last)
|
64
|
+
@last = Site.last
|
65
|
+
end
|
66
|
+
should "eql last site" do
|
67
|
+
assert_equal(@sites.last.name, @last.name)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: progressions-postly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- twoism
|
8
|
+
- progressions
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-03-13 00:00:00 -06:00
|
14
|
+
default_executable: postly
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: nokogiri
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: httparty
|
28
|
+
type: :runtime
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
version:
|
36
|
+
description: API Wrapper and IRB console for posterous.com
|
37
|
+
email: signalstatic@gmail.com
|
38
|
+
executables:
|
39
|
+
- postly
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- LICENSE
|
44
|
+
- README.markdown
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.markdown
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- bin/postly
|
52
|
+
- config/posterous.sample.yml
|
53
|
+
- etc/posterous.tmbundle/Commands/Post Selection.tmCommand
|
54
|
+
- etc/posterous.tmbundle/info.plist
|
55
|
+
- lib/postly.rb
|
56
|
+
- lib/postly/blog_importer.rb
|
57
|
+
- lib/postly/comment.rb
|
58
|
+
- lib/postly/connection.rb
|
59
|
+
- lib/postly/many_proxy.rb
|
60
|
+
- lib/postly/post.rb
|
61
|
+
- lib/postly/site.rb
|
62
|
+
- postly.gemspec
|
63
|
+
- progressions-postly.gemspec
|
64
|
+
- test/fixtures/cthulhu.png
|
65
|
+
- test/fixtures/fennec-fox.jpg
|
66
|
+
- test/fixtures/wp.xml
|
67
|
+
- test/growler.rb
|
68
|
+
- test/test_helper.rb
|
69
|
+
- test/test_importer.rb
|
70
|
+
- test/test_post.rb
|
71
|
+
- test/test_site.rb
|
72
|
+
has_rdoc: true
|
73
|
+
homepage: http://github.com/progressions/postly
|
74
|
+
licenses: []
|
75
|
+
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options:
|
78
|
+
- --charset=UTF-8
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: API Wrapper for posterous.com
|
100
|
+
test_files:
|
101
|
+
- test/growler.rb
|
102
|
+
- test/test_helper.rb
|
103
|
+
- test/test_importer.rb
|
104
|
+
- test/test_post.rb
|
105
|
+
- test/test_site.rb
|