attr_bool 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -15
- data/attr_bool.gemspec +25 -19
- data/lib/attr_bool.rb +12 -50
- data/lib/attr_bool/core_ext.rb +29 -0
- data/lib/attr_bool/version.rb +4 -4
- metadata +40 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08774043d349869b1a07f48acc95fb7c4239a6f7cbb7616db959adb82f204972'
|
4
|
+
data.tar.gz: 8076675a422c70291b7e5c775a6b8bb1ab7483e2987786ce53af438e2190ad72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bda865800a81e391929d58265b5d094384ba9f516c8ac2bb893d4f742d5bbd18e33eb43c4b237ac63993adca625db3dd0cd2e8fc69bbae33bc18f5da94da512
|
7
|
+
data.tar.gz: 78fe47e718bc4c9bd8988b17f9aca267b72861398c809761ae35288c96c860e663179867834debf4368a74f07c5c069a5b0f9bae08b1ec348ade1b58e93ade47
|
data/Rakefile
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
#--
|
5
|
-
# This file is part of
|
5
|
+
# This file is part of AttrBool.
|
6
6
|
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
7
7
|
#
|
8
|
-
#
|
8
|
+
# AttrBool is free software: you can redistribute it and/or modify it under
|
9
9
|
# the terms of the MIT License.
|
10
10
|
#
|
11
|
-
# You should have received a copy of the MIT License along with
|
11
|
+
# You should have received a copy of the MIT License along with AttrBool.
|
12
12
|
# If not, see <https://choosealicense.com/licenses/mit/>.
|
13
13
|
#++
|
14
14
|
|
@@ -22,18 +22,16 @@ require 'yard'
|
|
22
22
|
|
23
23
|
require 'attr_bool/version'
|
24
24
|
|
25
|
-
|
26
|
-
CLEAN.exclude('.git/','stock/')
|
25
|
+
CLEAN.exclude('{.git,stock}/**/*')
|
27
26
|
CLOBBER.include('doc/')
|
28
27
|
|
29
|
-
|
30
28
|
task default: [:test]
|
31
29
|
|
32
|
-
desc 'Generate doc
|
30
|
+
desc 'Generate doc'
|
33
31
|
task :doc => [:yard] do |task|
|
34
32
|
end
|
35
33
|
|
36
|
-
desc 'Generate doc for tests too
|
34
|
+
desc 'Generate doc for tests too'
|
37
35
|
task :doc_test do |task|
|
38
36
|
ENV['doctest'] = 'y'
|
39
37
|
|
@@ -44,6 +42,7 @@ task :doc_test do |task|
|
|
44
42
|
end
|
45
43
|
|
46
44
|
Rake::TestTask.new() do |task|
|
45
|
+
task.deps << :doc_test
|
47
46
|
task.libs = ['lib','test']
|
48
47
|
task.pattern = File.join('test','**','*_test.rb')
|
49
48
|
task.description += ": '#{task.pattern}'"
|
@@ -54,20 +53,15 @@ end
|
|
54
53
|
YARD::Rake::YardocTask.new() do |task|
|
55
54
|
task.files = [File.join('lib','**','*.{rb}')]
|
56
55
|
|
57
|
-
task.options += ['--files','CHANGELOG.md,LICENSE.txt']
|
58
|
-
task.options += ['--readme','README.md']
|
59
|
-
|
60
|
-
task.options << '--protected' # Show protected methods
|
61
56
|
#task.options += ['--template-path',File.join('yard','templates')]
|
62
|
-
task.options += ['--title',"
|
57
|
+
task.options += ['--title',"AttrBool v#{AttrBool::VERSION} doc"]
|
63
58
|
|
64
59
|
task.before = Proc.new() do
|
65
60
|
task.files << File.join('test','**','*.{rb}') if ENV['doctest'].to_s().casecmp?('y')
|
66
61
|
end
|
67
62
|
end
|
68
63
|
|
69
|
-
|
70
|
-
desc 'Benchmark define_method vs module_eval & ?: vs bangbang'
|
64
|
+
desc 'Benchmark define_method vs module_eval and ?: vs bangbang'
|
71
65
|
task :benchmark do |task|
|
72
66
|
N0 = 100_000
|
73
67
|
N1 = 20_000_000
|
data/attr_bool.gemspec
CHANGED
@@ -2,22 +2,18 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
#--
|
5
|
-
# This file is part of
|
5
|
+
# This file is part of AttrBool.
|
6
6
|
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
7
7
|
#
|
8
|
-
#
|
8
|
+
# AttrBool is free software: you can redistribute it and/or modify it under
|
9
9
|
# the terms of the MIT License.
|
10
10
|
#
|
11
|
-
# You should have received a copy of the MIT License along with
|
11
|
+
# You should have received a copy of the MIT License along with AttrBool.
|
12
12
|
# If not, see <https://choosealicense.com/licenses/mit/>.
|
13
13
|
#++
|
14
14
|
|
15
15
|
|
16
|
-
|
17
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
18
|
-
|
19
|
-
require 'attr_bool/version'
|
20
|
-
|
16
|
+
require_relative 'lib/attr_bool/version'
|
21
17
|
|
22
18
|
Gem::Specification.new() do |spec|
|
23
19
|
spec.name = 'attr_bool'
|
@@ -32,22 +28,32 @@ Gem::Specification.new() do |spec|
|
|
32
28
|
' Default values can also be passed in.'
|
33
29
|
|
34
30
|
spec.metadata = {
|
35
|
-
'bug_tracker_uri' => 'https://github.com/esotericpig/attr_bool/issues',
|
36
|
-
'changelog_uri' => 'https://github.com/esotericpig/attr_bool/blob/master/CHANGELOG.md',
|
37
31
|
'homepage_uri' => 'https://github.com/esotericpig/attr_bool',
|
38
32
|
'source_code_uri' => 'https://github.com/esotericpig/attr_bool',
|
33
|
+
'bug_tracker_uri' => 'https://github.com/esotericpig/attr_bool/issues',
|
34
|
+
'changelog_uri' => 'https://github.com/esotericpig/attr_bool/blob/master/CHANGELOG.md',
|
39
35
|
}
|
40
36
|
|
41
|
-
spec.
|
37
|
+
spec.required_ruby_version = '>= 2.4'
|
38
|
+
spec.require_paths = ['lib']
|
39
|
+
|
40
|
+
spec.files = [
|
41
|
+
Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{erb,rb}')),
|
42
|
+
%W[ Gemfile #{spec.name}.gemspec Rakefile ],
|
43
|
+
%w[ LICENSE.txt ],
|
44
|
+
].flatten()
|
42
45
|
|
43
|
-
spec.
|
44
|
-
|
45
|
-
|
46
|
+
spec.add_development_dependency 'bundler' ,'~> 2.1'
|
47
|
+
spec.add_development_dependency 'minitest' ,'~> 5.14'
|
48
|
+
spec.add_development_dependency 'rake' ,'~> 13.0'
|
49
|
+
spec.add_development_dependency 'rdoc' ,'~> 6.2' # YARDoc RDoc (*.rb)
|
50
|
+
spec.add_development_dependency 'redcarpet' ,'~> 3.5' # YARDoc Markdown (*.md)
|
51
|
+
spec.add_development_dependency 'yard' ,'~> 0.9' # Doc
|
46
52
|
|
47
|
-
spec.
|
53
|
+
spec.extra_rdoc_files = %w[ LICENSE.txt ]
|
48
54
|
|
49
|
-
spec.
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
spec.rdoc_options = [
|
56
|
+
'--hyperlink-all','--show-hash',
|
57
|
+
'--title',"AttrBool v#{AttrBool::VERSION} Doc",
|
58
|
+
]
|
53
59
|
end
|
data/lib/attr_bool.rb
CHANGED
@@ -3,40 +3,37 @@
|
|
3
3
|
# frozen_string_literal: true
|
4
4
|
|
5
5
|
#--
|
6
|
-
# This file is part of
|
6
|
+
# This file is part of AttrBool.
|
7
7
|
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# AttrBool is free software: you can redistribute it and/or modify it under
|
10
10
|
# the terms of the MIT License.
|
11
11
|
#
|
12
|
-
# You should have received a copy of the MIT License along with
|
12
|
+
# You should have received a copy of the MIT License along with AttrBool.
|
13
13
|
# If not, see <https://choosealicense.com/licenses/mit/>.
|
14
14
|
#++
|
15
15
|
|
16
16
|
|
17
17
|
require 'attr_bool/version'
|
18
18
|
|
19
|
-
|
20
19
|
###
|
21
|
-
# Benchmarks are kind of meaningless, but after playing around with some,
|
22
|
-
# I found the following to be the case on my system:
|
23
|
-
# - +define_method+ is faster than +module_eval+ & +class_eval+
|
24
|
-
# - +? true : false+ (ternary operator) is faster than +!!+ (surprisingly)
|
25
|
-
#
|
26
|
-
# To run benchmark code:
|
27
|
-
# $ bundle exec rake benchmark
|
28
|
-
#
|
29
20
|
# @author Jonathan Bradley Whited (@esotericpig)
|
30
21
|
# @since 0.1.0
|
31
22
|
###
|
32
23
|
module AttrBool
|
33
24
|
###
|
34
|
-
#
|
25
|
+
# Benchmarks are kind of meaningless, but after playing around with some,
|
26
|
+
# I found the following to be the case on my system:
|
27
|
+
# - +define_method+ is faster than +module_eval+ & +class_eval+
|
28
|
+
# - +? true : false+ (ternary operator) is faster than +!!+ (surprisingly)
|
29
|
+
#
|
30
|
+
# To run benchmark code:
|
31
|
+
# $ bundle exec rake benchmark
|
35
32
|
#
|
36
33
|
# @author Jonathan Bradley Whited (@esotericpig)
|
37
|
-
# @since 0.
|
34
|
+
# @since 0.2.0
|
38
35
|
###
|
39
|
-
module
|
36
|
+
module Ext
|
40
37
|
def attr_accessor?(*var_ids,default: nil,reader: nil,writer: nil,&block)
|
41
38
|
if block
|
42
39
|
reader = block if reader.nil?()
|
@@ -188,40 +185,5 @@ module AttrBool
|
|
188
185
|
end
|
189
186
|
end
|
190
187
|
end
|
191
|
-
|
192
|
-
# @!macro attach attr_reader?
|
193
|
-
# @!method $1?
|
194
|
-
# @return [Boolean] whether +$1+ or not
|
195
|
-
|
196
|
-
# @!macro attach attr_writer?
|
197
|
-
# @!method $1=(value)
|
198
|
-
# Sets +$1+ to +true+ or +false+.
|
199
|
-
# @param value [Boolean] the new value of +$1+
|
200
|
-
|
201
|
-
# @!macro attach attr_accessor?
|
202
|
-
# @!method $1?
|
203
|
-
# @!macro attach attr_reader?
|
204
|
-
# @!method $1=(value)
|
205
|
-
# @!macro attach attr_writer?
|
206
|
-
|
207
|
-
# @!macro attach attr_bool?
|
208
|
-
# @!method $1?
|
209
|
-
# @return [true,false] whether +$1+ or not
|
210
|
-
|
211
|
-
# @!macro attach attr_booler
|
212
|
-
# @!method $1=(value)
|
213
|
-
# Sets +$1+ to +true+ or +false+.
|
214
|
-
# @param value [true,false] the new value of +$1+
|
215
|
-
|
216
|
-
# @!macro attach attr_bool
|
217
|
-
# @!method $1?
|
218
|
-
# @!macro attach attr_bool?
|
219
|
-
# @!method $1=(value)
|
220
|
-
# @!macro attach attr_booler
|
221
|
-
|
222
|
-
# @!macro attach attr_boolor
|
223
|
-
# @!macro attach attr_bool
|
224
188
|
end
|
225
189
|
end
|
226
|
-
|
227
|
-
Module.prepend AttrBool::ModuleExt
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
#--
|
6
|
+
# This file is part of AttrBool.
|
7
|
+
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
8
|
+
#
|
9
|
+
# AttrBool is free software: you can redistribute it and/or modify it under
|
10
|
+
# the terms of the MIT License.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the MIT License along with AttrBool.
|
13
|
+
# If not, see <https://choosealicense.com/licenses/mit/>.
|
14
|
+
#++
|
15
|
+
|
16
|
+
|
17
|
+
require 'attr_bool'
|
18
|
+
|
19
|
+
module AttrBool
|
20
|
+
###
|
21
|
+
# @author Jonathan Bradley Whited (@esotericpig)
|
22
|
+
# @since 0.2.0
|
23
|
+
###
|
24
|
+
module CoreExt
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# This works for both +class+ & +module+ because +class+ extends +module+.
|
29
|
+
Module.prepend AttrBool::Ext
|
data/lib/attr_bool/version.rb
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
# frozen_string_literal: true
|
4
4
|
|
5
5
|
#--
|
6
|
-
# This file is part of
|
6
|
+
# This file is part of AttrBool.
|
7
7
|
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# AttrBool is free software: you can redistribute it and/or modify it under
|
10
10
|
# the terms of the MIT License.
|
11
11
|
#
|
12
|
-
# You should have received a copy of the MIT License along with
|
12
|
+
# You should have received a copy of the MIT License along with AttrBool.
|
13
13
|
# If not, see <https://choosealicense.com/licenses/mit/>.
|
14
14
|
#++
|
15
15
|
|
16
16
|
|
17
17
|
module AttrBool
|
18
|
-
VERSION = '0.
|
18
|
+
VERSION = '0.2.0'
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_bool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Bradley Whited (@esotericpig)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '13.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rdoc
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '6.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '6.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: redcarpet
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.5'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.5'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: yard
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,24 +101,30 @@ email:
|
|
73
101
|
- bradley@esotericpig.com
|
74
102
|
executables: []
|
75
103
|
extensions: []
|
76
|
-
extra_rdoc_files:
|
104
|
+
extra_rdoc_files:
|
105
|
+
- LICENSE.txt
|
77
106
|
files:
|
78
107
|
- Gemfile
|
79
108
|
- LICENSE.txt
|
80
109
|
- Rakefile
|
81
110
|
- attr_bool.gemspec
|
82
111
|
- lib/attr_bool.rb
|
112
|
+
- lib/attr_bool/core_ext.rb
|
83
113
|
- lib/attr_bool/version.rb
|
84
114
|
homepage: https://github.com/esotericpig/attr_bool
|
85
115
|
licenses:
|
86
116
|
- MIT
|
87
117
|
metadata:
|
88
|
-
bug_tracker_uri: https://github.com/esotericpig/attr_bool/issues
|
89
|
-
changelog_uri: https://github.com/esotericpig/attr_bool/blob/master/CHANGELOG.md
|
90
118
|
homepage_uri: https://github.com/esotericpig/attr_bool
|
91
119
|
source_code_uri: https://github.com/esotericpig/attr_bool
|
120
|
+
bug_tracker_uri: https://github.com/esotericpig/attr_bool/issues
|
121
|
+
changelog_uri: https://github.com/esotericpig/attr_bool/blob/master/CHANGELOG.md
|
92
122
|
post_install_message:
|
93
|
-
rdoc_options:
|
123
|
+
rdoc_options:
|
124
|
+
- "--hyperlink-all"
|
125
|
+
- "--show-hash"
|
126
|
+
- "--title"
|
127
|
+
- AttrBool v0.2.0 Doc
|
94
128
|
require_paths:
|
95
129
|
- lib
|
96
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|