papersync 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +23 -0
- data/VERSION +1 -0
- data/bin/papersync +15 -0
- data/lib/papersync.rb +33 -0
- data/papersync.gemspec +48 -0
- metadata +73 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 James Fairbairn
|
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,17 @@
|
|
1
|
+
= papersync
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 James Fairbairn. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "papersync"
|
8
|
+
gem.summary = %Q{Download your Instapaper content in mobi format.}
|
9
|
+
gem.description = %Q{}
|
10
|
+
gem.email = "james@netlagoon.com"
|
11
|
+
gem.homepage = "http://github.com/jfairbairn/papersync"
|
12
|
+
gem.authors = ["James Fairbairn"]
|
13
|
+
gem.executables = 'papersync'
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
task :test => :check_dependencies
|
21
|
+
|
22
|
+
task :default => :test
|
23
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/papersync
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'papersync'
|
4
|
+
|
5
|
+
def die(msg)
|
6
|
+
STDERR.puts msg
|
7
|
+
exit -1
|
8
|
+
end
|
9
|
+
|
10
|
+
die "Usage: papersync <destdir>" unless ARGV.size == 1
|
11
|
+
dirpath = ARGV[0]
|
12
|
+
die "Directory #{dirpath} does not exist!" unless File.exist? dirpath
|
13
|
+
die "Directory #{dirpath} is not a directory!" unless File.directory? dirpath
|
14
|
+
|
15
|
+
PaperSync.new(PaperSync::Credentials.new, dirpath).fetch
|
data/lib/papersync.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'uri'
|
3
|
+
require 'cgi'
|
4
|
+
class PaperSync
|
5
|
+
class Credentials
|
6
|
+
attr_reader :username, :password
|
7
|
+
def initialize
|
8
|
+
credpath = File.join(ENV['HOME'], '.papersync')
|
9
|
+
@username, @password = eval(File.read(credpath))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(credentials, destdir)
|
14
|
+
@credentials, @destdir = credentials, destdir
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch
|
18
|
+
auth_uri = URI.parse("https://www.instapaper.com/user/login")
|
19
|
+
http = Net::HTTP.new(auth_uri.host, auth_uri.port)
|
20
|
+
http.use_ssl=true
|
21
|
+
res = http.start do |h|
|
22
|
+
h.post("#{auth_uri.path}?#{auth_uri.query}", "username=#{CGI.escape(@credentials.username)}&password=#{CGI.escape(@credentials.password)}")
|
23
|
+
end
|
24
|
+
cookies = res['set-cookie'].split(',').map(&:strip)
|
25
|
+
http = Net::HTTP.new('www.instapaper.com', 80)
|
26
|
+
res = http.start do |h|
|
27
|
+
req = Net::HTTP::Get.new('/mobi')
|
28
|
+
req['cookie'] = cookies.map{|i|i.split(';').first}.join(';')
|
29
|
+
h.request(req)
|
30
|
+
end
|
31
|
+
File.open(File.join(@destdir, 'instapaper.mobi'), 'wb') {|f|f.write(res.body)}
|
32
|
+
end
|
33
|
+
end
|
data/papersync.gemspec
ADDED
@@ -0,0 +1,48 @@
|
|
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{papersync}
|
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 = ["James Fairbairn"]
|
12
|
+
s.date = %q{2010-08-24}
|
13
|
+
s.default_executable = %q{papersync}
|
14
|
+
s.description = %q{}
|
15
|
+
s.email = %q{james@netlagoon.com}
|
16
|
+
s.executables = ["papersync"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/papersync",
|
29
|
+
"lib/papersync.rb",
|
30
|
+
"papersync.gemspec"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/jfairbairn/papersync}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.7}
|
36
|
+
s.summary = %q{Download your Instapaper content in mobi format.}
|
37
|
+
|
38
|
+
if s.respond_to? :specification_version then
|
39
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
|
+
s.specification_version = 3
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
+
else
|
44
|
+
end
|
45
|
+
else
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: papersync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- James Fairbairn
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-08-24 00:00:00 +01:00
|
18
|
+
default_executable: papersync
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: ""
|
22
|
+
email: james@netlagoon.com
|
23
|
+
executables:
|
24
|
+
- papersync
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- .document
|
32
|
+
- .gitignore
|
33
|
+
- LICENSE
|
34
|
+
- README.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- VERSION
|
37
|
+
- bin/papersync
|
38
|
+
- lib/papersync.rb
|
39
|
+
- papersync.gemspec
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/jfairbairn/papersync
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options:
|
46
|
+
- --charset=UTF-8
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.7
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Download your Instapaper content in mobi format.
|
72
|
+
test_files: []
|
73
|
+
|