mirror of
https://github.com/samsonjs/instapaper.git
synced 2026-03-25 08:55:49 +00:00
fix more rubocop failures
This commit is contained in:
parent
5161c68b5a
commit
29e49c1ed7
10 changed files with 43 additions and 44 deletions
|
|
@ -11,14 +11,14 @@ module Instapaper
|
|||
consumer_key: consumer_key,
|
||||
consumer_secret: consumer_secret,
|
||||
token: oauth_token,
|
||||
token_secret: oauth_token_secret
|
||||
token_secret: oauth_token_secret,
|
||||
}
|
||||
end
|
||||
|
||||
def consumer_tokens
|
||||
{
|
||||
consumer_key: consumer_key,
|
||||
consumer_secret: consumer_secret
|
||||
consumer_secret: consumer_secret,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module Instapaper
|
|||
class Client
|
||||
# Defines methods related to bookmarks
|
||||
module Bookmark
|
||||
# Lists the user’s unread bookmarks, and can also synchronize reading positions.
|
||||
# Lists the user's unread bookmarks, and can also synchronize reading positions.
|
||||
# @option limit: Optional. A number between 1 and 500, default 25.
|
||||
# @option folder_id: Optional. Possible values are unread (default), starred, archive, or a folder_id value from /api/1/folders/list.
|
||||
# @option have: Optional. A concatenation of bookmark_id values that the client already has from the specified folder. See below.
|
||||
|
|
@ -10,7 +10,7 @@ module Instapaper
|
|||
post('bookmarks/list', options)[2..-1]
|
||||
end
|
||||
|
||||
# Updates the user’s reading progress on a single article.
|
||||
# Updates the user's reading progress on a single article.
|
||||
# @param bookmark_id [String] The id of the bookmark to update.
|
||||
# @param progress [Float] The user’s progress, as a floating-point number between 0.0 and 1.0, defined as the top edge of the user’s current viewport, expressed as a percentage of the article’s total length.
|
||||
# @param progress_timestamp [Integer] The Unix timestamp value of the time that the progress was recorded.
|
||||
|
|
@ -18,14 +18,14 @@ module Instapaper
|
|||
post('bookmarks/update_read_progress', bookmark_id: bookmark_id, progress: progress, progress_timestamp: progress_timestamp.to_i).first
|
||||
end
|
||||
|
||||
# Adds a new unread bookmark to the user’s account.
|
||||
# Adds a new unread bookmark to the user's account.
|
||||
# @param url [String] The url of the bookmark.
|
||||
def add_bookmark(url, options = {})
|
||||
post('bookmarks/add', options.merge(url: url)).first
|
||||
end
|
||||
|
||||
# Permanently deletes the specified bookmark.
|
||||
# This is NOT the same as Archive. Please be clear to users if you’re going to do this.
|
||||
# This is NOT the same as Archive. Please be clear to users if you're going to do this.
|
||||
# @param bookmark_id [String] The id of the bookmark.
|
||||
def delete_bookmark(bookmark_id)
|
||||
post('bookmarks/delete', bookmark_id: bookmark_id)
|
||||
|
|
@ -67,11 +67,11 @@ module Instapaper
|
|||
end
|
||||
alias_method :move_bookmark, :move
|
||||
|
||||
# Returns the specified bookmark’s processed text-view HTML, which is
|
||||
# Returns the specified bookmark's processed text-view HTML, which is
|
||||
# always text/html encoded as UTF-8.
|
||||
# @param bookmark_id [String] The id of the bookmark.
|
||||
def text(bookmark_id)
|
||||
post('bookmarks/get_text', { bookmark_id: bookmark_id }, true).body
|
||||
post('bookmarks/get_text', {bookmark_id: bookmark_id}, true).body
|
||||
end
|
||||
alias_method :get_text, :text
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module Instapaper
|
|||
class Client
|
||||
# Defines methods related to folders
|
||||
module Folder
|
||||
# List the account’s user-created folders.
|
||||
# List the account's user-created folders.
|
||||
# @note This only includes organizational folders and does not include RSS-feed folders or starred-subscription folders
|
||||
def folders
|
||||
post('folders/list')
|
||||
|
|
@ -20,7 +20,7 @@ module Instapaper
|
|||
post('folders/delete', folder_id: folder_id)
|
||||
end
|
||||
|
||||
# Re-orders a user’s folders.
|
||||
# Re-orders a user's folders.
|
||||
# @param order [Array] An array of folder_id:position pairs joined by commas.
|
||||
# @example Ordering folder_ids 100, 200, and 300
|
||||
# Instapaper.set_order(['100:1','200:2','300:3'])
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module Instapaper
|
|||
module User
|
||||
# Gets an OAuth access token for a user.
|
||||
def access_token(username, password)
|
||||
response = post('oauth/access_token', { x_auth_username: username, x_auth_password: password, x_auth_mode: 'client_auth' }, true)
|
||||
response = post('oauth/access_token', {x_auth_username: username, x_auth_password: password, x_auth_mode: 'client_auth'}, true)
|
||||
params = response.body.split('&')
|
||||
values = params.map { |part| part.split('=') }.flatten
|
||||
if values.length == 1
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ module Instapaper
|
|||
'User-Agent' => user_agent
|
||||
},
|
||||
proxy: proxy,
|
||||
ssl: { verify: false },
|
||||
url: api_endpoint)
|
||||
|
||||
Faraday.new(merged_options) do |builder|
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ describe Instapaper::Client::Account do
|
|||
describe '.verify_credentials' do
|
||||
before do
|
||||
stub_post('account/verify_credentials')
|
||||
.to_return(body: fixture('verify_credentials.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('verify_credentials.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.bookmarks' do
|
||||
before do
|
||||
stub_post('bookmarks/list')
|
||||
.to_return(body: fixture('bookmarks_list.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_list.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
|
|
@ -36,12 +36,12 @@ describe Instapaper::Client::Bookmark do
|
|||
before do
|
||||
@time = Time.now
|
||||
stub_post('bookmarks/update_read_progress')
|
||||
.to_return(body: fixture('bookmarks_update_read_progress.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_update_read_progress.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.update_read_progress(123, 0.5, @time)
|
||||
expect(a_post('bookmarks/update_read_progress').with(body: { bookmark_id: '123', progress: '0.5', progress_timestamp: @time.to_i.to_s }))
|
||||
expect(a_post('bookmarks/update_read_progress').with(body: {bookmark_id: '123', progress: '0.5', progress_timestamp: @time.to_i.to_s}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -56,12 +56,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.add_bookmark' do
|
||||
before do
|
||||
stub_post('bookmarks/add')
|
||||
.to_return(body: fixture('bookmarks_add.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_add.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.add_bookmark('http://someurl.com', title: 'This is the title', description: 'This is the description')
|
||||
expect(a_post('bookmarks/add').with(body: { url: 'http://someurl.com', title: 'This is the title', description: 'This is the description' }))
|
||||
expect(a_post('bookmarks/add').with(body: {url: 'http://someurl.com', title: 'This is the title', description: 'This is the description'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -75,12 +75,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.delete_bookmark' do
|
||||
before do
|
||||
stub_post('bookmarks/delete')
|
||||
.to_return(body: '[]', headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: '[]', headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.delete_bookmark(123)
|
||||
expect(a_post('bookmarks/delete').with(body: { bookmark_id: '123' }))
|
||||
expect(a_post('bookmarks/delete').with(body: {bookmark_id: '123'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -94,12 +94,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.star' do
|
||||
before do
|
||||
stub_post('bookmarks/star')
|
||||
.to_return(body: fixture('bookmarks_star.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_star.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.star(123)
|
||||
expect(a_post('bookmarks/star').with(body: { bookmark_id: '123' }))
|
||||
expect(a_post('bookmarks/star').with(body: {bookmark_id: '123'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -118,12 +118,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.unstar' do
|
||||
before do
|
||||
stub_post('bookmarks/unstar')
|
||||
.to_return(body: fixture('bookmarks_unstar.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_unstar.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.unstar(123)
|
||||
expect(a_post('bookmarks/unstar').with(body: { bookmark_id: '123' }))
|
||||
expect(a_post('bookmarks/unstar').with(body: {bookmark_id: '123'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -142,12 +142,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.archive' do
|
||||
before do
|
||||
stub_post('bookmarks/archive')
|
||||
.to_return(body: fixture('bookmarks_archive.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_archive.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.archive(123)
|
||||
expect(a_post('bookmarks/archive').with(body: { bookmark_id: '123' }))
|
||||
expect(a_post('bookmarks/archive').with(body: {bookmark_id: '123'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -165,12 +165,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.unarchive' do
|
||||
before do
|
||||
stub_post('bookmarks/unarchive')
|
||||
.to_return(body: fixture('bookmarks_unarchive.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_unarchive.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.unarchive(123)
|
||||
expect(a_post('bookmarks/unarchive').with(body: { bookmark_id: '123' }))
|
||||
expect(a_post('bookmarks/unarchive').with(body: {bookmark_id: '123'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -188,12 +188,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.move' do
|
||||
before do
|
||||
stub_post('bookmarks/move')
|
||||
.to_return(body: fixture('bookmarks_move.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_move.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.move(123, 12_345)
|
||||
expect(a_post('bookmarks/move').with(body: { bookmark_id: '123', folder_id: '12345' }))
|
||||
expect(a_post('bookmarks/move').with(body: {bookmark_id: '123', folder_id: '12345'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
@ -211,12 +211,12 @@ describe Instapaper::Client::Bookmark do
|
|||
describe '.text' do
|
||||
before do
|
||||
stub_post('bookmarks/get_text')
|
||||
.to_return(body: fixture('bookmarks_get_text.txt'), headers: { content_type: 'text/html; charset=utf-8' })
|
||||
.to_return(body: fixture('bookmarks_get_text.txt'), headers: {content_type: 'text/html; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
@client.text(123)
|
||||
expect(a_post('bookmarks/get_text').with(body: { bookmark_id: '123' }))
|
||||
expect(a_post('bookmarks/get_text').with(body: {bookmark_id: '123'}))
|
||||
.to have_been_made
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ describe Instapaper::Client::Folder do
|
|||
describe '.folders' do
|
||||
before do
|
||||
stub_post('folders/list')
|
||||
.to_return(body: fixture('folders_list.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
.to_return(body: fixture('folders_list.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
|
|
@ -28,8 +28,8 @@ describe Instapaper::Client::Folder do
|
|||
|
||||
describe '.add_folder' do
|
||||
before do
|
||||
stub_post('folders/add').with(body: { title: 'Ruby' })
|
||||
.to_return(body: fixture('folders_add.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
stub_post('folders/add').with(body: {title: 'Ruby'})
|
||||
.to_return(body: fixture('folders_add.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
|
|
@ -49,8 +49,8 @@ describe Instapaper::Client::Folder do
|
|||
|
||||
describe '.delete_folder' do
|
||||
before do
|
||||
stub_post('folders/delete'). with(body: { folder_id: '1' })
|
||||
.to_return(body: fixture('folders_delete.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
stub_post('folders/delete'). with(body: {folder_id: '1'})
|
||||
.to_return(body: fixture('folders_delete.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
|
|
@ -68,8 +68,8 @@ describe Instapaper::Client::Folder do
|
|||
|
||||
describe '.set_order' do
|
||||
before do
|
||||
stub_post('folders/set_order'). with(body: { order: '1121173:2,1121174:1' })
|
||||
.to_return(body: fixture('folders_set_order.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
||||
stub_post('folders/set_order'). with(body: {order: '1121173:2,1121174:1'})
|
||||
.to_return(body: fixture('folders_set_order.json'), headers: {content_type: 'application/json; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ describe Instapaper::Client::User do
|
|||
|
||||
describe '.access_token' do
|
||||
before do
|
||||
stub_post('oauth/access_token').with(body: { x_auth_username: 'ohai', x_auth_password: 'p455w0rd', x_auth_mode: 'client_auth' })
|
||||
.to_return(body: fixture('access_token.qline'), headers: { content_type: 'text/plain; charset=utf-8' })
|
||||
stub_post('oauth/access_token').with(body: { x_auth_username: 'inval1d', x_auth_password: 'cr3dentials', x_auth_mode: 'client_auth' })
|
||||
.to_return(body: fixture('invalid_credentials.qline'), headers: { content_type: 'text/plain; charset=utf-8' })
|
||||
stub_post('oauth/access_token').with(body: {x_auth_username: 'ohai', x_auth_password: 'p455w0rd', x_auth_mode: 'client_auth'})
|
||||
.to_return(body: fixture('access_token.qline'), headers: {content_type: 'text/plain; charset=utf-8'})
|
||||
stub_post('oauth/access_token').with(body: {x_auth_username: 'inval1d', x_auth_password: 'cr3dentials', x_auth_mode: 'client_auth'})
|
||||
.to_return(body: fixture('invalid_credentials.qline'), headers: {content_type: 'text/plain; charset=utf-8'})
|
||||
end
|
||||
|
||||
it 'should get the correct resource' do
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Instapaper::Client do
|
||||
before do
|
||||
@options = { adapter: :em_synchrony, user_agent: 'Instapaper::Client spec' }
|
||||
@options = {adapter: :em_synchrony, user_agent: 'Instapaper::Client spec'}
|
||||
@keys = Instapaper::Configuration::VALID_OPTIONS_KEYS
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue