Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bring API in line with instapaper additions

Instapaper added the 'selection' param to specify an optional description for
an article. Added this as a param to the bin and optional param to the .add
method. Bumped version and updated gemspec.
  • Loading branch information...
commit 95979723e6ea60de52f1b2cb1bbf4ff268ff98b8 1 parent c9fc7ae
@dakrone authored
Showing with 35 additions and 14 deletions.
  1. +1 −1  VERSION
  2. +9 −2 bin/ricepaper
  3. +17 −7 lib/ricepaper.rb
  4. +8 −4 ricepaper.gemspec
View
2  VERSION
@@ -1 +1 @@
-0.0.2
+0.0.3
View
11 bin/ricepaper
@@ -14,6 +14,7 @@ options = OptionParser.new do |opts|
opts.on("-p", "--password [PASS]", "Password") { |opt| opthash['password'] = opt }
opts.on("-a", "--authenticate", "Only attempt to authenticate to Instapaper") { |opt| opthash['authenticate'] = opt }
opts.on("-t", "--title [TITLE]", "Optional title for instantpaper entry") { |opt| opthash['title'] = opt }
+ opts.on("-d", "--description [DESC]", "Optional description for the article") { |opt| opthash['desc'] = opt }
end
options.parse!(ARGV)
@@ -33,8 +34,14 @@ if ARGV.size < 1
end
ARGV.each do |url|
- print "Submitting '#{url}' #{opthash['title'].nil? ? "" : "with title '#{opthash['title']}'"} ... "
- result = rp.add(url,opthash['title'])
+ if (!opthash['desc'].nil?)
+ print "Submitting '#{url}' #{opthash['title'].nil? ? "" : "with title '#{opthash['title']}'"}"
+ print ", description '#{opthash['desc']}' ... "
+ else
+ print "Submitting '#{url}' #{opthash['title'].nil? ? "" : "with title '#{opthash['title']}'"} ... "
+ end
+
+ result = rp.add(url,opthash['title'], opthash['desc'])
puts result ? "Successful." : "Failed."
puts "Error: #{rp.error}" unless result
View
24 lib/ricepaper.rb
@@ -46,13 +46,23 @@ def authenticate
# Add a url to instapaper, given a url and an optional
# title; if no title is given, auto-title by instapaper
- def add(url, title=nil)
- result = RestClient.post @apiurl + "add",
- :username => @username,
- :password => @password,
- :url => url,
- :title => title,
- :"auto-title" => title.nil? ? "1" : "0"
+ def add(url, title=nil, description=nil)
+ if (description.nil?)
+ result = RestClient.post @apiurl + "add",
+ :username => @username,
+ :password => @password,
+ :url => url,
+ :title => title,
+ :"auto-title" => title.nil? ? "1" : "0"
+ else
+ result = RestClient.post @apiurl + "add",
+ :username => @username,
+ :password => @password,
+ :url => url,
+ :title => title,
+ :"auto-title" => title.nil? ? "1" : "0",
+ :selection => description
+ end
rescue RestClient::RequestFailed
handle_error($!)
return false
View
12 ricepaper.gemspec
@@ -1,12 +1,15 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{ricepaper}
- s.version = "0.0.2"
+ s.version = "0.0.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Lee Hinman"]
- s.date = %q{2009-07-21}
+ s.date = %q{2010-07-01}
s.default_executable = %q{ricepaper}
s.description = %q{Ricepaper is a library that allows you to add URLs to Instapaper, either by using it as a CLI or as a Ruby library.}
s.email = %q{lee@writequit.org}
@@ -28,7 +31,7 @@ Gem::Specification.new do |s|
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{writequit}
- s.rubygems_version = %q{1.3.4}
+ s.rubygems_version = %q{1.3.7}
s.summary = %q{A small library for adding URLs to Instapaper}
s.test_files = [
"examples/add_sites.rb",
@@ -39,9 +42,10 @@ Gem::Specification.new do |s|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
else
end
else
end
end
+
Please sign in to comment.
Something went wrong with that request. Please try again.