Skip to content

Commit b158dfb

Browse files
committed
[devtools] sync
1 parent 050d3ef commit b158dfb

11 files changed

+240
-141
lines changed

.github/workflows/ci.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# this file is managed by dry-rb/devtools project
2+
3+
name: ci
4+
5+
"on":
6+
push:
7+
paths:
8+
- .github/workflows/ci.yml
9+
- lib/**
10+
- spec/**
11+
- Rakefile
12+
- Gemfile
13+
- Gemfile.devtools
14+
- ".rubocop.yml"
15+
- project.yml
16+
pull_request:
17+
branches:
18+
- master
19+
create:
20+
21+
jobs:
22+
tests:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
ruby:
28+
- "2.7"
29+
- "2.6"
30+
- "2.5"
31+
- "2.4"
32+
- "jruby"
33+
include:
34+
- ruby: "2.6"
35+
coverage: "true"
36+
env:
37+
CLASSPATH: "" # tmp jruby build workaround
38+
COVERAGE: ${{matrix.coverage}}
39+
CODACY_RUN_LOCAL: true
40+
CODACY_PROJECT_TOKEN: ${{secrets.CODACY_PROJECT_TOKEN}}
41+
steps:
42+
- uses: actions/checkout@v1
43+
- name: Set up Ruby
44+
uses: eregon/use-ruby-action@master
45+
with:
46+
ruby-version: ${{matrix.ruby}}
47+
- name: Install latest bundler
48+
run: |
49+
gem install bundler --no-document
50+
bundle config set without 'tools benchmarks docs'
51+
- name: Bundle install
52+
run: bundle install --jobs 4 --retry 3
53+
- name: Run all tests
54+
run: bundle exec rake
55+
release:
56+
runs-on: ubuntu-latest
57+
if: contains(github.ref, 'tags') && github.event_name == 'create'
58+
needs: tests
59+
env:
60+
GITHUB_LOGIN: dry-bot
61+
GITHUB_TOKEN: ${{secrets.GH_PAT}}
62+
steps:
63+
- uses: actions/checkout@v1
64+
- name: Set up Ruby
65+
uses: eregon/use-ruby-action@master
66+
with:
67+
ruby-version: 2.6
68+
- name: Install dependencies
69+
run: gem install ossy --no-document
70+
- name: Trigger release workflow
71+
run: |
72+
tag=$(echo $GITHUB_REF | cut -d / -f 3)
73+
ossy gh w dry-rb/devtools release --payload "{\"tag\":\"$tag\",\"tag_creator\":\"$GITHUB_ACTOR\",\"repo\":\"$GITHUB_REPOSITORY\"}"

.rspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
--color
22
--require spec_helper
33
--order random
4-
--tag ~production_env
4+
--warnings

.rubocop.yml

+72-23
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
1+
# this file is managed by dry-rb/devtools project
2+
13
AllCops:
24
TargetRubyVersion: 2.4
35

4-
Style/EachWithObject:
5-
Enabled: false
6-
76
Style/StringLiterals:
87
Enabled: true
98
EnforcedStyle: single_quotes
109

11-
Style/Alias:
10+
Style/AccessModifierDeclarations:
11+
Enabled: false
12+
13+
Style/BlockDelimiters:
1214
Enabled: false
1315

16+
Style/SymbolArray:
17+
Exclude:
18+
- "spec/**/*_spec.rb"
19+
20+
Style/ConditionalAssignment:
21+
Enabled: false
22+
23+
Style/ClassAndModuleChildren:
24+
Exclude:
25+
- "spec/**/*_spec.rb"
26+
27+
Style/EachWithObject:
28+
Enabled: false
29+
30+
Style/ParallelAssignment:
31+
Enabled: false
32+
33+
Style/Alias:
34+
Enabled: true
35+
EnforcedStyle: prefer_alias_method
36+
1437
Style/LambdaCall:
1538
Enabled: false
1639

@@ -20,40 +43,66 @@ Style/StabbyLambdaParentheses:
2043
Style/FormatString:
2144
Enabled: false
2245

46+
Style/Documentation:
47+
Enabled: false
48+
49+
Style/AsciiComments:
50+
Enabled: false
51+
52+
Style/DateTime:
53+
Enabled: false
54+
55+
Style/IfUnlessModifier:
56+
Enabled: false
57+
58+
Style/EachWithObject:
59+
Enabled: false
60+
61+
Lint/HandleExceptions:
62+
Exclude:
63+
- "spec/spec_helper.rb"
64+
65+
Lint/BooleanSymbol:
66+
Enabled: false
67+
2368
Layout/SpaceInLambdaLiteral:
2469
Enabled: false
2570

2671
Layout/MultilineMethodCallIndentation:
2772
Enabled: true
2873
EnforcedStyle: indented
2974

30-
Metrics/LineLength:
31-
Max: 100
75+
Layout/IndentFirstArrayElement:
76+
EnforcedStyle: consistent
3277

33-
Metrics/MethodLength:
34-
Max: 22
78+
Naming/PredicateName:
79+
Enabled: false
3580

36-
Metrics/ClassLength:
37-
Max: 150
81+
Naming/FileName:
82+
Exclude:
83+
- "lib/dry-*.rb"
3884

39-
Metrics/AbcSize:
40-
Max: 20
85+
Naming/MethodName:
86+
Enabled: false
4187

42-
Metrics/BlockLength:
43-
Enabled: true
44-
Exclude:
45-
- 'spec/**/*_spec.rb'
88+
Naming/MemoizedInstanceVariableName:
89+
Enabled: false
4690

47-
Metrics/CyclomaticComplexity:
48-
Enabled: true
49-
Max: 10
91+
Metrics/LineLength:
92+
Max: 100
5093

51-
Lint/BooleanSymbol:
94+
Metrics/MethodLength:
5295
Enabled: false
5396

54-
Style/AccessModifierDeclarations:
97+
Metrics/ClassLength:
5598
Enabled: false
5699

57-
Style/BlockDelimiters:
58-
EnforcedStyle: semantic
100+
Metrics/BlockLength:
101+
Enabled: false
59102

103+
Metrics/AbcSize:
104+
Max: 25
105+
106+
Metrics/CyclomaticComplexity:
107+
Enabled: true
108+
Max: 12

CODE_OF_CONDUCT.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Contributor Code of Conduct
2+
3+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4+
5+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6+
7+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8+
9+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10+
11+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12+
13+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct)

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ If you found a bug, report an issue and describe what's the expected behavior ve
66

77
## Reporting feature requests
88

9-
Report a feature request **only after discussing it first on [discuss.dry-rb.org](https://discuss.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
9+
Report a feature request **only after discussing it first on [discourse.dry-rb.org](https://discourse.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
1010

1111
## Reporting questions, support requests, ideas, concerns etc.
1212

13-
**PLEASE DON'T** - use [discuss.dry-rb.org](http://discuss.dry-rb.org) instead.
13+
**PLEASE DON'T** - use [discourse.dry-rb.org](http://discourse.dry-rb.org) instead.
1414

1515
# Pull Request Guidelines
1616

@@ -22,8 +22,8 @@ Other requirements:
2222
2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
2323
3) Add API documentation if it's a new feature
2424
4) Update API documentation if it changes an existing feature
25-
5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
25+
5) Bonus points for sending a PR which updates user documentation in the `docsite` directory
2626

2727
# Asking for help
2828

29-
If these guidelines aren't helpful, and you're stuck, please post a message on [discuss.dry-rb.org](https://discuss.dry-rb.org).
29+
If these guidelines aren't helpful, and you're stuck, please post a message on [discourse.dry-rb.org](https://discourse.dry-rb.org) or join [our chat](https://dry-rb.zulipchat.com).

Gemfile.devtools

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# this file is managed by dry-rb/devtools project
2+
3+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4+
5+
group :test do
6+
gem 'codacy-coverage', require: false, platforms: :ruby
7+
gem 'simplecov', require: false, platforms: :ruby
8+
gem 'warning' if RUBY_VERSION >= '2.4.0'
9+
end
10+
11+
group :tools do
12+
# this is the same version that we use on codacy
13+
gem 'rubocop', '0.71.0'
14+
end

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 dry-rb.org team
3+
Copyright (c) 2015-2020 dry-rb team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

+17-97
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,28 @@
1-
[gem]: https://rubygems.org/gems/dry-system-rails
2-
[travis]: https://travis-ci.org/dry-rb/dry-system-rails
3-
[codeclimate]: https://codeclimate.com/github/dry-rb/dry-system-rails
1+
[gem]: https://rubygems.org/gems/dry-rails
2+
[actions]: https://github.com/dry-rb/dry-rails/actions
3+
[codacy]: https://www.codacy.com/gh/dry-rb/dry-rails
44
[chat]: https://dry-rb.zulipchat.com
5-
[inchpages]: http://inch-ci.org/github/dry-rb/dry-system-rails
5+
[inchpages]: http://inch-ci.org/github/dry-rb/dry-rails
66

7-
# dry-system-rails [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
7+
# dry-rails [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
88

9-
[![Gem Version](https://badge.fury.io/rb/dry-system-rails.svg)][gem]
10-
[![Build Status](https://travis-ci.org/dry-rb/dry-system-rails.svg?branch=master)][travis]
11-
[![Code Climate](https://codeclimate.com/github/dry-rb/dry-system-rails/badges/gpa.svg)][codeclimate]
12-
[![Test Coverage](https://codeclimate.com/github/dry-rb/dry-system-rails/badges/coverage.svg)][codeclimate]
13-
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-system-rails.svg?branch=master)][inchpages]
9+
[![Gem Version](https://badge.fury.io/rb/dry-rails.svg)][gem]
10+
[![CI Status](https://github.com/dry-rb/dry-rails/workflows/ci/badge.svg)][actions]
11+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d4677ea0c4c2497bb1af1b3ac31552f4)][codacy]
12+
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/d4677ea0c4c2497bb1af1b3ac31552f4)][codacy]
13+
[![Inline docs](http://inch-ci.org/github/dry-rb/dry-rails.svg?branch=master)][inchpages]
1414

15-
Railtie for dry-system (つ◕౪◕)つ━☆゚.*・。゚
15+
## Links
1616

17-
## Installation
17+
* [User documentation](http://dry-rb.org/gems/dry-rails)
18+
* [API documentation](http://rubydoc.info/gems/dry-rails)
1819

19-
Add it to your Gemfile:
20+
## Supported Ruby versions
2021

21-
```
22-
gem 'dry-system-rails'
23-
```
22+
This library officially supports the following Ruby versions:
2423

25-
## Usage
26-
27-
To configure auto-registration create `config/initializers/system.rb` with the following content:
28-
29-
``` ruby
30-
Dry::System::Rails.container do
31-
# you can set it to whatever you want and add as many dirs you want
32-
config.auto_register << 'lib'
33-
end
34-
```
35-
36-
The `Dry::System::Rails::Railtie` creates a container and injector on your behalf at runtime and assign them to two constants `Container` and `Import`
37-
under your applications root module. E.g. if your application is named `MyApp`, the `Railtie` will add the following constants:
38-
39-
* `MyApp::Container`
40-
* `MyApp::Import`
41-
42-
Now you can use `MyApp::Import` to inject components into your objects and framework components:
43-
44-
``` ruby
45-
# lib/user_repo.rb
46-
class UserRepo
47-
48-
end
49-
50-
# lib/create_user.rb
51-
class CreateUser
52-
include MyApp::Import['user_repo']
53-
end
54-
55-
# app/controllers/users_controller.rb
56-
class UsersController < ApplicationController
57-
include MyApp::Import['create_user']
58-
end
59-
```
60-
61-
## Working with Framework Dependencies
62-
63-
The Rails API is designed around the usage of class methods. If you choose to write domain logic in objects you will likely encounter a situation where your code will have to use one of the framework components. That is where manual registration using [bootable dependency](https://dry-rb.org/gems/dry-system/booting) will come in handy.
64-
65-
E.g. You have an object `CreateWidget` that needs to process widgets asynchronously with an `Widgets:NotificationJob` but you want to leverage dependency injection to decouple the components:
66-
67-
```ruby
68-
# config/initializers/system.rb
69-
Dry::System::Rails.container do
70-
# changes `self` to the container
71-
config.auto_register << 'lib'
72-
end
73-
74-
# app/jobs/widgets/notification_job.rb
75-
class Widgets::NotificationJob < ApplicationJob
76-
end
77-
78-
# config/system/boot/application.rb
79-
# Use bootable componets to manually register framework dependencies
80-
MyApp::Container.boot(:application) do |app|
81-
setup do
82-
app.namespace(:widgets) do |widgets|
83-
widgets.register(:notification, memoize: true) { Widgets::NotificationJob }
84-
end
85-
end
86-
end
87-
88-
# lib/create_widget.rb
89-
class CreateWidget
90-
include MyApp::Import[job: 'widgets.notification']
91-
92-
def call(args)
93-
# some logic that creates a widget command
94-
job.perform_later(create_widget_command)
95-
end
96-
end
97-
```
98-
99-
## TODO
100-
101-
This is super alpha and it's missing a couple of things:
102-
103-
* Some generators to make UX nicer
104-
* Tests for loading scripts (console etc)
105-
* Tests for running rake tasks
24+
* MRI >= `2.4`
25+
* jruby >= `9.2`
10626

10727
## License
10828

0 commit comments

Comments
 (0)