Skip to content

Commit

Permalink
Merge pull request #17 from rossta/update_rubocop
Browse files Browse the repository at this point in the history
Update rubocop and correct warnings
  • Loading branch information
rossta committed Jan 29, 2016
2 parents f4f5a9a + 967f0ae commit 69f5846
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -4,6 +4,8 @@ rvm:
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.3.0
- ruby-head

sudo: false
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -13,7 +13,7 @@ gem "pry-byebug", platforms: [:ruby_21, :ruby_22]
gem "rake"
gem "rb-fsevent"
gem "rspec", "~> 3.3"
gem "rubocop", "0.34"
gem "rubocop", "~> 0.34"
gem "sinatra"
gem "vcr"
gem "webmock"
Expand Down
9 changes: 3 additions & 6 deletions Rakefile
Expand Up @@ -18,12 +18,9 @@ namespace :doc do
begin
require "yard"
rescue LoadError => e
if e.message =~ /yard/
warn "Please install `gem install yard` first"
exit
else
raise e
end
raise e unless e.message =~ /yard/
warn "Please install `gem install yard` first"
exit
end

require "fileutils"
Expand Down
2 changes: 1 addition & 1 deletion lib/tacokit/client.rb
Expand Up @@ -107,7 +107,7 @@ def request(method, url, data = nil, params = nil)
def to_s
"<#{self.class}:#{object_id}>"
end
alias_method :inspect, :to_s
alias inspect to_s

private

Expand Down
2 changes: 1 addition & 1 deletion lib/tacokit/client/actions.rb
Expand Up @@ -86,7 +86,7 @@ def update_action(action_id, options = {})
def update_action_text(action_id, text)
put action_path(action_id, "text"), value: text
end
alias_method :edit_action_text, :update_action_text
alias edit_action_text update_action_text

# Delete an action
# @param action_id [String] the action identifier
Expand Down
2 changes: 1 addition & 1 deletion lib/tacokit/client/boards.rb
Expand Up @@ -101,7 +101,7 @@ def board_labels(board_id, options = {})
def lists(board_id, options = {})
board_resource(board_id, "lists", options)
end
alias_method :board_lists, :lists
alias board_lists lists

# Retrieve a board's members
# @param board_id [String, Tacokit::Resource<Board>] the board identifier or board
Expand Down
28 changes: 14 additions & 14 deletions lib/tacokit/client/cards.rb
Expand Up @@ -40,7 +40,7 @@ def card_actions(card_id, options = {})
def attachments(card_id, options = {})
card_resource(card_id, "attachments", options)
end
alias_method :card_attachments, :attachments
alias card_attachments attachments

# Retrieve a card attachment
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand Down Expand Up @@ -162,7 +162,7 @@ def update_card(card_id, options = {})
def update_comment(card_id, comment_id, text, options = {})
update_card_resource(card_id, "actions", resource_id(comment_id), "comments", options.merge(text: text))
end
alias_method :edit_comment, :update_comment
alias edit_comment update_comment

# Update checklist item text, position or state
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand Down Expand Up @@ -274,7 +274,7 @@ def add_comment(card_id, text, options = {})
options.update text: text
create_card_resource card_id, "actions", "comments", options
end
alias_method :create_card_comment, :add_comment
alias create_card_comment add_comment

# Attach a file to a card
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -300,7 +300,7 @@ def attach_file(card_id, url, mime_type = nil, options = {})

create_card_resource card_id, "attachments", options
end
alias_method :create_card_attachment, :attach_file
alias create_card_attachment attach_file

# Convert a checklist item to a card
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -327,7 +327,7 @@ def convert_to_card(card_id, checklist_id, check_item_id)
def add_checklist(card_id, name)
create_card_resource(card_id, "checklists", name: name)
end
alias_method :start_checklist, :add_checklist
alias start_checklist add_checklist

# Copy another checklist to card
# @param card_id [String, Tacokit::Resource<Card>] the destination card identifier, shortlink, or card
Expand Down Expand Up @@ -376,7 +376,7 @@ def add_label(card_id, color, options = {})
def vote(card_id, member_id)
create_card_resource(card_id, "membersVoted", value: resource_id(member_id))
end
alias_method :create_vote, :vote
alias create_vote vote

# Add sticker to card
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -389,7 +389,7 @@ def add_sticker(card_id, image_name, options = {})
defaults = { top: 0, left: 0, z_index: 1 }
create_card_resource(card_id, "stickers", defaults.merge(options.merge(image: image_name)))
end
alias_method :create_sticker, :add_sticker
alias create_sticker add_sticker

# @private
# Create a card resource
Expand Down Expand Up @@ -419,7 +419,7 @@ def delete_card(card_id)
def remove_comment(card_id, comment_id)
delete_card_resource card_id, "actions", resource_id(comment_id), "comments"
end
alias_method :delete_comment, :remove_comment
alias delete_comment remove_comment

# Remove an attachment
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -432,7 +432,7 @@ def remove_comment(card_id, comment_id)
def remove_attachment(card_id, attachment_id)
delete_card_resource card_id, "attachments", resource_id(attachment_id)
end
alias_method :delete_attachement, :remove_attachment
alias delete_attachement remove_attachment

# Remove checklist
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -444,7 +444,7 @@ def remove_attachment(card_id, attachment_id)
def remove_checklist(card_id, checklist_id)
delete_card_resource card_id, "checklists", checklist_id
end
alias_method :delete_checklist, :remove_checklist
alias delete_checklist remove_checklist

# Remove a member from a card
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -459,7 +459,7 @@ def remove_checklist(card_id, checklist_id)
def remove_card_member(card_id, member_id)
delete_card_resource card_id, "idMembers", resource_id(member_id)
end
alias_method :delete_card_member, :remove_card_member
alias delete_card_member remove_card_member

# Remove label from card
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -470,7 +470,7 @@ def remove_card_member(card_id, member_id)
def remove_label(card_id, color)
delete_card_resource card_id, "labels", color
end
alias_method :delete_label, :remove_label
alias delete_label remove_label

# Remove a vote from a card
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -482,7 +482,7 @@ def remove_label(card_id, color)
def remove_vote(card_id, member_id)
delete_card_resource card_id, "membersVoted", resource_id(member_id)
end
alias_method :delete_vote, :remove_vote
alias delete_vote remove_vote

# Remove a sticker from a card
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -494,7 +494,7 @@ def remove_vote(card_id, member_id)
def remove_sticker(card_id, sticker_id)
delete_card_resource card_id, "stickers", resource_id(sticker_id)
end
alias_method :delete_sticker, :remove_sticker
alias delete_sticker remove_sticker

private

Expand Down
12 changes: 6 additions & 6 deletions lib/tacokit/client/checklists.rb
Expand Up @@ -36,7 +36,7 @@ def checklist_card(checklist_id, options = {})
def check_items(checklist_id, options = {})
checklist_resource checklist_id, "check_items", options
end
alias_method :checklist_check_items, :check_items
alias checklist_check_items check_items

# Updates a checklist
# @param checklist_id [String] the checklist identifier
Expand All @@ -45,7 +45,7 @@ def check_items(checklist_id, options = {})
def update_checklist(checklist_id, options = {})
put checklist_path(checklist_id), options
end
alias_method :checklist_update, :update_checklist
alias checklist_update update_checklist

# Create a checklist
# @param card_id [String, Tacokit::Resource<Card>] the card identifier, shortlink, or card
Expand All @@ -55,7 +55,7 @@ def create_checklist(card_id, name, options = {})
options.update card_id: card_id, name: name
post "checklists", options
end
alias_method :checklist_create, :create_checklist
alias checklist_create create_checklist

# Add a checklist item to a checklist
# @param checklist_id [String] the checklist identifier
Expand All @@ -64,16 +64,16 @@ def create_checklist(card_id, name, options = {})
def add_checklist_check_item(checklist_id, name, options = {})
post checklist_path(checklist_id, "checkItems"), options.merge(name: name)
end
alias_method :checklist_check_item_create, :add_checklist_check_item
alias_method :add_checklist_item, :add_checklist_check_item
alias checklist_check_item_create add_checklist_check_item
alias add_checklist_item add_checklist_check_item

# Delete a checklist
# @param checklist_id [String] the checklist identifier
# @see https://developers.trello.com/advanced-reference/checklist#delete-1-checklists-idchecklist
def delete_checklist(checklist_id)
delete checklist_path(checklist_id)
end
alias_method :checklist_delete, :delete_checklist
alias checklist_delete delete_checklist

private

Expand Down
2 changes: 1 addition & 1 deletion lib/tacokit/client/members.rb
Expand Up @@ -47,7 +47,7 @@ def actions(username = "me", options = {})
username, options = extract_member_args(username, options)
paginated_get member_path(username, "actions"), options
end
alias_method :member_actions, :actions
alias member_actions actions

# @overload boards(username = "me", options = {})
# Retrieve a member's boards
Expand Down
3 changes: 2 additions & 1 deletion lib/tacokit/configuration.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Tacokit
class Configuration
API_URL = "https://api.trello.com".freeze
Expand Down Expand Up @@ -33,7 +34,7 @@ def user_authenticated?
end

def user_credentials
{ consumer_key: app_key, token: oauth_token }.delete_if { |k, v| v.nil? }
{ consumer_key: app_key, consumer_secret: app_secret, token: oauth_token }.delete_if { |k, v| v.nil? }
end

def app_authenticated?
Expand Down
13 changes: 7 additions & 6 deletions lib/tacokit/resource.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require "set"
require "time"
require "forwardable"
Expand All @@ -10,8 +11,8 @@ class Resource
SPECIAL_METHODS = Set.new(%w[fields])
attr_reader :_fields
attr_reader :attrs
alias_method :to_hash, :attrs
alias_method :to_h, :attrs
alias to_hash attrs
alias to_h attrs

def_delegators :@_fields, :fetch, :keys, :any?

Expand Down Expand Up @@ -43,14 +44,14 @@ def []=(method, value)
def key?(key)
@_fields.include?(key)
end
alias_method :has_key?, :key?
alias_method :include?, :key?
alias has_key? key?
alias include? key?

def inspect
(to_attrs.respond_to?(:pretty_inspect) ? to_attrs.pretty_inspect : to_attrs.inspect)
end

alias_method :to_s, :inspect
alias to_s inspect

def to_attrs
hash = attrs.clone
Expand Down Expand Up @@ -129,7 +130,7 @@ def getter_missing(attr_name, suffix)
end

# rubocop:disable Metrics/LineLength
ISO8601 = %r{^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$}.freeze
ISO8601 = %r{^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$}
# rubocop:enable Metrics/LineLength
def cast_value_type(value)
case value
Expand Down
2 changes: 1 addition & 1 deletion lib/tacokit/utils.rb
Expand Up @@ -37,7 +37,7 @@ def present?(obj)
def camel_path(path)
camelize(path.to_s, :lower)
end
alias_method :camp, :camel_path
alias camp camel_path

def camel_join(*paths)
path_join paths.map { |p| camel_path(p) }
Expand Down
3 changes: 2 additions & 1 deletion lib/tacokit/version.rb
@@ -1,3 +1,4 @@
# frozen_string_literal: true
module Tacokit
VERSION = "0.3.1"
VERSION = "0.3.1".freeze
end

0 comments on commit 69f5846

Please sign in to comment.