io_tools 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +10 -17
- data/README.mdown +1 -3
- data/Rakefile +0 -2
- data/VERSION +1 -1
- data/io_tools.gemspec +3 -9
- data/lib/io_tools.rb +1 -3
- data/lib/io_tools/helpers/{xml_rpc.rb → meta_weblog.rb} +2 -2
- data/lib/server/importers/word_press_importer.rb +8 -7
- data/lib/server/server.rb +11 -13
- data/lib/server/views/index.haml +22 -5
- metadata +10 -38
data/LICENSE
CHANGED
@@ -1,20 +1,13 @@
|
|
1
|
-
|
1
|
+
This program is free software: you can redistribute it and/or modify
|
2
|
+
it under the terms of the GNU General Public License as published by
|
3
|
+
the Free Software Foundation, either version 3 of the License, or
|
4
|
+
(at your option) any later version.
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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:
|
6
|
+
This program is distributed in the hope that it will be useful,
|
7
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
8
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
9
|
+
GNU General Public License for more details.
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
You should have received a copy of the GNU General Public License
|
12
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
13
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.mdown
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
## io_tools ##
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Extracted modules from the Posterous Blog Importer. Used for conforming RSS Feeds or results from one API to another.
|
3
|
+
Extracted modules from the Posterous Blog Importer. A way to structure the code needed to connect to various APIs and conform the results to your liking. At it's core is a very simple module that tries to keep things sane when communicating with a multitude of platforms.
|
6
4
|
|
7
5
|
## Installation ##
|
8
6
|
|
data/Rakefile
CHANGED
@@ -15,8 +15,6 @@ begin
|
|
15
15
|
gem.add_development_dependency "mocha"
|
16
16
|
|
17
17
|
gem.add_dependency "nokogiri", ">= 1.4.2"
|
18
|
-
gem.add_dependency "sinatra"
|
19
|
-
gem.add_dependency "haml"
|
20
18
|
gem.add_dependency "xml-simple"
|
21
19
|
gem.add_dependency "feedtools", ">= 0.2.29"
|
22
20
|
gem.add_dependency "vegas", "~> 0.1.2"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/io_tools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{io_tools}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Christopher Burnett"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-27}
|
13
13
|
s.default_executable = %q{io-server}
|
14
14
|
s.description = %q{Extracted modules from the Posterous Blog Importer. Used for conforming RSS Feeds or results from one API to another.}
|
15
15
|
s.email = %q{signalstatic@gmail.com}
|
@@ -29,8 +29,8 @@ Gem::Specification.new do |s|
|
|
29
29
|
"io_tools.gemspec",
|
30
30
|
"lib/io_tools.rb",
|
31
31
|
"lib/io_tools/helpers.rb",
|
32
|
+
"lib/io_tools/helpers/meta_weblog.rb",
|
32
33
|
"lib/io_tools/helpers/rss_feed.rb",
|
33
|
-
"lib/io_tools/helpers/xml_rpc.rb",
|
34
34
|
"lib/io_tools/importer.rb",
|
35
35
|
"lib/server/config.ru",
|
36
36
|
"lib/server/importers/posterous_api_importer.rb",
|
@@ -70,8 +70,6 @@ Gem::Specification.new do |s|
|
|
70
70
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
71
71
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
72
72
|
s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.2"])
|
73
|
-
s.add_runtime_dependency(%q<sinatra>, [">= 0"])
|
74
|
-
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
75
73
|
s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
|
76
74
|
s.add_runtime_dependency(%q<feedtools>, [">= 0.2.29"])
|
77
75
|
s.add_runtime_dependency(%q<vegas>, ["~> 0.1.2"])
|
@@ -79,8 +77,6 @@ Gem::Specification.new do |s|
|
|
79
77
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
80
78
|
s.add_dependency(%q<mocha>, [">= 0"])
|
81
79
|
s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
|
82
|
-
s.add_dependency(%q<sinatra>, [">= 0"])
|
83
|
-
s.add_dependency(%q<haml>, [">= 0"])
|
84
80
|
s.add_dependency(%q<xml-simple>, [">= 0"])
|
85
81
|
s.add_dependency(%q<feedtools>, [">= 0.2.29"])
|
86
82
|
s.add_dependency(%q<vegas>, ["~> 0.1.2"])
|
@@ -89,8 +85,6 @@ Gem::Specification.new do |s|
|
|
89
85
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
90
86
|
s.add_dependency(%q<mocha>, [">= 0"])
|
91
87
|
s.add_dependency(%q<nokogiri>, [">= 1.4.2"])
|
92
|
-
s.add_dependency(%q<sinatra>, [">= 0"])
|
93
|
-
s.add_dependency(%q<haml>, [">= 0"])
|
94
88
|
s.add_dependency(%q<xml-simple>, [">= 0"])
|
95
89
|
s.add_dependency(%q<feedtools>, [">= 0.2.29"])
|
96
90
|
s.add_dependency(%q<vegas>, ["~> 0.1.2"])
|
data/lib/io_tools.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
%w{rubygems ostruct xmlrpc/client nokogiri open-uri feed_tools}.each { |f| require f }
|
2
2
|
|
3
|
-
|
4
3
|
require "io_tools/importer"
|
5
4
|
require "io_tools/helpers/rss_feed"
|
6
|
-
require "io_tools/helpers/
|
5
|
+
require "io_tools/helpers/meta_weblog"
|
7
6
|
|
8
7
|
module IoTools
|
9
|
-
VERSION = '0.0.1'
|
10
8
|
class ItemStruct < OpenStruct
|
11
9
|
def to_json *_
|
12
10
|
self.table.inject({}){|h,f| h[f.first] = f.last; h }.to_json
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module IoTools
|
2
2
|
module Helpers
|
3
|
-
module
|
3
|
+
module MetaWeblog
|
4
4
|
|
5
5
|
def server
|
6
6
|
@server ||= XMLRPC::Client.new2(api_url, nil, 300)
|
7
7
|
end
|
8
8
|
|
9
9
|
def rpc method, *args
|
10
|
-
server.call("metaWeblog.#{method.to_s}", self.metaweblog_id, self.
|
10
|
+
server.call("metaWeblog.#{method.to_s}", self.metaweblog_id, self.params['username'], self.params['password'], *args)
|
11
11
|
end
|
12
12
|
|
13
13
|
def recent_posts num
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class WordPressImporter
|
4
4
|
include IoTools::Importer
|
5
|
-
include IoTools::Helpers::
|
5
|
+
include IoTools::Helpers::MetaWeblog
|
6
6
|
|
7
7
|
RSD_SELECTOR = 'link[rel=EditURI]'
|
8
8
|
METAWEB_SELECTOR = 'api[name=MetaWeblog]'
|
@@ -12,11 +12,12 @@ class WordPressImporter
|
|
12
12
|
recent_posts MAX_POSTS_TO_REQUEST
|
13
13
|
end
|
14
14
|
|
15
|
-
conform do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
conform do |incoming, conformed|
|
16
|
+
conformed.title = incoming['title']
|
17
|
+
conformed.body = incoming['description']
|
18
|
+
conformed.display_date = incoming['dateCreated'].to_time.utc
|
19
|
+
conformed.tags = incoming['mt_keywords'].split(",")
|
20
|
+
conformed
|
20
21
|
end
|
21
22
|
|
22
23
|
# Methods below are helpers for detecting RSD for the
|
@@ -30,7 +31,7 @@ class WordPressImporter
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def html
|
33
|
-
@html ||= open self.import_url
|
34
|
+
@html ||= open self.params['import_url']
|
34
35
|
end
|
35
36
|
|
36
37
|
def rsd_url
|
data/lib/server/server.rb
CHANGED
@@ -3,31 +3,29 @@
|
|
3
3
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../..', 'lib'))
|
5
5
|
|
6
|
-
|
7
|
-
dir = File.expand_path(File.dirname(__FILE__))
|
8
|
-
|
9
|
-
require dir+'/importers/posterous_feed_importer'
|
10
|
-
require dir+'/importers/posterous_api_importer'
|
6
|
+
@dir = File.expand_path(File.dirname(__FILE__))
|
11
7
|
|
8
|
+
require 'io_tools'
|
12
9
|
|
10
|
+
require dir + '/importers/posterous_feed_importer'
|
11
|
+
require dir + '/importers/posterous_api_importer'
|
12
|
+
require dir + '/importers/word_press_importer'
|
13
13
|
|
14
14
|
module IoTools
|
15
|
-
|
16
|
-
|
17
15
|
class Server < Sinatra::Base
|
18
|
-
dir = File.dirname(File.expand_path(__FILE__))
|
19
16
|
|
20
|
-
set :views, "#{dir}/views"
|
21
|
-
set :public, "#{dir}/public"
|
17
|
+
set :views, "#{@dir}/views"
|
18
|
+
set :public, "#{@dir}/public"
|
22
19
|
|
23
20
|
get "/" do
|
24
21
|
haml :index
|
25
22
|
end
|
26
23
|
|
27
24
|
post '/import' do
|
28
|
-
klass
|
29
|
-
@import
|
30
|
-
@posts
|
25
|
+
@klass = params.delete('service').camelize.constantize
|
26
|
+
@import = klass.new(params)
|
27
|
+
@posts = @import.import!
|
28
|
+
|
31
29
|
haml :import
|
32
30
|
end
|
33
31
|
|
data/lib/server/views/index.haml
CHANGED
@@ -22,13 +22,14 @@
|
|
22
22
|
Posterous API
|
23
23
|
%option{ :value => 'posterous_feed_importer' }
|
24
24
|
Posterous Feed
|
25
|
+
%option{ :value => 'word_press_importer' }
|
26
|
+
WordPress MetaWeblog
|
25
27
|
|
26
28
|
%form.login_info{:style => 'display:none', :id => 'posterous_api_importer', :method => "POST"}
|
27
29
|
%p
|
28
30
|
%label
|
29
31
|
Email:
|
30
32
|
%input{:name => "username", :type => 'text', :value => '',:class=>"text_field"}
|
31
|
-
%br{:clear => "all"}
|
32
33
|
%p
|
33
34
|
%label
|
34
35
|
Password:
|
@@ -38,8 +39,6 @@
|
|
38
39
|
Hostname:
|
39
40
|
%input{:name => "hostname", :type => 'text', :value => '',:class=>"text_field"}
|
40
41
|
%input{:name => "service", :type => 'hidden', :value => 'posterous_api_importer',:class=>"text_field"}
|
41
|
-
|
42
|
-
|
43
42
|
%p
|
44
43
|
%input{:id => "submit_btn",:value => 'Export', :type => "submit"}
|
45
44
|
|
@@ -51,13 +50,31 @@
|
|
51
50
|
Site URL:
|
52
51
|
%input{:name => "feed_url", :type => 'text', :value => '',:class=>"text_field"}
|
53
52
|
%input{:name => "service", :type => 'hidden', :value => 'posterous_feed_importer',:class=>"text_field"}
|
54
|
-
|
55
|
-
|
56
53
|
%p
|
57
54
|
%input{:id => "submit_btn",:value => 'Export', :type => "submit"}
|
58
55
|
|
59
56
|
%br{:clear => "all"}
|
60
57
|
|
58
|
+
%form.login_info{:style => 'display:none', :id => 'word_press_importer', :method => "POST"}
|
59
|
+
%p
|
60
|
+
%label
|
61
|
+
Site URL:
|
62
|
+
%input{:name => "import_url", :type => 'text', :value => '',:class=>"text_field"}
|
63
|
+
|
64
|
+
%p
|
65
|
+
%label
|
66
|
+
Email:
|
67
|
+
%input{:name => "username", :type => 'text', :value => '',:class=>"text_field"}
|
68
|
+
%br{:clear => "all"}
|
69
|
+
%p
|
70
|
+
%label
|
71
|
+
Password:
|
72
|
+
%input{:name => "password", :type => 'password', :value => '',:class=>"text_field"}
|
73
|
+
%input{:name => "service", :type => 'hidden', :value => 'word_press_importer',:class=>"text_field"}
|
74
|
+
%p
|
75
|
+
%input{:id => "submit_btn",:value => 'Export', :type => "submit"}
|
76
|
+
|
77
|
+
%br{:clear => "all"}
|
61
78
|
|
62
79
|
|
63
80
|
#loading{:style => 'display:none'}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
version: 0.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Burnett
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-27 00:00:00 -07:00
|
19
19
|
default_executable: io-server
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
type: :runtime
|
66
66
|
version_requirements: *id003
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
68
|
+
name: xml-simple
|
69
69
|
prerelease: false
|
70
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
71
|
none: false
|
@@ -78,38 +78,10 @@ dependencies:
|
|
78
78
|
version: "0"
|
79
79
|
type: :runtime
|
80
80
|
version_requirements: *id004
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: haml
|
83
|
-
prerelease: false
|
84
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
hash: 3
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
93
|
-
type: :runtime
|
94
|
-
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: xml-simple
|
97
|
-
prerelease: false
|
98
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
hash: 3
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
version: "0"
|
107
|
-
type: :runtime
|
108
|
-
version_requirements: *id006
|
109
81
|
- !ruby/object:Gem::Dependency
|
110
82
|
name: feedtools
|
111
83
|
prerelease: false
|
112
|
-
requirement: &
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
113
85
|
none: false
|
114
86
|
requirements:
|
115
87
|
- - ">="
|
@@ -121,11 +93,11 @@ dependencies:
|
|
121
93
|
- 29
|
122
94
|
version: 0.2.29
|
123
95
|
type: :runtime
|
124
|
-
version_requirements: *
|
96
|
+
version_requirements: *id005
|
125
97
|
- !ruby/object:Gem::Dependency
|
126
98
|
name: vegas
|
127
99
|
prerelease: false
|
128
|
-
requirement: &
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
129
101
|
none: false
|
130
102
|
requirements:
|
131
103
|
- - ~>
|
@@ -137,7 +109,7 @@ dependencies:
|
|
137
109
|
- 2
|
138
110
|
version: 0.1.2
|
139
111
|
type: :runtime
|
140
|
-
version_requirements: *
|
112
|
+
version_requirements: *id006
|
141
113
|
description: Extracted modules from the Posterous Blog Importer. Used for conforming RSS Feeds or results from one API to another.
|
142
114
|
email: signalstatic@gmail.com
|
143
115
|
executables:
|
@@ -158,8 +130,8 @@ files:
|
|
158
130
|
- io_tools.gemspec
|
159
131
|
- lib/io_tools.rb
|
160
132
|
- lib/io_tools/helpers.rb
|
133
|
+
- lib/io_tools/helpers/meta_weblog.rb
|
161
134
|
- lib/io_tools/helpers/rss_feed.rb
|
162
|
-
- lib/io_tools/helpers/xml_rpc.rb
|
163
135
|
- lib/io_tools/importer.rb
|
164
136
|
- lib/server/config.ru
|
165
137
|
- lib/server/importers/posterous_api_importer.rb
|