dry-core 0.4.7 → 0.4.8

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: 74e2816087ba373bcfd55f8e216ef6708e1e70b0930020d71518385190460537
4
- data.tar.gz: 19eb04ff0972c2b928e455ff7345c93caed587af56ea8089a5433eb471a624b3
3
+ metadata.gz: 248dbedf379c8c7c585274a2334bd6b6347641d59d66f2348bb78990ac60d921
4
+ data.tar.gz: 2abd02588d6151cbe2ce1ddb6d547b841a6a5c6dd73eeedf2adf92fb760ad06a
5
5
  SHA512:
6
- metadata.gz: c1949faf46146ee0bb734aec09350b864ba414105ad7ceef4dad476b3667f4d14c0474c84da28fdf293e651da9a7a26119501548d6512eeed42e5e1296270d12
7
- data.tar.gz: ffa845da4bf5da3f5b370f6093721d4c7689bde90da3b4a58f17954807fc9fe0f7065997b7bebee46e6eed2525bd181c042fe550ffa1b4557fa9cf95ee6eae47
6
+ metadata.gz: d0a1a31e66dcac988307bbff851611773d0d8bc2b561a76b0dcdd18d17199d49e4eabcf84e42e7443fdc0e5b16bfdde86d532b6bbe78bd070f32945fc2506f3a
7
+ data.tar.gz: 46afa1f06dd69b69a182f9d5cfa17cf8d0d9d419d22193d61b18f967f56fe3d0042de3c1bf38e5a41756faca5e230e246b80d5bf074666dac384ba2f93c813be
@@ -0,0 +1,15 @@
1
+ version: "2"
2
+
3
+ prepare:
4
+ fetch:
5
+ - url: "https://raw.githubusercontent.com/dry-rb/devtools/master/.rubocop.yml"
6
+ path: ".rubocop.yml"
7
+
8
+ exclude_patterns:
9
+ - "benchmarks/"
10
+ - "examples/"
11
+ - "spec/"
12
+
13
+ plugins:
14
+ rubocop:
15
+ enabled: true
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  spec/examples.txt
11
+ .rubocop.yml
@@ -5,22 +5,23 @@ cache: bundler
5
5
  bundler_args: --without benchmarks tools
6
6
  after_success:
7
7
  - '[ -d coverage ] && bundle exec codeclimate-test-reporter'
8
- script:
9
- - bundle exec rake
10
8
  before_install:
11
- - gem update --system
9
+ - gem install bundler
12
10
  after_success:
13
11
  - '[ -d coverage ] && bundle exec codeclimate-test-reporter'
14
12
  rvm:
15
- - 2.2.9
16
- - 2.3.6
17
- - 2.4.3
18
- - 2.5.0
19
- - jruby-9.1.15.0
13
+ - 2.4.6
14
+ - 2.5.5
15
+ - 2.6.3
16
+ - jruby-9.2.7.0
17
+ - truffleruby
20
18
  env:
21
19
  global:
22
20
  - COVERAGE=true
23
21
  - JRUBY_OPTS='--dev -J-Xmx1024M'
22
+ matrix:
23
+ allow_failures:
24
+ - rvm: truffleruby
24
25
  notifications:
25
26
  email: false
26
27
  webhooks:
@@ -1,8 +1,23 @@
1
+ # v0.4.8 2019-06-23
2
+
3
+ ### Added
4
+
5
+ - `Undefined.map` for mapping non-undefined values (flash-gordon):
6
+
7
+ ```ruby
8
+ something = 1
9
+ Undefined.map(something) { |v| v + 1 } # => 2
10
+ something = Undefined
11
+ Undefined.map(something) { |v| v + 1 } # => Undefined
12
+ ```
13
+
14
+ [Compare v0.4.7...v0.4.8](https://github.com/dry-rb/dry-core/compare/v0.4.7...v0.4.8)
15
+
1
16
  # v0.4.7 2018-06-25
2
17
 
3
18
  ### Fixed
4
19
 
5
- * Fix default logger for deprecations, it now uses `$stderr` by default, as it should (flash-gordon)
20
+ - Fix default logger for deprecations, it now uses `$stderr` by default, as it should (flash-gordon)
6
21
 
7
22
  [Compare v0.4.6...v0.4.7](https://github.com/dry-rb/dry-core/compare/v0.4.6...v0.4.7)
8
23
 
@@ -10,7 +25,7 @@
10
25
 
11
26
  ### Changed
12
27
 
13
- * Trigger constant autoloading in the class builder (radar)
28
+ - Trigger constant autoloading in the class builder (radar)
14
29
 
15
30
  [Compare v0.4.5...v0.4.6](https://github.com/dry-rb/dry-core/compare/v0.4.5...v0.4.6)
16
31
 
@@ -18,7 +33,7 @@
18
33
 
19
34
  ### Added
20
35
 
21
- * `Dry::Core::Memoizable`, which provides a `memoize` macro for memoizing results of instance methods (timriley)
36
+ - `Dry::Core::Memoizable`, which provides a `memoize` macro for memoizing results of instance methods (timriley)
22
37
 
23
38
  [Compare v0.4.4...v0.4.5](https://github.com/dry-rb/dry-core/compare/v0.4.4...v0.4.5)
24
39
 
@@ -26,8 +41,8 @@
26
41
 
27
42
  ### Added
28
43
 
29
- * `deprecate_constant` overrides `Module#deprecate_constant` and issues a labeled message on accessing a deprecated constant (flash-gordon)
30
- * `Undefined.default` which accepts two arguments and returns the first if it's not `Undefined`; otherwise, returns the second one or yields a block (flash-gordon)
44
+ - `deprecate_constant` overrides `Module#deprecate_constant` and issues a labeled message on accessing a deprecated constant (flash-gordon)
45
+ - `Undefined.default` which accepts two arguments and returns the first if it's not `Undefined`; otherwise, returns the second one or yields a block (flash-gordon)
31
46
 
32
47
  [Compare v0.4.3...v0.4.4](https://github.com/dry-rb/dry-core/compare/v0.4.3...v0.4.4)
33
48
 
@@ -35,7 +50,7 @@
35
50
 
36
51
  ### Added
37
52
 
38
- * `Dry::Core::DescendantsTracker` which is a maintained version of the [`descendants_tracker`](https://github.com/dkubb/descendants_tracker) gem (flash-gordon)
53
+ - `Dry::Core::DescendantsTracker` which is a maintained version of the [`descendants_tracker`](https://github.com/dkubb/descendants_tracker) gem (flash-gordon)
39
54
 
40
55
  [Compare v0.4.2...v0.4.3](https://github.com/dry-rb/dry-core/compare/v0.4.2...0.4.3)
41
56
 
@@ -43,7 +58,7 @@
43
58
 
44
59
  ### Fixed
45
60
 
46
- * Class attributes now support private setters/getters (flash-gordon)
61
+ - Class attributes now support private setters/getters (flash-gordon)
47
62
 
48
63
  [Compare v0.4.1...v0.4.2](https://github.com/dry-rb/dry-core/compare/v0.4.1...v0.4.2)
49
64
 
@@ -51,7 +66,7 @@
51
66
 
52
67
  ### Changed
53
68
 
54
- * Improved error message on invalid attribute value (GustavoCaso)
69
+ - Improved error message on invalid attribute value (GustavoCaso)
55
70
 
56
71
  [Compare v0.4.0...v0.4.1](https://github.com/dry-rb/dry-core/compare/v0.4.0...v0.4.1)
57
72
 
@@ -59,7 +74,7 @@
59
74
 
60
75
  ### Added
61
76
 
62
- * Added the `:type` option to class attributes, you can now restrict attribute values with a type. You can either use plain ruby types (`Integer`, `String`, etc) or `dry-types` (GustavoCaso)
77
+ - Added the `:type` option to class attributes, you can now restrict attribute values with a type. You can either use plain ruby types (`Integer`, `String`, etc) or `dry-types` (GustavoCaso)
63
78
 
64
79
  ```ruby
65
80
  class Foo
@@ -76,7 +91,7 @@
76
91
 
77
92
  ### Fixed
78
93
 
79
- * `Deprecations` output is set to `$stderr` by default now (solnic)
94
+ - `Deprecations` output is set to `$stderr` by default now (solnic)
80
95
 
81
96
  [Compare v0.3.3...v0.3.4](https://github.com/dry-rb/dry-core/compare/v0.3.3...v0.3.4)
82
97
 
@@ -84,7 +99,7 @@
84
99
 
85
100
  ### Fixed
86
101
 
87
- * The Deprecations module now shows the right caller line (flash-gordon)
102
+ - The Deprecations module now shows the right caller line (flash-gordon)
88
103
 
89
104
  [Compare v0.3.2...v0.3.3](https://github.com/dry-rb/dry-core/compare/v0.3.2...v0.3.3)
90
105
 
@@ -92,7 +107,7 @@
92
107
 
93
108
  ### Added
94
109
 
95
- * Accept an existing logger object in `Dry::Core::Deprecations.set_logger!` (flash-gordon)
110
+ - Accept an existing logger object in `Dry::Core::Deprecations.set_logger!` (flash-gordon)
96
111
 
97
112
  [Compare v0.3.1...v0.3.2](https://github.com/dry-rb/dry-core/compare/v0.3.1...v0.3.2)
98
113
 
@@ -100,7 +115,7 @@
100
115
 
101
116
  ### Added
102
117
 
103
- * Support for building classes within an existing namespace (flash-gordon)
118
+ - Support for building classes within an existing namespace (flash-gordon)
104
119
 
105
120
  [Compare v0.3.0...v0.3.1](https://github.com/dry-rb/dry-core/compare/v0.3.0...v0.3.1)
106
121
 
@@ -108,7 +123,7 @@
108
123
 
109
124
  ### Changed
110
125
 
111
- * Class attributes are initialized _before_ running the `inherited` hook. It's slightly more convenient behavior and it's very unlikely anyone will be affected by this, but technically this is a breaking change (flash-gordon)
126
+ - Class attributes are initialized _before_ running the `inherited` hook. It's slightly more convenient behavior and it's very unlikely anyone will be affected by this, but technically this is a breaking change (flash-gordon)
112
127
 
113
128
  [Compare v0.2.4...v0.3.0](https://github.com/dry-rb/dry-core/compare/v0.2.4...v0.3.0)
114
129
 
@@ -116,7 +131,7 @@
116
131
 
117
132
  ### Fixed
118
133
 
119
- * Do not require deprecated method to be defined (flash-gordon)
134
+ - Do not require deprecated method to be defined (flash-gordon)
120
135
 
121
136
  [Compare v0.2.3...v0.2.4](https://github.com/dry-rb/dry-core/compare/v0.2.3...v0.2.4)
122
137
 
@@ -124,7 +139,7 @@
124
139
 
125
140
  ### Fixed
126
141
 
127
- * Fix warnings on using uninitialized class attributes (flash-gordon)
142
+ - Fix warnings on using uninitialized class attributes (flash-gordon)
128
143
 
129
144
  [Compare v0.2.2...v0.2.3](https://github.com/dry-rb/dry-core/compare/v0.2.2...v0.2.3)
130
145
 
@@ -132,7 +147,7 @@
132
147
 
133
148
  ### Added
134
149
 
135
- * `ClassAttributes` which provides `defines` method for defining get-or-set methods (flash-gordon)
150
+ - `ClassAttributes` which provides `defines` method for defining get-or-set methods (flash-gordon)
136
151
 
137
152
  [Compare v0.2.1...v0.2.2](https://github.com/dry-rb/dry-core/compare/v0.2.1...v0.2.2)
138
153
 
@@ -140,7 +155,7 @@
140
155
 
141
156
  ### Added
142
157
 
143
- * `Constants` are now available in nested scopes (flash-gordon)
158
+ - `Constants` are now available in nested scopes (flash-gordon)
144
159
 
145
160
  [Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-core/compare/v0.2.0...v0.2.1)
146
161
 
data/Gemfile CHANGED
@@ -11,12 +11,11 @@ group :test do
11
11
  gem 'inflecto', '~> 0.0', '>= 0.0.2'
12
12
  gem 'codeclimate-test-reporter', require: false
13
13
  gem 'simplecov', require: false
14
- gem 'dry-types'
15
- gem 'dry-inflector', git: 'https://github.com/dry-rb/dry-inflector', branch: 'master'
14
+ gem 'dry-types', '~> 1.0'
15
+ gem 'dry-inflector'
16
16
  end
17
17
 
18
18
  group :tools do
19
19
  gem 'pry-byebug', platform: :mri
20
20
  gem 'pry', platform: :jruby
21
- gem 'rubocop'
22
21
  end
data/README.md CHANGED
@@ -3,8 +3,9 @@
3
3
  [travis]: https://travis-ci.org/dry-rb/dry-core
4
4
  [code_climate]: https://codeclimate.com/github/dry-rb/dry-core
5
5
  [inch]: http://inch-ci.org/github/dry-rb/dry-core
6
+ [chat]: https://dry-rb.zulipchat.com
6
7
 
7
- # dry-core
8
+ # dry-core [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
8
9
 
9
10
  [![Gem Version](https://img.shields.io/gem/v/dry-core.svg)][gem]
10
11
  [![Build Status](https://img.shields.io/travis/dry-rb/dry-core.svg)][travis]
@@ -15,6 +16,20 @@
15
16
 
16
17
  A collection of small modules used in the dry-rb ecosystem.
17
18
 
19
+ ## Links
20
+
21
+ * [User docs](https://dry-rb.org/gems/dry-core)
22
+ * [API docs](http://rubydoc.info/gems/dry-core)
23
+
24
+ ## Supported Ruby versions
25
+
26
+ This library officially supports following Ruby versions:
27
+
28
+ * MRI >= `2.4`
29
+ * jruby >= `9.2`
30
+
31
+ It **should** work on MRI `2.3.x` too, but there's no official support for this version.
32
+
18
33
  ## Installation
19
34
 
20
35
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('../lib', __FILE__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'dry/core/version'
@@ -28,7 +30,7 @@ Gem::Specification.new do |spec|
28
30
  spec.required_ruby_version = '>= 2.1.0'
29
31
  spec.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
30
32
 
31
- spec.add_development_dependency 'bundler', '~> 1.12'
33
+ spec.add_development_dependency 'bundler'
32
34
  spec.add_development_dependency 'rake', '~> 10.0'
33
35
  spec.add_development_dependency 'rspec', '~> 3.0'
34
36
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/core'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/core/version'
2
4
 
3
5
  # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'concurrent/map'
2
4
 
3
5
  module Dry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry/core/constants'
2
4
  require 'dry/core/errors'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Core
3
5
  # Class for generating more classes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Dry
@@ -48,13 +50,13 @@ module Dry
48
50
  # otherwise return the second arg or yield the block.
49
51
  #
50
52
  # @example
51
- # def method(val = Undefined)
52
- # 1 + Undefined.default(val, 2)
53
- # end
53
+ # def method(val = Undefined)
54
+ # 1 + Undefined.default(val, 2)
55
+ # end
54
56
  #
55
57
  def undefined.default(x, y = self)
56
- if x.equal?(self)
57
- if y.equal?(self)
58
+ if equal?(x)
59
+ if equal?(y)
58
60
  yield
59
61
  else
60
62
  y
@@ -63,6 +65,21 @@ module Dry
63
65
  x
64
66
  end
65
67
  end
68
+
69
+ # Map a non-undefined value
70
+ #
71
+ # @example
72
+ # def add_five(val = Undefined)
73
+ # Undefined.map(val) { |x| x + 5 }
74
+ # end
75
+ #
76
+ def undefined.map(value)
77
+ if equal?(value)
78
+ self
79
+ else
80
+ yield(value)
81
+ end
82
+ end
66
83
  end.freeze
67
84
 
68
85
  def self.included(base)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'logger'
2
4
 
3
5
  module Dry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'concurrent/array'
2
4
 
3
5
  module Dry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Core
3
5
  class InvalidClassAttributeValue < StandardError
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module Dry
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Core
3
5
  # Helper module providing thin interface around an inflection backend.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Core
3
5
  module Memoizable
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Core
3
- VERSION = '0.4.7'.freeze
5
+ VERSION = '0.4.8'.freeze
4
6
  end
5
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikita Shilnikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-25 00:00:00.000000000 Z
11
+ date: 2019-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.12'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.12'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -73,10 +73,10 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".codeclimate.yml"
76
77
  - ".gitignore"
77
78
  - ".inch.yml"
78
79
  - ".rspec"
79
- - ".rubocop.yml"
80
80
  - ".travis.yml"
81
81
  - CHANGELOG.md
82
82
  - CONTRIBUTING.md
@@ -118,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.7.6
121
+ rubygems_version: 3.0.3
123
122
  signing_key:
124
123
  specification_version: 4
125
124
  summary: A toolset of small support modules used throughout the dry-rb ecosystem.
@@ -1,31 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.1
3
- Exclude:
4
- - 'dry-core.gemspec'
5
- - 'spec/spec_helper.rb'
6
-
7
- Style/SignalException:
8
- Exclude:
9
- - 'spec/**/*'
10
-
11
- Style/RedundantSelf:
12
- Exclude:
13
- - 'lib/dry/core/deprecations.rb'
14
-
15
- Metrics/LineLength:
16
- Max: 110
17
-
18
- Metrics/MethodLength:
19
- Enabled: false
20
-
21
- Style/FileName:
22
- Exclude:
23
- - 'lib/dry-core.rb'
24
-
25
- Lint/AmbiguousRegexpLiteral:
26
- Exclude:
27
- - 'spec/**/*'
28
-
29
- Style/BlockDelimiters:
30
- Exclude:
31
- - 'spec/**/*'