billomat 0.1.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.editorconfig +30 -0
- data/.github/workflows/documentation.yml +38 -0
- data/.github/workflows/test.yml +59 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +53 -0
- data/.simplecov +3 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +48 -0
- data/Dockerfile +29 -0
- data/Envfile +6 -0
- data/Gemfile +3 -1
- data/Makefile +135 -0
- data/README.md +42 -17
- data/Rakefile +74 -3
- data/billomat.gemspec +28 -22
- data/config/docker/.bash_profile +3 -0
- data/config/docker/.bashrc +48 -0
- data/config/docker/.inputrc +17 -0
- data/doc/assets/project.svg +68 -0
- data/docker-compose.yml +9 -0
- data/lib/billomat/actions/cancel.rb +3 -5
- data/lib/billomat/actions/complete.rb +8 -12
- data/lib/billomat/actions/email.rb +6 -10
- data/lib/billomat/actions/pdf.rb +4 -10
- data/lib/billomat/actions/uncancel.rb +3 -6
- data/lib/billomat/actions.rb +0 -1
- data/lib/billomat/configuration.rb +2 -1
- data/lib/billomat/gateway.rb +52 -24
- data/lib/billomat/models/base.rb +26 -27
- data/lib/billomat/models/client.rb +3 -4
- data/lib/billomat/models/contact.rb +18 -0
- data/lib/billomat/models/credit_note.rb +18 -0
- data/lib/billomat/models/credit_note_item.rb +18 -0
- data/lib/billomat/models/invoice.rb +6 -11
- data/lib/billomat/models/invoice_item.rb +3 -3
- data/lib/billomat/models/invoice_payment.rb +3 -4
- data/lib/billomat/models/tag.rb +18 -0
- data/lib/billomat/models/template.rb +18 -0
- data/lib/billomat/models.rb +6 -2
- data/lib/billomat/search.rb +12 -14
- data/lib/billomat/version.rb +1 -1
- data/lib/billomat.rb +15 -18
- metadata +117 -20
- data/.travis.yml +0 -18
- data/doc/assets/logo.png +0 -0
- data/doc/assets/project.png +0 -0
- data/doc/assets/project.xcf +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d00f8873b7ea8c178761b0ebca4200541d9eaa25ac2cb67500f0b22caf29482
|
4
|
+
data.tar.gz: e7e0f542aa48d665ef1957676b785dc801e27b0f9e754b7ea31318e869142a92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fff72d6a694ed3b199999291aac06da32f5517de090426b8190467a1a404076095deeae152a007dd96ff4c7722433ab6916523905fd68f5fccfee00456d634cb
|
7
|
+
data.tar.gz: 1e5d35d889fbba13ee6fbca7193a21ea4bf8d10e6baab532b9ad989bcc55c70990801d7558969d79531ad3c8d58f1b10f0b61bf947957a39e58782d096d347c0
|
data/.editorconfig
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# http://editorconfig.org
|
2
|
+
root = true
|
3
|
+
|
4
|
+
[*]
|
5
|
+
indent_style = space
|
6
|
+
indent_size = 2
|
7
|
+
end_of_line = lf
|
8
|
+
charset = utf-8
|
9
|
+
trim_trailing_whitespace = true
|
10
|
+
insert_final_newline = true
|
11
|
+
|
12
|
+
[*.md]
|
13
|
+
trim_trailing_whitespace = true
|
14
|
+
|
15
|
+
[*.json]
|
16
|
+
indent_style = space
|
17
|
+
indent_size = 2
|
18
|
+
|
19
|
+
[*.yml]
|
20
|
+
indent_style = space
|
21
|
+
indent_size = 2
|
22
|
+
|
23
|
+
[Makefile]
|
24
|
+
trim_trailing_whitespace = true
|
25
|
+
indent_style = tab
|
26
|
+
indent_size = 4
|
27
|
+
|
28
|
+
[*.sh]
|
29
|
+
indent_style = space
|
30
|
+
indent_size = 2
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: Build Documentation
|
2
|
+
on:
|
3
|
+
repository_dispatch:
|
4
|
+
types: [documentation]
|
5
|
+
|
6
|
+
concurrency:
|
7
|
+
group: 'docs'
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
docs:
|
11
|
+
name: Build gem documentation
|
12
|
+
runs-on: ubuntu-20.04
|
13
|
+
timeout-minutes: 5
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
|
17
|
+
- name: Install the correct Ruby version
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.5
|
21
|
+
bundler-cache: true
|
22
|
+
|
23
|
+
- name: Prepare the virtual environment
|
24
|
+
uses: hausgold/actions/ci@master
|
25
|
+
with:
|
26
|
+
clone_token: '${{ secrets.CLONE_TOKEN }}'
|
27
|
+
settings: '${{ github.repository }}'
|
28
|
+
target: ci/gem-test
|
29
|
+
|
30
|
+
- name: Build gem documentation
|
31
|
+
run: make docs
|
32
|
+
|
33
|
+
- name: Upload the code coverage report
|
34
|
+
run: coverage
|
35
|
+
|
36
|
+
- name: Add this job to the commit status
|
37
|
+
run: commit-status '${{ job.status }}'
|
38
|
+
if: always()
|
@@ -0,0 +1,59 @@
|
|
1
|
+
name: Test
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- '**'
|
6
|
+
schedule:
|
7
|
+
- cron: '0 0 * * MON'
|
8
|
+
|
9
|
+
concurrency:
|
10
|
+
group: '${{ github.ref }}'
|
11
|
+
cancel-in-progress: true
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
name: 'Test the gem (Ruby ${{ matrix.ruby }})'
|
16
|
+
runs-on: ubuntu-20.04
|
17
|
+
timeout-minutes: 5
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby: [2.3, 2.4, 2.5, 2.6]
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
|
25
|
+
- name: Install the correct Ruby version
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby }}
|
29
|
+
bundler-cache: true
|
30
|
+
|
31
|
+
- name: Prepare the virtual environment
|
32
|
+
uses: hausgold/actions/ci@master
|
33
|
+
with:
|
34
|
+
clone_token: '${{ secrets.CLONE_TOKEN }}'
|
35
|
+
settings: '${{ github.repository }}'
|
36
|
+
target: ci/gem-test
|
37
|
+
|
38
|
+
- name: Run the gem tests
|
39
|
+
run: make test
|
40
|
+
|
41
|
+
- name: Upload the code coverage report
|
42
|
+
run: coverage
|
43
|
+
|
44
|
+
trigger-docs:
|
45
|
+
name: Trigger the documentation upload
|
46
|
+
runs-on: ubuntu-20.04
|
47
|
+
timeout-minutes: 2
|
48
|
+
needs: test
|
49
|
+
if: github.ref == 'refs/heads/master'
|
50
|
+
steps:
|
51
|
+
- name: Prepare the virtual environment
|
52
|
+
uses: hausgold/actions/ci@master
|
53
|
+
with:
|
54
|
+
clone_token: '${{ secrets.CLONE_TOKEN }}'
|
55
|
+
settings: '${{ github.repository }}'
|
56
|
+
target: ci/noop
|
57
|
+
|
58
|
+
- name: Trigger the documentation upload
|
59
|
+
run: workflow documentation
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
Rails:
|
4
|
+
Enabled: true
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
Enabled: true
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
DisplayCopNames: true
|
11
|
+
TargetRubyVersion: 2.5
|
12
|
+
Exclude:
|
13
|
+
- bin/**/*
|
14
|
+
- vendor/**/*
|
15
|
+
- build/**/*
|
16
|
+
- gemfiles/**/*
|
17
|
+
|
18
|
+
Metrics/BlockLength:
|
19
|
+
Exclude:
|
20
|
+
- Rakefile
|
21
|
+
- '*.gemspec'
|
22
|
+
- spec/**/*.rb
|
23
|
+
- '**/*.rake'
|
24
|
+
- doc/**/*.rb
|
25
|
+
|
26
|
+
# Document all the things.
|
27
|
+
Style/DocumentationMethod:
|
28
|
+
Enabled: true
|
29
|
+
RequireForNonPublicMethods: true
|
30
|
+
|
31
|
+
# It's a deliberate idiom in RSpec.
|
32
|
+
# See: https://github.com/bbatsov/rubocop/issues/4222
|
33
|
+
Lint/AmbiguousBlockAssociation:
|
34
|
+
Exclude:
|
35
|
+
- "spec/**/*"
|
36
|
+
|
37
|
+
# Because +expect_any_instance_of().to have_received()+ is not
|
38
|
+
# supported with the +with(hash_including)+ matchers
|
39
|
+
RSpec/MessageSpies:
|
40
|
+
EnforcedStyle: receive
|
41
|
+
|
42
|
+
# Because nesting makes sense here to group the feature tests
|
43
|
+
# more effective. This increases maintainability.
|
44
|
+
RSpec/NestedGroups:
|
45
|
+
Max: 4
|
46
|
+
|
47
|
+
# Disable regular Rails spec paths.
|
48
|
+
RSpec/FilePath:
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
# Because we just implemented the ActiveRecord API.
|
52
|
+
Rails/SkipsModelValidations:
|
53
|
+
Enabled: false
|
data/.simplecov
ADDED
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
### 0.3.0
|
2
|
+
|
3
|
+
* Improve error handling (breaking change, as we are now raising
|
4
|
+
`Billomat::GatewayError`s rather than just the client's
|
5
|
+
`RestClient::Exception`) (#15)
|
6
|
+
* Added bang variants to API methods
|
7
|
+
(`Billomat::Models::Base#{save!,create!,update!,delete!}`) (#16)
|
8
|
+
* Added `CreditNote` and `CreditNoteItem` models (#14)
|
9
|
+
* Moved to GitHub Actions
|
10
|
+
* Migrated to our own coverage reporting
|
11
|
+
|
12
|
+
### 0.2.0
|
13
|
+
|
14
|
+
* Add codeclimate test runner
|
15
|
+
* Update codeclimate reporter id
|
16
|
+
* Switched to SVG project teasers
|
17
|
+
* Updated Travis CI and Code Climate configs (#11)
|
18
|
+
* Changed travis-ci.org to travis-ci.com links
|
19
|
+
* Adds templates and tags to models (#13)
|
20
|
+
|
21
|
+
### 0.1.6
|
22
|
+
|
23
|
+
* Support registered apps
|
24
|
+
* Added `app_id` and `app_secret` to configuration (#9)
|
25
|
+
|
26
|
+
### 0.1.5
|
27
|
+
|
28
|
+
* Added contact support
|
29
|
+
|
30
|
+
### 0.1.4
|
31
|
+
|
32
|
+
* Made timeout configurable
|
33
|
+
|
34
|
+
### 0.1.3
|
35
|
+
|
36
|
+
* Added `#as_json` to base model
|
37
|
+
|
38
|
+
### 0.1.2
|
39
|
+
|
40
|
+
* Small fixes and code coverage
|
41
|
+
|
42
|
+
### 0.1.1
|
43
|
+
|
44
|
+
* Improved documentation and README
|
45
|
+
|
46
|
+
### 0.1.0
|
47
|
+
|
48
|
+
* Initial release
|
data/Dockerfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
FROM hausgold/ruby:2.5
|
2
|
+
MAINTAINER Hermann Mayer <hermann.mayer@hausgold.de>
|
3
|
+
|
4
|
+
# Update system gem
|
5
|
+
RUN gem update --system
|
6
|
+
|
7
|
+
# Install system packages and the latest bundler
|
8
|
+
RUN apt-get update -yqqq && \
|
9
|
+
apt-get install -y \
|
10
|
+
build-essential locales sudo vim \
|
11
|
+
ca-certificates \
|
12
|
+
bash-completion inotify-tools && \
|
13
|
+
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && /usr/sbin/locale-gen && \
|
14
|
+
gem install bundler -v '~> 2.0' --no-document --no-prerelease && \
|
15
|
+
gem install bundler -v '~> 1.0' --no-document --no-prerelease
|
16
|
+
|
17
|
+
# Add new web user
|
18
|
+
RUN mkdir /app && \
|
19
|
+
adduser web --home /home/web --shell /bin/bash \
|
20
|
+
--disabled-password --gecos ""
|
21
|
+
COPY config/docker/* /home/web/
|
22
|
+
RUN chown web:web -R /app /home/web /usr/local/bundle && \
|
23
|
+
mkdir -p /home/web/.ssh
|
24
|
+
|
25
|
+
# Set the root password and grant root access to web
|
26
|
+
RUN echo 'root:root' | chpasswd
|
27
|
+
RUN echo 'web ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
28
|
+
|
29
|
+
WORKDIR /app
|
data/Envfile
ADDED
data/Gemfile
CHANGED
data/Makefile
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
MAKEFLAGS += --warn-undefined-variables -j1
|
2
|
+
SHELL := bash
|
3
|
+
.SHELLFLAGS := -eu -o pipefail -c
|
4
|
+
.DEFAULT_GOAL := all
|
5
|
+
.DELETE_ON_ERROR:
|
6
|
+
.SUFFIXES:
|
7
|
+
.PHONY:
|
8
|
+
|
9
|
+
# Environment switches
|
10
|
+
MAKE_ENV ?= docker
|
11
|
+
COMPOSE_RUN_SHELL_FLAGS ?= --rm
|
12
|
+
|
13
|
+
# Directories
|
14
|
+
VENDOR_DIR ?= vendor/bundle
|
15
|
+
|
16
|
+
# Host binaries
|
17
|
+
AWK ?= awk
|
18
|
+
BASH ?= bash
|
19
|
+
COMPOSE ?= docker-compose
|
20
|
+
DOCKER ?= docker
|
21
|
+
GREP ?= grep
|
22
|
+
ID ?= id
|
23
|
+
MKDIR ?= mkdir
|
24
|
+
RM ?= rm
|
25
|
+
XARGS ?= xargs
|
26
|
+
|
27
|
+
# Container binaries
|
28
|
+
BUNDLE ?= bundle
|
29
|
+
GEM ?= gem
|
30
|
+
RAKE ?= rake
|
31
|
+
RUBOCOP ?= rubocop
|
32
|
+
YARD ?= yard
|
33
|
+
|
34
|
+
# Define a generic shell run wrapper
|
35
|
+
# $1 - The command to run
|
36
|
+
ifeq ($(MAKE_ENV),docker)
|
37
|
+
define run-shell
|
38
|
+
$(COMPOSE) run $(COMPOSE_RUN_SHELL_FLAGS) \
|
39
|
+
-e LANG=en_US.UTF-8 -e LANGUAGE=en_US.UTF-8 -e LC_ALL=en_US.UTF-8 \
|
40
|
+
-e HOME=/home/web -e BUNDLE_APP_CONFIG=/app/.bundle \
|
41
|
+
-u `$(ID) -u` test bash -c 'sleep 0.1; echo; $(1)'
|
42
|
+
endef
|
43
|
+
else ifeq ($(MAKE_ENV),baremetal)
|
44
|
+
define run-shell
|
45
|
+
$(1)
|
46
|
+
endef
|
47
|
+
endif
|
48
|
+
|
49
|
+
all:
|
50
|
+
# Billomat
|
51
|
+
#
|
52
|
+
# install Install the dependencies
|
53
|
+
# update Update the local Gemset dependencies
|
54
|
+
# clean Clean the dependencies
|
55
|
+
#
|
56
|
+
# test Run the whole test suite
|
57
|
+
# test-style Test the code styles
|
58
|
+
#
|
59
|
+
# docs Generate the Ruby documentation of the library
|
60
|
+
# stats Print the code statistics (library and test suite)
|
61
|
+
# notes Print all the notes from the code
|
62
|
+
# release Release a new Gem version (maintainers only)
|
63
|
+
#
|
64
|
+
# shell Run an interactive shell on the container
|
65
|
+
# shell-irb Run an interactive IRB shell on the container
|
66
|
+
|
67
|
+
install:
|
68
|
+
# Install the dependencies
|
69
|
+
@$(MKDIR) -p $(VENDOR_DIR)
|
70
|
+
@$(call run-shell,$(BUNDLE) check || $(BUNDLE) install --path $(VENDOR_DIR))
|
71
|
+
@$(call run-shell,GEM_HOME=vendor/bundle/ruby/$${RUBY_MAJOR}.0 \
|
72
|
+
$(GEM) install bundler -v "~> 1.0")
|
73
|
+
|
74
|
+
test: \
|
75
|
+
test-specs \
|
76
|
+
test-style
|
77
|
+
|
78
|
+
test-specs:
|
79
|
+
# Run the whole test suite
|
80
|
+
@$(call run-shell,$(BUNDLE) exec $(RAKE) stats spec)
|
81
|
+
|
82
|
+
test-style: \
|
83
|
+
test-style-ruby
|
84
|
+
|
85
|
+
test-style-ruby:
|
86
|
+
# Run the static code analyzer (rubocop)
|
87
|
+
@$(call run-shell,$(BUNDLE) exec $(RUBOCOP) -a)
|
88
|
+
|
89
|
+
clean:
|
90
|
+
# Clean the dependencies
|
91
|
+
@$(RM) -rf $(VENDOR_DIR)
|
92
|
+
@$(RM) -rf $(VENDOR_DIR)/Gemfile.lock
|
93
|
+
@$(RM) -rf pkg
|
94
|
+
@$(RM) -rf coverage
|
95
|
+
|
96
|
+
clean-containers:
|
97
|
+
# Clean running containers
|
98
|
+
ifeq ($(MAKE_ENV),docker)
|
99
|
+
@$(COMPOSE) down
|
100
|
+
endif
|
101
|
+
|
102
|
+
clean-images:
|
103
|
+
# Clean build images
|
104
|
+
ifeq ($(MAKE_ENV),docker)
|
105
|
+
@-$(DOCKER) images | $(GREP) rimless \
|
106
|
+
| $(AWK) '{ print $$3 }' \
|
107
|
+
| $(XARGS) -rn1 $(DOCKER) rmi -f
|
108
|
+
endif
|
109
|
+
|
110
|
+
distclean: clean clean-containers clean-images
|
111
|
+
|
112
|
+
shell:
|
113
|
+
# Run an interactive shell on the container
|
114
|
+
@$(call run-shell,$(BASH) -i)
|
115
|
+
|
116
|
+
shell-irb:
|
117
|
+
# Run an interactive IRB shell on the container
|
118
|
+
@$(call run-shell,bin/console)
|
119
|
+
|
120
|
+
docs:
|
121
|
+
# Build the API documentation
|
122
|
+
@$(call run-shell,$(BUNDLE) exec $(YARD) -q && \
|
123
|
+
$(BUNDLE) exec $(YARD) stats --list-undoc --compact)
|
124
|
+
|
125
|
+
notes:
|
126
|
+
# Print the code statistics (library and test suite)
|
127
|
+
@$(call run-shell,$(BUNDLE) exec $(RAKE) notes)
|
128
|
+
|
129
|
+
stats:
|
130
|
+
# Print all the notes from the code
|
131
|
+
@$(call run-shell,$(BUNDLE) exec $(RAKE) stats)
|
132
|
+
|
133
|
+
release:
|
134
|
+
# Release a new gem version
|
135
|
+
@$(BUNDLE) exec $(RAKE) release
|
data/README.md
CHANGED
@@ -1,11 +1,20 @@
|
|
1
|
-

|
2
2
|
|
3
|
-
[](https://github.com/hausgold/billomat/actions/workflows/test.yml)
|
4
4
|
[](https://badge.fury.io/rb/billomat)
|
5
|
-
[](https://knowledge.hausgold.de/coverage)
|
6
|
+
[](https://knowledge.hausgold.de/coverage)
|
7
|
+
[](https://www.rubydoc.info/gems/billomat)
|
7
8
|
|
8
|
-
This gem provides a Ruby API for [billomat.com](https://billomat.com) - an
|
9
|
+
This gem provides a Ruby API for [billomat.com](https://billomat.com) - an
|
10
|
+
online accounting service.
|
11
|
+
|
12
|
+
- [Installation](#installation)
|
13
|
+
- [Usage](#usage)
|
14
|
+
- [Configuration](#configuration)
|
15
|
+
- [Basic usage](#basic-usage)
|
16
|
+
- [Development](#development)
|
17
|
+
- [Contributing](#contributing)
|
9
18
|
|
10
19
|
## Installation
|
11
20
|
|
@@ -37,15 +46,29 @@ or inside an initializer.
|
|
37
46
|
|
38
47
|
```ruby
|
39
48
|
Billomat.configure do |config|
|
40
|
-
|
41
|
-
config.
|
42
|
-
|
49
|
+
# Subdomain, e.g. example.billomat.net
|
50
|
+
config.subdomain = 'example'
|
51
|
+
# API key
|
52
|
+
config.api_key = '4aefdc...'
|
53
|
+
# timeout in seconds
|
54
|
+
config.timeout = 5
|
55
|
+
|
56
|
+
# You can also configure a registerd app to increase your
|
57
|
+
# API call limit as described here:
|
58
|
+
# https://www.billomat.com/en/api/basics/rate-limiting/
|
59
|
+
config.app_id = '12345'
|
60
|
+
config.app_secret = 'c3df...'
|
43
61
|
end
|
44
62
|
```
|
45
63
|
|
46
64
|
### Basic usage
|
47
65
|
|
48
|
-
Currently there is basic support for the models
|
66
|
+
Currently there is basic support for the models:
|
67
|
+
* `Invoice`
|
68
|
+
* `Client`
|
69
|
+
* `InvoicePayment`
|
70
|
+
* `InvoiceItem`
|
71
|
+
* `Contact`
|
49
72
|
|
50
73
|
```ruby
|
51
74
|
Billomat::Models::Invoice.where(invoice_number: 'RE1234')
|
@@ -62,17 +85,19 @@ client.delete
|
|
62
85
|
=> true
|
63
86
|
```
|
64
87
|
|
65
|
-
### Documentation
|
66
|
-
|
67
|
-
The RubyDoc is available [here](http://www.rubydoc.info/gems/billomat).
|
68
|
-
|
69
|
-
|
70
88
|
## Development
|
71
89
|
|
72
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
90
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
91
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
92
|
+
prompt that will allow you to experiment.
|
73
93
|
|
74
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
94
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
95
|
+
release a new version, update the version number in `version.rb`, and then run
|
96
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
97
|
+
git commits and tags, and push the `.gem` file to
|
98
|
+
[rubygems.org](https://rubygems.org).
|
75
99
|
|
76
100
|
## Contributing
|
77
101
|
|
78
|
-
Bug reports and pull requests are welcome on GitHub at
|
102
|
+
Bug reports and pull requests are welcome on GitHub at
|
103
|
+
https://github.com/hausgold/billomat.
|
data/Rakefile
CHANGED
@@ -1,6 +1,77 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rails/code_statistics'
|
6
|
+
require 'pp'
|
3
7
|
|
4
8
|
RSpec::Core::RakeTask.new(:spec)
|
5
9
|
|
6
|
-
task :
|
10
|
+
task default: :spec
|
11
|
+
|
12
|
+
# Load some railties tasks
|
13
|
+
load 'rails/tasks/statistics.rake'
|
14
|
+
load 'rails/tasks/annotations.rake'
|
15
|
+
|
16
|
+
# Clear the default statistics directory constant
|
17
|
+
#
|
18
|
+
# rubocop:disable Style/MutableConstant because we define it
|
19
|
+
Object.send(:remove_const, :STATS_DIRECTORIES)
|
20
|
+
::STATS_DIRECTORIES = []
|
21
|
+
# rubocop:enable Style/MutableConstant
|
22
|
+
|
23
|
+
# Monkey patch the Rails +CodeStatistics+ class to support configurable
|
24
|
+
# patterns per path. This is reuqired to support top-level only file matches.
|
25
|
+
class CodeStatistics
|
26
|
+
DEFAULT_PATTERN = /^(?!\.).*?\.(rb|js|coffee|rake)$/.freeze
|
27
|
+
|
28
|
+
# Pass the possible +pattern+ argument down to the
|
29
|
+
# +calculate_directory_statistics+ method call.
|
30
|
+
def calculate_statistics
|
31
|
+
Hash[@pairs.map do |pair|
|
32
|
+
[pair.first, calculate_directory_statistics(*pair[1..-1])]
|
33
|
+
end]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Match the pattern against the individual file name and the relative file
|
37
|
+
# path. This allows top-level only matches.
|
38
|
+
def calculate_directory_statistics(directory, pattern = DEFAULT_PATTERN)
|
39
|
+
stats = CodeStatisticsCalculator.new
|
40
|
+
|
41
|
+
Dir.foreach(directory) do |file_name|
|
42
|
+
path = "#{directory}/#{file_name}"
|
43
|
+
|
44
|
+
if File.directory?(path) && (/^\./ !~ file_name)
|
45
|
+
stats.add(calculate_directory_statistics(path, pattern))
|
46
|
+
elsif file_name =~ pattern || path =~ pattern
|
47
|
+
stats.add_by_file_path(path)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
stats
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Configure all code statistics directories
|
56
|
+
vendors = [
|
57
|
+
[:unshift, 'Top-levels', 'lib', %r{lib(/billomat)?/[^/]+\.rb$}],
|
58
|
+
[:unshift, 'Top-levels specs', 'spec', %r{spec/[^/]+_spec\.rb$}],
|
59
|
+
|
60
|
+
[:unshift, 'Actions', 'lib/billomat/actions'],
|
61
|
+
|
62
|
+
[:unshift, 'Models matchers', 'lib/billomat/models'],
|
63
|
+
[:unshift, 'Models matchers specs', 'spec/models']
|
64
|
+
].reverse
|
65
|
+
|
66
|
+
vendors.each do |method, type, dir, pattern|
|
67
|
+
::STATS_DIRECTORIES.send(method, [type, dir, pattern].compact)
|
68
|
+
::CodeStatistics::TEST_TYPES << type if type.include? 'specs'
|
69
|
+
end
|
70
|
+
|
71
|
+
# Setup annotations
|
72
|
+
ENV['SOURCE_ANNOTATION_DIRECTORIES'] = 'spec,doc'
|
73
|
+
|
74
|
+
desc 'Enumerate all annotations'
|
75
|
+
task :notes do
|
76
|
+
SourceAnnotationExtractor.enumerate '@?OPTIMIZE|@?FIXME|@?TODO', tag: true
|
77
|
+
end
|