attio-rails 0.1.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 +7 -0
- data/.github/dependabot.yml +42 -0
- data/.github/workflows/ci.yml +74 -0
- data/.github/workflows/docs.yml +51 -0
- data/.github/workflows/release.yml +70 -0
- data/.gitignore +60 -0
- data/.rspec +4 -0
- data/.rubocop.yml +65 -0
- data/.yardopts +14 -0
- data/CHANGELOG.md +32 -0
- data/CODE_OF_CONDUCT.md +37 -0
- data/CONTRIBUTING.md +241 -0
- data/Gemfile +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +243 -0
- data/Rakefile +29 -0
- data/SECURITY.md +63 -0
- data/attio-rails.gemspec +42 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/index.html +91 -0
- data/lib/attio/rails/concerns/syncable.rb +132 -0
- data/lib/attio/rails/configuration.rb +55 -0
- data/lib/attio/rails/railtie.rb +15 -0
- data/lib/attio/rails/version.rb +5 -0
- data/lib/attio/rails.rb +13 -0
- data/lib/generators/attio/install/install_generator.rb +65 -0
- data/lib/generators/attio/install/templates/README.md +39 -0
- data/lib/generators/attio/install/templates/attio.rb +7 -0
- data/lib/generators/attio/install/templates/attio_sync_job.rb +63 -0
- data/lib/generators/attio/install/templates/migration.rb +11 -0
- data/test_basic.rb +39 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 326cdb48011eef91cec7539a0392807c05ac2b1d4934dfb307760e76d8dfea57
|
4
|
+
data.tar.gz: 0b6b51c04055d87a0f5415e16d51c4aba68d570d73ba3b4ccca61ea52a35a31c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 44a37aba1c6f0372d3acf61bdf3aaf46a9a3424949baaf7edad6ab71a4b21949afcf38598644530eedace80b443f3bcc5d78706d6465dcc57a4a707db1c23529
|
7
|
+
data.tar.gz: 0ddda37466544f419d441f33f85048307c37c94701c6890fb5c19470a869952b5f68f7d9a0267f367d88791bd900d1ac1471b1f157a376aac666618528f7e135
|
@@ -0,0 +1,42 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: "bundler"
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: "weekly"
|
7
|
+
day: "monday"
|
8
|
+
time: "09:00"
|
9
|
+
open-pull-requests-limit: 10
|
10
|
+
reviewers:
|
11
|
+
- "ernestsim"
|
12
|
+
assignees:
|
13
|
+
- "ernestsim"
|
14
|
+
commit-message:
|
15
|
+
prefix: "chore"
|
16
|
+
include: "scope"
|
17
|
+
labels:
|
18
|
+
- "dependencies"
|
19
|
+
- "ruby"
|
20
|
+
ignore:
|
21
|
+
- dependency-name: "rails"
|
22
|
+
update-types: ["version-update:semver-major"]
|
23
|
+
- dependency-name: "ruby"
|
24
|
+
update-types: ["version-update:semver-major"]
|
25
|
+
|
26
|
+
- package-ecosystem: "github-actions"
|
27
|
+
directory: "/"
|
28
|
+
schedule:
|
29
|
+
interval: "weekly"
|
30
|
+
day: "monday"
|
31
|
+
time: "09:00"
|
32
|
+
open-pull-requests-limit: 5
|
33
|
+
reviewers:
|
34
|
+
- "ernestsim"
|
35
|
+
assignees:
|
36
|
+
- "ernestsim"
|
37
|
+
commit-message:
|
38
|
+
prefix: "ci"
|
39
|
+
include: "scope"
|
40
|
+
labels:
|
41
|
+
- "dependencies"
|
42
|
+
- "github-actions"
|
@@ -0,0 +1,74 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby-version: ['3.0', '3.1', '3.2', '3.3']
|
16
|
+
rails-version: ['6.1', '7.0', '7.1']
|
17
|
+
exclude:
|
18
|
+
- ruby-version: '3.0'
|
19
|
+
rails-version: '7.1'
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v4
|
23
|
+
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby-version }}
|
28
|
+
bundler-cache: true
|
29
|
+
|
30
|
+
- name: Install Rails ${{ matrix.rails-version }}
|
31
|
+
run: |
|
32
|
+
gem install rails -v "~> ${{ matrix.rails-version }}.0"
|
33
|
+
bundle update rails
|
34
|
+
|
35
|
+
- name: Run tests
|
36
|
+
run: bundle exec rspec
|
37
|
+
|
38
|
+
- name: Upload coverage reports
|
39
|
+
if: matrix.ruby-version == '3.2' && matrix.rails-version == '7.1'
|
40
|
+
uses: codecov/codecov-action@v3
|
41
|
+
with:
|
42
|
+
file: ./coverage/coverage.xml
|
43
|
+
flags: unittests
|
44
|
+
name: codecov-umbrella
|
45
|
+
|
46
|
+
lint:
|
47
|
+
runs-on: ubuntu-latest
|
48
|
+
steps:
|
49
|
+
- uses: actions/checkout@v4
|
50
|
+
|
51
|
+
- name: Set up Ruby
|
52
|
+
uses: ruby/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: '3.2'
|
55
|
+
bundler-cache: true
|
56
|
+
|
57
|
+
- name: Run RuboCop
|
58
|
+
run: bundle exec rubocop --format github
|
59
|
+
|
60
|
+
security:
|
61
|
+
runs-on: ubuntu-latest
|
62
|
+
steps:
|
63
|
+
- uses: actions/checkout@v4
|
64
|
+
|
65
|
+
- name: Set up Ruby
|
66
|
+
uses: ruby/setup-ruby@v1
|
67
|
+
with:
|
68
|
+
ruby-version: '3.2'
|
69
|
+
bundler-cache: true
|
70
|
+
|
71
|
+
- name: Run security audit
|
72
|
+
run: |
|
73
|
+
gem install bundler-audit
|
74
|
+
bundle audit check --update
|
@@ -0,0 +1,51 @@
|
|
1
|
+
name: Documentation
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
workflow_dispatch:
|
7
|
+
|
8
|
+
permissions:
|
9
|
+
contents: read
|
10
|
+
pages: write
|
11
|
+
id-token: write
|
12
|
+
|
13
|
+
concurrency:
|
14
|
+
group: "pages"
|
15
|
+
cancel-in-progress: false
|
16
|
+
|
17
|
+
jobs:
|
18
|
+
build:
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
steps:
|
21
|
+
- name: Checkout
|
22
|
+
uses: actions/checkout@v4
|
23
|
+
|
24
|
+
- name: Set up Ruby
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: '3.2'
|
28
|
+
bundler-cache: true
|
29
|
+
|
30
|
+
- name: Setup Pages
|
31
|
+
uses: actions/configure-pages@v4
|
32
|
+
|
33
|
+
- name: Generate documentation
|
34
|
+
run: |
|
35
|
+
bundle exec rake yard:gh_pages
|
36
|
+
|
37
|
+
- name: Upload artifact
|
38
|
+
uses: actions/upload-pages-artifact@v3
|
39
|
+
with:
|
40
|
+
path: docs
|
41
|
+
|
42
|
+
deploy:
|
43
|
+
environment:
|
44
|
+
name: github-pages
|
45
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
46
|
+
runs-on: ubuntu-latest
|
47
|
+
needs: build
|
48
|
+
steps:
|
49
|
+
- name: Deploy to GitHub Pages
|
50
|
+
id: deployment
|
51
|
+
uses: actions/deploy-pages@v4
|
@@ -0,0 +1,70 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- 'v*.*.*'
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
release:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
permissions:
|
13
|
+
contents: write
|
14
|
+
packages: write
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- name: Checkout code
|
18
|
+
uses: actions/checkout@v4
|
19
|
+
with:
|
20
|
+
fetch-depth: 0
|
21
|
+
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: '3.2'
|
26
|
+
bundler-cache: true
|
27
|
+
|
28
|
+
- name: Configure gem credentials
|
29
|
+
run: |
|
30
|
+
mkdir -p ~/.gem
|
31
|
+
cat > ~/.gem/credentials << EOF
|
32
|
+
---
|
33
|
+
:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
|
34
|
+
EOF
|
35
|
+
chmod 0600 ~/.gem/credentials
|
36
|
+
|
37
|
+
- name: Run tests
|
38
|
+
run: |
|
39
|
+
bundle exec rspec
|
40
|
+
bundle exec rubocop
|
41
|
+
|
42
|
+
- name: Generate documentation
|
43
|
+
run: bundle exec rake yard
|
44
|
+
|
45
|
+
- name: Build gem
|
46
|
+
run: bundle exec rake build
|
47
|
+
|
48
|
+
- name: Publish to RubyGems
|
49
|
+
run: bundle exec rake release
|
50
|
+
|
51
|
+
- name: Create GitHub Release
|
52
|
+
uses: softprops/action-gh-release@v1
|
53
|
+
with:
|
54
|
+
files: pkg/*.gem
|
55
|
+
generate_release_notes: true
|
56
|
+
draft: false
|
57
|
+
prerelease: ${{ contains(github.ref_name, 'pre') || contains(github.ref_name, 'rc') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') }}
|
58
|
+
env:
|
59
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
60
|
+
|
61
|
+
- name: Update GitHub Pages with documentation
|
62
|
+
run: |
|
63
|
+
git config --local user.email "action@github.com"
|
64
|
+
git config --local user.name "GitHub Action"
|
65
|
+
git checkout --orphan gh-pages
|
66
|
+
git rm -rf .
|
67
|
+
cp -r docs/* .
|
68
|
+
git add -A
|
69
|
+
git commit -m "Update documentation for ${{ github.ref_name }}"
|
70
|
+
git push origin gh-pages --force
|
data/.gitignore
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Documentation
|
14
|
+
/doc/
|
15
|
+
/docs/yard/
|
16
|
+
/.yardoc/
|
17
|
+
/_yardoc/
|
18
|
+
/rdoc/
|
19
|
+
|
20
|
+
# Bundler
|
21
|
+
/.bundle/
|
22
|
+
/vendor/bundle
|
23
|
+
/lib/bundler/man/
|
24
|
+
Gemfile.lock
|
25
|
+
.ruby-version
|
26
|
+
.ruby-gemset
|
27
|
+
.rvmrc
|
28
|
+
|
29
|
+
# IDE
|
30
|
+
/.idea/
|
31
|
+
/.vscode/
|
32
|
+
*.swp
|
33
|
+
*.swo
|
34
|
+
*~
|
35
|
+
.DS_Store
|
36
|
+
|
37
|
+
# Test artifacts
|
38
|
+
/spec/dummy/log/*.log
|
39
|
+
/spec/dummy/tmp/
|
40
|
+
/spec/dummy/db/*.sqlite3
|
41
|
+
/spec/dummy/db/*.sqlite3-journal
|
42
|
+
/spec/dummy/public/system
|
43
|
+
/spec/dummy/coverage/
|
44
|
+
/spec/dummy/node_modules/
|
45
|
+
/spec/dummy/yarn-error.log
|
46
|
+
/spec/dummy/storage/
|
47
|
+
/spec/dummy/public/packs
|
48
|
+
/spec/dummy/public/packs-test
|
49
|
+
|
50
|
+
# Environment
|
51
|
+
.env
|
52
|
+
.env.local
|
53
|
+
.env.*.local
|
54
|
+
|
55
|
+
# Logs
|
56
|
+
*.log
|
57
|
+
|
58
|
+
# Cache
|
59
|
+
.sass-cache/
|
60
|
+
.cache/
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
- rubocop-rails
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.0
|
7
|
+
NewCops: enable
|
8
|
+
Exclude:
|
9
|
+
- 'bin/**/*'
|
10
|
+
- 'db/**/*'
|
11
|
+
- 'vendor/**/*'
|
12
|
+
- 'spec/dummy/**/*'
|
13
|
+
- 'node_modules/**/*'
|
14
|
+
- 'tmp/**/*'
|
15
|
+
- '.git/**/*'
|
16
|
+
|
17
|
+
# Style
|
18
|
+
Style/Documentation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/StringLiterals:
|
22
|
+
EnforcedStyle: double_quotes
|
23
|
+
|
24
|
+
Style/FrozenStringLiteralComment:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
# Layout
|
28
|
+
Layout/LineLength:
|
29
|
+
Max: 120
|
30
|
+
Exclude:
|
31
|
+
- 'spec/**/*'
|
32
|
+
|
33
|
+
# Metrics
|
34
|
+
Metrics/BlockLength:
|
35
|
+
Exclude:
|
36
|
+
- 'spec/**/*'
|
37
|
+
- '*.gemspec'
|
38
|
+
- 'lib/generators/**/*'
|
39
|
+
|
40
|
+
Metrics/MethodLength:
|
41
|
+
Max: 20
|
42
|
+
|
43
|
+
Metrics/ClassLength:
|
44
|
+
Max: 150
|
45
|
+
|
46
|
+
Metrics/AbcSize:
|
47
|
+
Max: 20
|
48
|
+
|
49
|
+
# Rails specific
|
50
|
+
Rails/ApplicationRecord:
|
51
|
+
Exclude:
|
52
|
+
- 'spec/dummy/**/*'
|
53
|
+
|
54
|
+
Rails/SkipsModelValidations:
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
# RSpec specific
|
58
|
+
RSpec/ExampleLength:
|
59
|
+
Max: 10
|
60
|
+
|
61
|
+
RSpec/MultipleExpectations:
|
62
|
+
Max: 3
|
63
|
+
|
64
|
+
RSpec/NestedGroups:
|
65
|
+
Max: 3
|
data/.yardopts
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
--output-dir docs/yard
|
2
|
+
--markup markdown
|
3
|
+
--markup-provider redcarpet
|
4
|
+
--charset utf-8
|
5
|
+
--no-private
|
6
|
+
--embed-mixins
|
7
|
+
--readme README.md
|
8
|
+
--title "Attio Rails Integration Documentation"
|
9
|
+
--main README.md
|
10
|
+
--files CHANGELOG.md,CONTRIBUTING.md
|
11
|
+
lib/**/*.rb
|
12
|
+
-
|
13
|
+
CHANGELOG.md
|
14
|
+
CONTRIBUTING.md
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.1.0] - 2025-01-11
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- Initial release of Attio Rails integration gem
|
14
|
+
- ActiveRecord concern `Attio::Rails::Syncable` for model synchronization
|
15
|
+
- Rails generator for initial setup (`rails generate attio:install`)
|
16
|
+
- ActiveJob integration for async syncing
|
17
|
+
- Configuration management through Rails config
|
18
|
+
- Support for Rails 6.1, 7.0, and 7.1
|
19
|
+
- Comprehensive test suite with dummy Rails app
|
20
|
+
- Full documentation with YARD
|
21
|
+
- CI/CD setup with GitHub Actions
|
22
|
+
|
23
|
+
### Features
|
24
|
+
- Automatic syncing of ActiveRecord models to Attio
|
25
|
+
- Configurable attribute mapping
|
26
|
+
- Support for callbacks (before_sync, after_sync)
|
27
|
+
- Error handling and retry logic
|
28
|
+
- Batch operations support
|
29
|
+
- Custom field transformations
|
30
|
+
|
31
|
+
[Unreleased]: https://github.com/idl3/attio-rails/compare/v0.1.0...HEAD
|
32
|
+
[0.1.0]: https://github.com/idl3/attio-rails/releases/tag/v0.1.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We pledge to make participation in our project a respectful and professional experience for everyone.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of positive behavior include:
|
10
|
+
* Using welcoming and inclusive language
|
11
|
+
* Being respectful of differing viewpoints
|
12
|
+
* Gracefully accepting constructive feedback
|
13
|
+
* Focusing on what is best for the community
|
14
|
+
* Showing empathy towards other community members
|
15
|
+
|
16
|
+
Examples of unacceptable behavior include:
|
17
|
+
* Unprofessional or unwelcome comments
|
18
|
+
* Personal attacks
|
19
|
+
* Public or private harassment
|
20
|
+
* Publishing others' private information without permission
|
21
|
+
* Other conduct which could reasonably be considered inappropriate
|
22
|
+
|
23
|
+
## Our Responsibilities
|
24
|
+
|
25
|
+
Project maintainers are responsible for clarifying standards of acceptable behavior and are expected to take appropriate corrective action in response to unacceptable behavior.
|
26
|
+
|
27
|
+
## Scope
|
28
|
+
|
29
|
+
This Code of Conduct applies within project spaces and in public spaces when representing the project.
|
30
|
+
|
31
|
+
## Enforcement
|
32
|
+
|
33
|
+
Instances of unacceptable behavior may be reported to the project team. All complaints will be reviewed and investigated promptly and fairly.
|
34
|
+
|
35
|
+
## Attribution
|
36
|
+
|
37
|
+
This Code of Conduct is adapted from the Contributor Covenant, version 2.0.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
# Contributing to Attio Rails
|
2
|
+
|
3
|
+
Thank you for your interest in contributing to the Attio Rails integration gem! This guide will help you get started.
|
4
|
+
|
5
|
+
## Table of Contents
|
6
|
+
|
7
|
+
- [Getting Started](#getting-started)
|
8
|
+
- [Development Setup](#development-setup)
|
9
|
+
- [Testing with Rails](#testing-with-rails)
|
10
|
+
- [Submitting Changes](#submitting-changes)
|
11
|
+
- [Rails-Specific Guidelines](#rails-specific-guidelines)
|
12
|
+
|
13
|
+
## Getting Started
|
14
|
+
|
15
|
+
1. Fork the repository on GitHub
|
16
|
+
2. Clone your fork locally:
|
17
|
+
```bash
|
18
|
+
git clone https://github.com/YOUR_USERNAME/attio-rails.git
|
19
|
+
cd attio-rails
|
20
|
+
```
|
21
|
+
3. Add the upstream remote:
|
22
|
+
```bash
|
23
|
+
git remote add upstream https://github.com/idl3/attio-rails.git
|
24
|
+
```
|
25
|
+
|
26
|
+
## Development Setup
|
27
|
+
|
28
|
+
1. Install Ruby 3.0 or higher
|
29
|
+
2. Install dependencies:
|
30
|
+
```bash
|
31
|
+
bundle install
|
32
|
+
```
|
33
|
+
3. Set up the test Rails app:
|
34
|
+
```bash
|
35
|
+
cd spec/dummy
|
36
|
+
bundle install
|
37
|
+
rails db:create db:migrate
|
38
|
+
cd ../..
|
39
|
+
```
|
40
|
+
4. Run tests:
|
41
|
+
```bash
|
42
|
+
bundle exec rspec
|
43
|
+
```
|
44
|
+
|
45
|
+
### Testing Different Rails Versions
|
46
|
+
|
47
|
+
To test with different Rails versions:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
# Test with Rails 7.1
|
51
|
+
RAILS_VERSION=7.1 bundle update
|
52
|
+
bundle exec rspec
|
53
|
+
|
54
|
+
# Test with Rails 7.0
|
55
|
+
RAILS_VERSION=7.0 bundle update
|
56
|
+
bundle exec rspec
|
57
|
+
|
58
|
+
# Test with Rails 6.1
|
59
|
+
RAILS_VERSION=6.1 bundle update
|
60
|
+
bundle exec rspec
|
61
|
+
```
|
62
|
+
|
63
|
+
## Testing with Rails
|
64
|
+
|
65
|
+
### Writing Rails-Specific Tests
|
66
|
+
|
67
|
+
When adding new features, ensure you test:
|
68
|
+
|
69
|
+
1. **Generator Tests**: If adding generators
|
70
|
+
```ruby
|
71
|
+
require "generators/attio/install/install_generator"
|
72
|
+
|
73
|
+
RSpec.describe Attio::Generators::InstallGenerator do
|
74
|
+
# Test generator behavior
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
2. **Model Concern Tests**: For ActiveRecord integrations
|
79
|
+
```ruby
|
80
|
+
RSpec.describe "Attio::Rails::Syncable" do
|
81
|
+
let(:model) { User.new }
|
82
|
+
# Test concern behavior
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
86
|
+
3. **Railtie Tests**: For Rails integration points
|
87
|
+
```ruby
|
88
|
+
RSpec.describe Attio::Rails::Railtie do
|
89
|
+
# Test Rails configuration
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
### Testing with Dummy Rails App
|
94
|
+
|
95
|
+
The gem includes a dummy Rails app in `spec/dummy` for integration testing:
|
96
|
+
|
97
|
+
```bash
|
98
|
+
cd spec/dummy
|
99
|
+
rails console # Test your changes interactively
|
100
|
+
rails server # Run the dummy app
|
101
|
+
```
|
102
|
+
|
103
|
+
## Submitting Changes
|
104
|
+
|
105
|
+
### Before Submitting
|
106
|
+
|
107
|
+
1. Create a feature branch:
|
108
|
+
```bash
|
109
|
+
git checkout -b feature/your-feature-name
|
110
|
+
```
|
111
|
+
|
112
|
+
2. Make your changes following Rails conventions
|
113
|
+
|
114
|
+
3. Write or update tests
|
115
|
+
|
116
|
+
4. Update documentation
|
117
|
+
|
118
|
+
5. Run the full test suite:
|
119
|
+
```bash
|
120
|
+
bundle exec rspec
|
121
|
+
bundle exec rubocop
|
122
|
+
```
|
123
|
+
|
124
|
+
6. Update CHANGELOG.md
|
125
|
+
|
126
|
+
### Commit Messages
|
127
|
+
|
128
|
+
Use conventional commits:
|
129
|
+
- `feat:` New features
|
130
|
+
- `fix:` Bug fixes
|
131
|
+
- `docs:` Documentation
|
132
|
+
- `test:` Test changes
|
133
|
+
- `chore:` Maintenance
|
134
|
+
|
135
|
+
Examples:
|
136
|
+
```
|
137
|
+
feat: add ActiveJob integration for async syncing
|
138
|
+
fix: handle Rails 7.1 deprecations
|
139
|
+
docs: add Rails 6.1 migration guide
|
140
|
+
```
|
141
|
+
|
142
|
+
## Rails-Specific Guidelines
|
143
|
+
|
144
|
+
### Following Rails Conventions
|
145
|
+
|
146
|
+
1. **Generators**: Follow Rails generator conventions
|
147
|
+
- Use Thor for generator implementation
|
148
|
+
- Provide clear descriptions
|
149
|
+
- Support Rails conventions (--skip flags, etc.)
|
150
|
+
|
151
|
+
2. **Concerns**: Design reusable concerns
|
152
|
+
- Keep concerns focused and single-purpose
|
153
|
+
- Document required methods
|
154
|
+
- Provide clear examples
|
155
|
+
|
156
|
+
3. **Configuration**: Use Rails configuration patterns
|
157
|
+
```ruby
|
158
|
+
Rails.application.configure do
|
159
|
+
config.attio.api_key = ENV['ATTIO_API_KEY']
|
160
|
+
end
|
161
|
+
```
|
162
|
+
|
163
|
+
4. **ActiveRecord Integration**:
|
164
|
+
- Follow ActiveRecord callback conventions
|
165
|
+
- Support Rails validations
|
166
|
+
- Integrate with Rails error handling
|
167
|
+
|
168
|
+
### Rails Version Compatibility
|
169
|
+
|
170
|
+
- Maintain compatibility with Rails 6.1+
|
171
|
+
- Test against multiple Rails versions
|
172
|
+
- Document version-specific features
|
173
|
+
- Handle deprecations gracefully
|
174
|
+
|
175
|
+
### Performance Considerations
|
176
|
+
|
177
|
+
- Use Rails caching when appropriate
|
178
|
+
- Leverage ActiveJob for background processing
|
179
|
+
- Optimize database queries
|
180
|
+
- Consider connection pooling
|
181
|
+
|
182
|
+
## Code Organization
|
183
|
+
|
184
|
+
```
|
185
|
+
lib/
|
186
|
+
├── attio/
|
187
|
+
│ ├── rails.rb # Main module
|
188
|
+
│ ├── rails/
|
189
|
+
│ │ ├── version.rb # Version constant
|
190
|
+
│ │ ├── railtie.rb # Rails integration
|
191
|
+
│ │ ├── configuration.rb # Config management
|
192
|
+
│ │ └── concerns/ # Model concerns
|
193
|
+
│ │ └── syncable.rb
|
194
|
+
└── generators/ # Rails generators
|
195
|
+
└── attio/
|
196
|
+
└── install/
|
197
|
+
├── install_generator.rb
|
198
|
+
└── templates/
|
199
|
+
```
|
200
|
+
|
201
|
+
## Testing Requirements
|
202
|
+
|
203
|
+
- Write tests for all new features
|
204
|
+
- Maintain test coverage above 85%
|
205
|
+
- Test with multiple Rails versions
|
206
|
+
- Include integration tests with dummy app
|
207
|
+
- Test generators with Rails test helpers
|
208
|
+
|
209
|
+
## Documentation
|
210
|
+
|
211
|
+
### YARD Documentation
|
212
|
+
|
213
|
+
Document Rails-specific features:
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
# Syncs the model with Attio
|
217
|
+
#
|
218
|
+
# @example Basic usage
|
219
|
+
# class User < ApplicationRecord
|
220
|
+
# include Attio::Rails::Syncable
|
221
|
+
#
|
222
|
+
# attio_syncable object: 'people',
|
223
|
+
# attributes: [:email, :name]
|
224
|
+
# end
|
225
|
+
#
|
226
|
+
# @param options [Hash] sync configuration
|
227
|
+
# @option options [String] :object Attio object type
|
228
|
+
# @option options [Array] :attributes Attributes to sync
|
229
|
+
def attio_syncable(**options)
|
230
|
+
# implementation
|
231
|
+
end
|
232
|
+
```
|
233
|
+
|
234
|
+
## Getting Help
|
235
|
+
|
236
|
+
- Check [Rails Guides](https://guides.rubyonrails.org/) for Rails conventions
|
237
|
+
- Review the [main Attio gem](https://github.com/idl3/attio) documentation
|
238
|
+
- Open an issue for questions
|
239
|
+
- Join discussions on GitHub
|
240
|
+
|
241
|
+
Thank you for contributing to Attio Rails!
|