diff --git a/.travis.yml b/.travis.yml index b1a149d..09f9590 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ rvm: - 1.9.3 - 2.0.0 - 2.1 + - 2.2 + - 2.3.0 - ruby-head sudo: false diff --git a/Gemfile b/Gemfile index 1bf80a7..4d42d75 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Rakefile b/Rakefile index b281138..a2b1429 100644 --- a/Rakefile +++ b/Rakefile @@ -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" diff --git a/lib/tacokit/client.rb b/lib/tacokit/client.rb index fafd39d..bf041cb 100644 --- a/lib/tacokit/client.rb +++ b/lib/tacokit/client.rb @@ -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 diff --git a/lib/tacokit/client/actions.rb b/lib/tacokit/client/actions.rb index 0c26f20..d177373 100644 --- a/lib/tacokit/client/actions.rb +++ b/lib/tacokit/client/actions.rb @@ -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 diff --git a/lib/tacokit/client/boards.rb b/lib/tacokit/client/boards.rb index c6f6813..688edd8 100644 --- a/lib/tacokit/client/boards.rb +++ b/lib/tacokit/client/boards.rb @@ -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] the board identifier or board diff --git a/lib/tacokit/client/cards.rb b/lib/tacokit/client/cards.rb index 6097a3e..d34d94d 100644 --- a/lib/tacokit/client/cards.rb +++ b/lib/tacokit/client/cards.rb @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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] the destination card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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 @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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] the card identifier, shortlink, or card @@ -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 diff --git a/lib/tacokit/client/checklists.rb b/lib/tacokit/client/checklists.rb index 24004da..58b3acc 100644 --- a/lib/tacokit/client/checklists.rb +++ b/lib/tacokit/client/checklists.rb @@ -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 @@ -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] the card identifier, shortlink, or card @@ -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 @@ -64,8 +64,8 @@ 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 @@ -73,7 +73,7 @@ def add_checklist_check_item(checklist_id, name, options = {}) def delete_checklist(checklist_id) delete checklist_path(checklist_id) end - alias_method :checklist_delete, :delete_checklist + alias checklist_delete delete_checklist private diff --git a/lib/tacokit/client/members.rb b/lib/tacokit/client/members.rb index 828a320..16c6046 100644 --- a/lib/tacokit/client/members.rb +++ b/lib/tacokit/client/members.rb @@ -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 diff --git a/lib/tacokit/configuration.rb b/lib/tacokit/configuration.rb index 5c3dbae..64e3ee3 100644 --- a/lib/tacokit/configuration.rb +++ b/lib/tacokit/configuration.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Tacokit class Configuration API_URL = "https://api.trello.com".freeze @@ -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? diff --git a/lib/tacokit/resource.rb b/lib/tacokit/resource.rb index 489c1ae..c96b979 100644 --- a/lib/tacokit/resource.rb +++ b/lib/tacokit/resource.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require "set" require "time" require "forwardable" @@ -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? @@ -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 @@ -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 diff --git a/lib/tacokit/utils.rb b/lib/tacokit/utils.rb index 53bafc6..805149e 100644 --- a/lib/tacokit/utils.rb +++ b/lib/tacokit/utils.rb @@ -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) } diff --git a/lib/tacokit/version.rb b/lib/tacokit/version.rb index d5a22c6..4e2f3bb 100644 --- a/lib/tacokit/version.rb +++ b/lib/tacokit/version.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true module Tacokit - VERSION = "0.3.1" + VERSION = "0.3.1".freeze end