attr_extras 6.2.4 → 6.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4f8e12f94bbc166632e1a65a52f83ddc14e4982ad57f87043fa285e7e7a8cf2
4
- data.tar.gz: 1d621e46616f5df763909d9481f983d60fe4e014a8a9a3b0dbfc2635d8867d71
3
+ metadata.gz: a01c4bfc2a6ce3f1ae8735fe122b7abbd65c99be5a17330087e09e028e59b3cb
4
+ data.tar.gz: c83abb5d1467b7c91b2ff0c54220fa72ebdc2d6ee0deba2c7ca8edc3629f744c
5
5
  SHA512:
6
- metadata.gz: 44cade5ed299c18a1e8c01706e04767f1b49f3a934a53759542702fd6435c8ba225b360250dd276a78174fdea32e112ca1155cf20e172db765940ea05ecb3b03
7
- data.tar.gz: 7fe165a6de71503666cb3344478c769385d50a31ca11de78cce7f934d87393867a5e2c3bc05703c7a3fdc86dd81da729703452c35d0999600f70b42a35851629
6
+ metadata.gz: 48893855229adec5435cd0b709c50cf1e631e321197dd23baeaaa54e11c513f1d4f47ac3e9b3ab2268fc6d86c26c519e57c8e12d9c7aa2a7e819e9c5a53d9cfd
7
+ data.tar.gz: dc63a635eedac54ce49b25eece473e5264b655d2c87852725bc28baeaf4f9c7d516febad45978ba71816c3dec0afc1e5e114c9587c16ad890999a408efe588cd
@@ -0,0 +1,26 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ["3.0", "2.7", "2.6", "2.5", "jruby-head"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby-version }}
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - name: Run tests
26
+ run: bundle exec rake
data/README.md CHANGED
@@ -1,22 +1,31 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/attr_extras.svg)](https://badge.fury.io/rb/attr_extras)
2
- [![Build status](https://secure.travis-ci.org/barsoom/attr_extras.svg)](https://travis-ci.org/#!/barsoom/attr_extras/builds)
2
+ [![Ruby CI](https://github.com/barsoom/attr_extras/actions/workflows/ci.yml/badge.svg)](https://github.com/barsoom/attr_extras/actions/workflows/ci.yml)
3
3
  [![Code Climate](https://codeclimate.com/github/barsoom/attr_extras/badges/gpa.svg)](https://codeclimate.com/github/barsoom/attr_extras)
4
4
 
5
5
  # attr\_extras
6
6
 
7
7
  Takes some boilerplate out of Ruby, lowering the barrier to extracting small focused classes, without [the downsides of using `Struct`](http://thepugautomatic.com/2013/08/struct-inheritance-is-overused/).
8
8
 
9
+ Provides lower-level methods like `attr_private` and `attr_value` that nicely complement Ruby's built-in `attr_accessor`, `attr_reader` and `attr_writer`.
10
+
11
+ Also higher-level ones like `pattr_initialize` (or `attr_private_initialize`) and `method_object` to really cut down on the boilerplate.
12
+
9
13
  Instead of
10
14
 
11
15
  ``` ruby
12
- class InvoiceBuilder
13
- def initialize(invoice, employee)
14
- @invoice, @employee = invoice, employee
16
+ class InvoicePolicy
17
+ def initialize(invoice, company:)
18
+ @invoice = invoice
19
+ @company = company
20
+ end
21
+
22
+ def payable?
23
+ some_logic(invoice, company)
15
24
  end
16
25
 
17
26
  private
18
27
 
19
- attr_reader :invoice, :employee
28
+ attr_reader :invoice, :company
20
29
  end
21
30
  ```
22
31
 
@@ -24,11 +33,58 @@ you can just do
24
33
 
25
34
  ``` ruby
26
35
  class InvoiceBuilder
27
- pattr_initialize :invoice, :employee
36
+ pattr_initialize :invoice, [:company!]
37
+
38
+ def payable?
39
+ some_logic(invoice, company)
40
+ end
28
41
  end
29
42
  ```
30
43
 
31
- This nicely complements Ruby's built-in `attr_accessor`, `attr_reader` and `attr_writer`.
44
+ And instead of
45
+
46
+ ``` ruby
47
+ class PayInvoice
48
+ def self.call(invoice, amount)
49
+ new(invoice, amount).call
50
+ end
51
+
52
+ def initialize(invoice, amount)
53
+ @invoice = invoice
54
+ @amount = amount
55
+ end
56
+
57
+ def call
58
+ PaymentGateway.charge(invoice.id, amount_in_cents)
59
+ end
60
+
61
+ private
62
+
63
+ def amount_in_cents
64
+ amount * 100
65
+ end
66
+
67
+ attr_reader :invoice, :amount
68
+ end
69
+ ```
70
+
71
+ you can just do
72
+
73
+ ``` ruby
74
+ class PayInvoice
75
+ method_object :invoice, :amount
76
+
77
+ def call
78
+ PaymentGateway.charge(invoice.id, amount_in_cents)
79
+ end
80
+
81
+ private
82
+
83
+ def amount_in_cents
84
+ amount * 100
85
+ end
86
+ end
87
+ ```
32
88
 
33
89
  Supports positional arguments as well as optional and required keyword arguments.
34
90
 
data/attr_extras.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.require_paths = ["lib"]
15
15
  gem.license = "MIT"
16
16
  gem.version = AttrExtras::VERSION
17
+ gem.metadata = { "rubygems_mfa_required" => "true" }
17
18
 
18
19
  gem.add_development_dependency "minitest", ">= 5"
19
20
  gem.add_development_dependency "m", "~> 1.5.1" # Running individual tests.
@@ -1,3 +1,3 @@
1
1
  module AttrExtras
2
- VERSION = "6.2.4"
2
+ VERSION = "6.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.4
4
+ version: 6.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-06-08 00:00:00.000000000 Z
15
+ date: 2021-11-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: minitest
@@ -63,8 +63,8 @@ executables: []
63
63
  extensions: []
64
64
  extra_rdoc_files: []
65
65
  files:
66
+ - ".github/workflows/ci.yml"
66
67
  - ".gitignore"
67
- - ".travis.yml"
68
68
  - CHANGELOG.md
69
69
  - Gemfile
70
70
  - LICENSE.txt
@@ -102,7 +102,8 @@ files:
102
102
  homepage: https://github.com/barsoom/attr_extras
103
103
  licenses:
104
104
  - MIT
105
- metadata: {}
105
+ metadata:
106
+ rubygems_mfa_required: 'true'
106
107
  post_install_message:
107
108
  rdoc_options: []
108
109
  require_paths:
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  - !ruby/object:Gem::Version
119
120
  version: '0'
120
121
  requirements: []
121
- rubygems_version: 3.1.2
122
+ rubygems_version: 3.2.28
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Takes some boilerplate out of Ruby with methods like attr_initialize.
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.7.1
4
- - 2.6.6
5
- - 2.5.8
6
- - jruby-head