Skip to content

Commit

Permalink
Merge pull request #129 from halorrr/add-and-configure-yard-docs
Browse files Browse the repository at this point in the history
Add and configure yard docs
  • Loading branch information
mmenanno authored Jan 24, 2024
2 parents 2b68ee1 + bc5fa38 commit 82b7e6f
Show file tree
Hide file tree
Showing 36 changed files with 140 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/build_and_public_yard_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Publish Yard Docs

on:
push:
branches: [ main ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
name: Build and Publish Yard Docs
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1.165.1
with:
ruby-version: 3.3.0
bundler-cache: true

- name: Install YARD
run: gem install yard

- name: Generate docs
run: yard docs

- name: Setup Github Pages
uses: actions/configure-pages@v4

- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
path: "doc"

- name: Publish to Github Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--plugin yard-sorbet
--markup markdown
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ gem "sorbet-static-and-runtime", require: false
gem "spoom", require: false
gem "tapioca", require: false
gem "dotenv"
gem "yard", require: false
gem "yard-sorbet", require: false
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ DEPENDENCIES
spoom
tapioca
toys
yard
yard-sorbet

BUNDLED WITH
2.5.3
27 changes: 27 additions & 0 deletions bin/yard
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'yard' is installed as part of a gem, and
# this file is here to facilitate running it.
#

ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

bundle_binstub = File.expand_path("bundle", __dir__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("yard", "yard")
14 changes: 13 additions & 1 deletion lib/lunchmoney.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,28 @@
require "sorbet-runtime"

# Include T::Sig directly in the module class so that it doesn't need to be extended everywhere.
Module.include(T::Sig)
class Module
include T::Sig
end

require_relative "lunchmoney/version"
require_relative "lunchmoney/validators"
require_relative "lunchmoney/api"

module LunchMoney
# Lock used to avoid config conflicts
LOCK = T.let(Mutex.new, Mutex)

class << self
# @example Set your API key
# LunchMoney.configure do |config|
# config.api_key = "your_api_key"
# end
#
# @example Turn off object validation
# LunchMoney.configure do |config|
# config.validate_object_attributes = false
# end
sig do
params(block: T.proc.params(arg0: LunchMoney::Configuration).void).void
end
Expand Down
3 changes: 3 additions & 0 deletions lib/lunchmoney/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
require_relative "crypto/crypto_calls"

module LunchMoney
# The main API class that a user should interface through the method of any individual call is delegated through here
# so that it is never necessary to go through things like `LunchMoney::UserCalls.new.user` instead you can directly
# call the endpoint with LunchMoney::Api.new.user and it will be delegated to the correct call.
class Api
sig { returns(T.nilable(String)) }
attr_reader :api_key
Expand Down
2 changes: 2 additions & 0 deletions lib/lunchmoney/api_call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
require_relative "error"

module LunchMoney
# Base class for all API call types
class ApiCall
# Base URL used for API calls
BASE_URL = "https://dev.lunchmoney.app/v1/"

sig { returns(T.nilable(String)) }
Expand Down
3 changes: 3 additions & 0 deletions lib/lunchmoney/assets/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#assets-object
class Asset < LunchMoney::DataObject
# API object reference documentation: https://lunchmoney.dev/#assets-object

Expand All @@ -25,6 +26,7 @@ class Asset < LunchMoney::DataObject
sig { returns(T::Boolean) }
attr_accessor :exclude_transactions

# Valid asset type names
VALID_TYPE_NAMES = T.let(
[
"cash",
Expand All @@ -41,6 +43,7 @@ class Asset < LunchMoney::DataObject
T::Array[String],
)

# Valid asset subtype names
VALID_SUBTYPE_NAMES = T.let(
[
"retirement",
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/assets/asset_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "asset"

module LunchMoney
# https://lunchmoney.dev/#assets
class AssetCalls < ApiCall
sig { returns(T.any(T::Array[LunchMoney::Asset], LunchMoney::Errors)) }
def assets
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/budget/budget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require_relative "config"

module LunchMoney
# https://lunchmoney.dev/#budget-object
class Budget < LunchMoney::DataObject
# API object reference documentation: https://lunchmoney.dev/#budget-object

Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/budget/budget_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "budget"

module LunchMoney
# https://lunchmoney.dev/#budget
class BudgetCalls < ApiCall
sig do
params(
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/budget/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#config-object
class Config < LunchMoney::DataObject
# API object reference documentation: https://lunchmoney.dev/#config-object

Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/budget/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#data-object
class Data < LunchMoney::DataObject
# API object reference documentation: https://lunchmoney.dev/#data-object

Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/categories/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#categories-object
class Category < LunchMoney::DataObject
sig { returns(Integer) }
attr_accessor :id
Expand Down
2 changes: 2 additions & 0 deletions lib/lunchmoney/categories/category_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
require_relative "category"

module LunchMoney
# https://lunchmoney.dev/#categories
class CategoryCalls < ApiCall
# Valid query parameter formets for categories
VALID_FORMATS = T.let(
[
"flattened",
Expand Down
8 changes: 8 additions & 0 deletions lib/lunchmoney/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# frozen_string_literal: true

module LunchMoney
# Holds global configuration options for this gem
# @example api_key
# LunchMoney::Configuration.api_key
# => "your_api_key"
#
# @example validate_object_attributes
# LunchMoney::Configuration.validate_object_attributes
# => true
class Configuration
sig { returns(T.nilable(String)) }
attr_accessor :api_key
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/crypto/crypto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#crypto-object
class Crypto < LunchMoney::DataObject
sig { returns(T.nilable(Integer)) }
attr_accessor :id, :zabo_account_id
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/crypto/crypto_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "crypto"

module LunchMoney
# https://lunchmoney.dev/#crypto
class CryptoCalls < ApiCall
sig { returns(T.any(T::Array[LunchMoney::Crypto], LunchMoney::Errors)) }
def crypto
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/data_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# Base data object for the objects returned and used when calling the LunchMoney API
class DataObject
sig { params(symbolize_keys: T::Boolean).returns(T::Hash[String, T.untyped]) }
def serialize(symbolize_keys: false)
Expand Down
2 changes: 2 additions & 0 deletions lib/lunchmoney/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# This class is used to represent errors returned directly from the LunchMoney API
class Error
sig { returns(String) }
attr_reader :message
Expand All @@ -13,4 +14,5 @@ def initialize(message:)
end
end

# A type alias for an array of LunchMoney::Error
LunchMoney::Errors = T.type_alias { T::Array[LunchMoney::Error] }
4 changes: 4 additions & 0 deletions lib/lunchmoney/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
# frozen_string_literal: true

module LunchMoney
# Base exception class for exceptions raised by this gem
class Exception < StandardError; end

# Exception raised when an API Key appears to be invalid
class InvalidApiKey < Exception; end

# Exception raised when an object attribute is invalid
class InvalidObjectAttribute < Exception; end

# Exception raised when a query parameter is invalid
class InvalidQueryParameter < Exception; end
end
1 change: 1 addition & 0 deletions lib/lunchmoney/plaid_accounts/plaid_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#plaid-accounts-object
class PlaidAccount < LunchMoney::DataObject
sig { returns(Integer) }
attr_accessor :id
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/plaid_accounts/plaid_account_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "plaid_account"

module LunchMoney
# https://lunchmoney.dev/#plaid-accounts
class PlaidAccountCalls < ApiCall
sig { returns(T.any(T::Array[LunchMoney::PlaidAccount], LunchMoney::Errors)) }
def plaid_accounts
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/recurring_expenses/recurring_expense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#recurring-expenses-object
class RecurringExpense < LunchMoney::DataObject
sig { returns(Integer) }
attr_accessor :id, :amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "recurring_expense"

module LunchMoney
# https://lunchmoney.dev/#recurring-expenses
class RecurringExpenseCalls < ApiCall
sig do
params(
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/tags/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#tags-object
class Tag < LunchMoney::DataObject
sig { returns(Integer) }
attr_accessor :id
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/tags/tag_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "tag"

module LunchMoney
# https://lunchmoney.dev/#tags
class TagCalls < ApiCall
sig { returns(T.any(T::Array[LunchMoney::Tag], LunchMoney::Errors)) }
def all_tags
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/transactions/split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# Object used to split a transaction when updating https://lunchmoney.dev/#update-transaction
class Split < LunchMoney::DataObject
sig { returns(T.nilable(String)) }
attr_accessor :payee, :date, :notes
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/transactions/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#transaction-object
class Transaction < LunchMoney::DataObject
sig { returns(T.nilable(Integer)) }
attr_accessor :id, :to_base, :category_id, :recurring_id, :asset_id, :plaid_account_id, :parent_id, :group_id
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/transactions/transaction_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require_relative "split"

module LunchMoney
# https://lunchmoney.dev/#transactions
class TransactionCalls < ApiCall
sig do
params(
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/transactions/update_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# object used when updating a transaction https://lunchmoney.dev/#update-transaction
class UpdateTransaction < LunchMoney::DataObject
sig { returns(T.nilable(String)) }
attr_accessor :date, :payee, :amount, :currency, :notes, :status, :external_id
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/user/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

module LunchMoney
# https://lunchmoney.dev/#user-object
class User < LunchMoney::DataObject
sig { returns(Integer) }
attr_accessor :user_id, :account_id
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/user/user_calls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "user"

module LunchMoney
# https://lunchmoney.dev/#user
class UserCalls < ApiCall
sig { returns(T.any(LunchMoney::User, LunchMoney::Errors)) }
def user
Expand Down
1 change: 1 addition & 0 deletions lib/lunchmoney/validators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "time"

module LunchMoney
# module containing reusable methods for validating data objects
module Validators
include Kernel

Expand Down
Loading

0 comments on commit 82b7e6f

Please sign in to comment.