csexton-twitter_archive 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -51,8 +51,13 @@ module GData
|
|
51
51
|
put(path, entry.to_s)
|
52
52
|
end
|
53
53
|
|
54
|
-
# Creates a new entry with the given title and body
|
55
|
-
|
54
|
+
# Creates a new entry with the given +title+ and +body+
|
55
|
+
# +options+ can contain the following:
|
56
|
+
# :labels - an array of labels (tags) to apply to the post
|
57
|
+
# :draft - boolean to save the post as a draft (not published)
|
58
|
+
#
|
59
|
+
def entry(title, body, options = {})
|
60
|
+
options = { :labels => [], :draft => false}.merge(options)
|
56
61
|
x = Builder::XmlMarkup.new :indent => 2
|
57
62
|
@entry = x.entry 'xmlns' => 'http://www.w3.org/2005/Atom' do
|
58
63
|
x.title title, 'type' => 'text'
|
@@ -61,11 +66,17 @@ module GData
|
|
61
66
|
x << body
|
62
67
|
end
|
63
68
|
end
|
64
|
-
labels.each do |label|
|
69
|
+
options[:labels].each do |label|
|
65
70
|
x.category 'scheme' => "http://www.blogger.com/atom/ns#", 'term' => label
|
66
71
|
end
|
72
|
+
if options[:draft]
|
73
|
+
x.app:control, 'xmlns:app' =>'http://www.w3.org/2007/app' do
|
74
|
+
x << "<app:draft>yes</app:draft>" # The whitespace that builder
|
75
|
+
# adds around 'yes' was resulting
|
76
|
+
# in a bad request.
|
77
|
+
end
|
78
|
+
end
|
67
79
|
end
|
68
|
-
|
69
80
|
path = "/feeds/#{@blog_id}/posts/default"
|
70
81
|
post(path, @entry)
|
71
82
|
end
|
@@ -8,8 +8,17 @@ module TwitterArchive
|
|
8
8
|
if twitter_results.length > 0
|
9
9
|
blogger = GData::Blogger.new(opts['blogger_id'])
|
10
10
|
blogger.authenticate(opts['blogger_user'], opts['blogger_pass'])
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
res = blogger.entry(opts['blogger_title'] || 'Twitter',
|
13
|
+
format_post(twitter_results),
|
14
|
+
{:labels => ['twitter'], :draft => true})
|
15
|
+
|
16
|
+
if res.code == '201' # 201 - Created
|
17
|
+
"Posting to blogger id #{opts['blogger_id']}, user #{opts['blogger_user']}"
|
18
|
+
else
|
19
|
+
"Error posting to blogger id #{opts['blogger_id']}, user #{opts['blogger_user']}: #{res.body}"
|
20
|
+
end
|
21
|
+
|
13
22
|
else
|
14
23
|
"Nothing to post to blogger"
|
15
24
|
end
|
data/twitter_archive.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{twitter_archive}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Christohper Sexton"]
|
9
|
-
s.date = %q{2009-01-
|
9
|
+
s.date = %q{2009-01-12}
|
10
10
|
s.default_executable = %q{twitter_archive}
|
11
11
|
s.description = %q{Twitter archive utility}
|
12
12
|
s.email = %q{csexton@gmail.com}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csexton-twitter_archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christohper Sexton
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-12 00:00:00 -08:00
|
13
13
|
default_executable: twitter_archive
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|