governor_blogger 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/governor_blogger.gemspec +1 -1
- data/lib/governor_blogger/instance_methods.rb +0 -31
- data/spec/rails_app/Gemfile.lock +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/governor_blogger.gemspec
CHANGED
@@ -1,36 +1,5 @@
|
|
1
1
|
module GovernorBlogger
|
2
2
|
module InstanceMethods
|
3
|
-
def post_to_blogger
|
4
|
-
b = GData::Client::Blogger.new
|
5
|
-
body = Nokogiri::XML.fragment(Governor::Formatters.format_article self).to_s
|
6
|
-
page = "http://www.blogger.com/feeds/#{GovernorBlogger.config.blog_id}/posts/default/#{blogger_id}".chomp '/'
|
7
|
-
# log in
|
8
|
-
b.clientlogin(GovernorBlogger.config.username, GovernorBlogger.config.password)
|
9
|
-
|
10
|
-
if blogger_id.blank?
|
11
|
-
# construct post
|
12
|
-
entry = Nokogiri::XML::Builder.new do |xml|
|
13
|
-
xml.entry(:xmlns => 'http://www.w3.org/2005/Atom') do
|
14
|
-
xml.title self.title, :type => 'text'
|
15
|
-
xml.content(:type => 'xhtml') { |content| content << body }
|
16
|
-
end
|
17
|
-
end.to_xml
|
18
|
-
# post to page, retrieve blogger_id
|
19
|
-
response = b.post(page, entry)
|
20
|
-
post_id = response.headers['location'].match(%r{posts/default/(\d+)})[1]
|
21
|
-
# update entry with blogger_id
|
22
|
-
self.update_attribute :blogger_id, post_id
|
23
|
-
else
|
24
|
-
# retrieve post
|
25
|
-
xml = b.get(page).to_xml
|
26
|
-
# transform XML
|
27
|
-
xml.children.detect{|e| e.name == 'title' }.text = self.title
|
28
|
-
xml.children.detect{|e| e.name == 'content' }.text = body
|
29
|
-
# post back to page
|
30
|
-
b.put(page, xml)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
3
|
def post_to_blogger_in_background
|
35
4
|
GovernorBackground.run('blogger_post', self)
|
36
5
|
end
|
data/spec/rails_app/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: governor_blogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Liam Morley
|