y_support 2.1.13 → 2.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/y_support/core_ext/symbol/misc.rb +2 -0
- data/lib/y_support/name_magic.rb +16 -14
- data/lib/y_support/version.rb +1 -1
- data/test/abstract_algebra_test.rb +2 -0
- data/test/performance_test_example.rb +23 -0
- data/y_support.gemspec +1 -1
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c623135aae2815fd50d9fc441039ea15246b18ec
|
4
|
+
data.tar.gz: b3c7b0e2085623d4144fa9d7819c9413cd9d1a6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 727a7aed54b1bcbdc912059c5a37d388c6746a697ed389e1bc3e43d942533988da8c7ad569d3ac73f0f1764a1222450092502e01c2a1f3bcc68d7b3f1bd76148
|
7
|
+
data.tar.gz: c8cfe09d50fee1df7bd1917bfb8965867657635d3e7136ab907a0cbbe0cb99fe6850d60d9c139f39ee75f437a78b2601ac7bcf0be985f9767e83a2372c083095
|
data/lib/y_support/name_magic.rb
CHANGED
@@ -11,29 +11,32 @@ require_relative 'name_magic/hash'
|
|
11
11
|
# for "name" ins YSupport). One can write:
|
12
12
|
#
|
13
13
|
# require 'y_support/name_magic'
|
14
|
-
# class Foo;
|
14
|
+
# class Foo;
|
15
|
+
# include NameMagic
|
16
|
+
# end
|
15
17
|
# Bar = Foo.new
|
16
18
|
#
|
17
|
-
#
|
19
|
+
# The resulting object will know its +#name+:
|
20
|
+
#
|
21
|
+
# Bar.name #=> "Bar"
|
18
22
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
23
|
+
# This is done by searching whole Ruby namespace for constants, via #const_magic
|
24
|
+
# defined in the namespace mixin. (Once the object is named, its assignments to
|
25
|
+
# other constants have no further effects.) By default, the class, in which
|
26
|
+
# NameMagic is included acts as a namespace: holds a list of instances and their
|
27
|
+
# names, which is often useful.
|
22
28
|
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# is the class, in which NameMagic is included, but it is possible to prescribe
|
27
|
-
# another module as a namespace:
|
29
|
+
# Foo.instances #=> [Bar]
|
30
|
+
#
|
31
|
+
# It is possible to set another module as namespace:
|
28
32
|
#
|
29
33
|
# Quux = Module.new
|
30
34
|
# class FooBar
|
31
35
|
# include NameMagic
|
32
|
-
# self.namespace = Quux
|
33
36
|
# end
|
37
|
+
# FooBar.namespace = Quux
|
34
38
|
# FooBar.new name: "Baz"
|
35
|
-
#
|
36
|
-
# Quux::Baz #=> <FooBar:0x.....>
|
39
|
+
# Quux.instances #=> [Baz]
|
37
40
|
#
|
38
41
|
# When subclassing the classes with NameMagic included, namespace setting does
|
39
42
|
# not change:
|
@@ -205,4 +208,3 @@ module NameMagic
|
|
205
208
|
namespace.validate_name( ɴ ).to_sym.tap { |ɴ| name_set_hook.( ɴ ) }
|
206
209
|
end
|
207
210
|
end # module NameMagic
|
208
|
-
|
data/lib/y_support/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/benchmark'
|
5
|
+
|
6
|
+
class TestCoreMethods < Minitest::Benchmark
|
7
|
+
def setup
|
8
|
+
@arrays = ( 1 .. 11_000 ).map { |n| [ 42 ] * n }
|
9
|
+
end
|
10
|
+
|
11
|
+
# Override self.bench_range or default range is [1, 10, 100, 1_000, 10_000]
|
12
|
+
def bench_size
|
13
|
+
assert_performance_linear 0.99 do |n| ( [ 0 ] * n ).reduce :+ end
|
14
|
+
assert_performance_constant 0.99 do |n| 42.times { 42 } end
|
15
|
+
# assert_performance_linear 0.99 do |n| @arrays[ n ].size end
|
16
|
+
assert_performance_constant 0.99 do |n| @arrays[ n ].size end
|
17
|
+
# TODO: For some reason, assert_performance_constant doesn't fail even if
|
18
|
+
# I artificially introduce eg. quadratic algorithm. All the while, the
|
19
|
+
# line assert_performance_linear does fail if uncommented (since the perf.
|
20
|
+
# here is constant).
|
21
|
+
# TODO: In other words, I'm not very experienced in performance testing yet.
|
22
|
+
end
|
23
|
+
end
|
data/y_support.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["boris"]
|
10
10
|
spec.email = ["\"boris@iis.sinica.edu.tw\""]
|
11
11
|
spec.summary = %q{Support library used by Y gems.}
|
12
|
-
spec.description = %q{
|
12
|
+
spec.description = %q{Methods and assets of general utility. NameMagic, core extensions, typing etc.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "GPLv3"
|
15
15
|
|
metadata
CHANGED
@@ -1,80 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: y_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.6'
|
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
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: shoulda
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
70
|
-
|
69
|
+
description: Methods and assets of general utility. NameMagic, core extensions, typing
|
70
|
+
etc.
|
71
71
|
email:
|
72
72
|
- '"boris@iis.sinica.edu.tw"'
|
73
73
|
executables: []
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
77
|
+
- ".gitignore"
|
78
78
|
- Gemfile
|
79
79
|
- LICENSE.txt
|
80
80
|
- README.md
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- test/misc_test/test_module/fixture_class.rb
|
140
140
|
- test/name_magic_test.rb
|
141
141
|
- test/null_object_test.rb
|
142
|
+
- test/performance_test_example.rb
|
142
143
|
- test/respond_to_test.rb
|
143
144
|
- test/try_test.rb
|
144
145
|
- test/typing_test.rb
|
@@ -155,17 +156,17 @@ require_paths:
|
|
155
156
|
- lib
|
156
157
|
required_ruby_version: !ruby/object:Gem::Requirement
|
157
158
|
requirements:
|
158
|
-
- -
|
159
|
+
- - ">="
|
159
160
|
- !ruby/object:Gem::Version
|
160
161
|
version: '0'
|
161
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
163
|
requirements:
|
163
|
-
- -
|
164
|
+
- - ">="
|
164
165
|
- !ruby/object:Gem::Version
|
165
166
|
version: '0'
|
166
167
|
requirements: []
|
167
168
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.2.2
|
169
170
|
signing_key:
|
170
171
|
specification_version: 4
|
171
172
|
summary: Support library used by Y gems.
|
@@ -178,6 +179,7 @@ test_files:
|
|
178
179
|
- test/misc_test/test_module/fixture_class.rb
|
179
180
|
- test/name_magic_test.rb
|
180
181
|
- test/null_object_test.rb
|
182
|
+
- test/performance_test_example.rb
|
181
183
|
- test/respond_to_test.rb
|
182
184
|
- test/try_test.rb
|
183
185
|
- test/typing_test.rb
|