y_support 2.0.28 → 2.0.29

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
  SHA1:
3
- metadata.gz: 6b1639844409b11e7f45fc554f83432734d3e3ee
4
- data.tar.gz: dd9233d2232ba3a36234142c6764af894fbbf012
3
+ metadata.gz: d0bd1b8b70060322aaea75ad11f07890adef799e
4
+ data.tar.gz: 9918e56fbed551dd5051067d92af30e3a4cd9e9e
5
5
  SHA512:
6
- metadata.gz: d7f43e4b30f3279ac854cb646e1171825397ada05f28b78b78422a28da00717df3d58db26326d34755d823be27951f69631efa948253c972d204a11f59ce0d7b
7
- data.tar.gz: 4875cda1e30239bedd021042bd1972e98d21453099676d3b690e239855f24f07a244737190edb61043ec42fa3306b051f6a517518aae4c4b6f563edc7e2151d5
6
+ metadata.gz: 0275a6c4b90096fcc9299e7bd1bed593319045e46818b9a848dd67bf84f3b1f8463dd75177856ffc46cd54efe2d53c5d88e10c8b8337c2a7b2d1c2b3f90936bd
7
+ data.tar.gz: fdeb2cbfe9c079b0d493c13557c72ad6dc909d7a9329bf7ad605ae3202ad52bcfcb6b82b16df29d5fa4ec4d0669c0161e8b7cc4748e2cfa3e57b107893d2c733
@@ -2,70 +2,89 @@
2
2
 
3
3
  require 'y_support'
4
4
 
5
- # This library sets forth 4 standard abbreviations of Ruby keywords:
5
+ # A tiny number of Unicode 1-character aliases:
6
6
  #
7
- # * <b>ç</b> – class (c with cedilla, U00E7, compose seq. [c, comma])
8
- # * <b>ⓒ</b> – singleton class (copyright sign, U00A9, compose seq. [(, c, )])
9
- # * <b>λ</b> – lambda (Greek character lambda)
10
- # * <b>Λ</b> – proc (Greek character capital lambda)
7
+ # * <b>ç</b> – class (c with cedilla, U00E7)
8
+ # * <b>ⓒ</b> – singleton class (copyright sign)
9
+ # * <b>√</b> – square root
10
+ # * <b>Σ</b> – summation
11
+ # * <b>Π</b> – product
11
12
  #
12
- # It is also encouraged that other on-letter Unicode abbreviations are
13
- # used especially for local variables:
14
- #
15
- # * <b>ɱ</b> – module (m with hook, U2C6E, compose seq. [m, j])
16
- # * <b>ꜧ</b> – hash (latin small letter heng, UA727, compose seq. [h, j])
17
- # * <b>ᴀ</b> – array (small capital A, U1D00, compose seq. [a, `])
18
- # * <b>ß</b> – symbol (German sharp s, U00DF, compose seq. [s, s])
19
- # * <b>ς</b> – string (Greek final sigma, U03C2, compose seq. [*, w])
20
- # * <b>w</b> – abbreviation for "with"
21
- # * <b>wo</b> – abbreviation for "without"
22
- #
23
- # There are, however, no defined methods using these in YSupport. In other
24
- # words, using these additional abbreviations is completely up to the goodwill
25
- # of the developer.
26
- #
27
- # ==== Note on compose sequences
28
- #
29
- # Each compose sequence has to be preceded by pressing the <compose> key.
30
- # The compose sequences comply with the standard Kragen's .XCompose file
31
- # (https://github.com/kragen/xcompose). In some cases, the needed characters
32
- # are not in Kragen's file and need to be defined manually.
33
- #
34
13
  class Object
35
14
  alias :ç :class
36
- alias :ⓒ :singleton_class
37
- alias :© :singleton_class
38
-
39
- # Square root (proxy for Math.sqrt(x)).
40
- #
41
- def √( number ); Math.sqrt( number ) end
15
+ alias singleton_class
42
16
 
43
17
  # Sum. The argument is expected to be a collection; block can be specified.
44
18
  # Basically same as chaining .reduce( :+ ) to the end; Σ() notation can be
45
19
  # more readable at times.
46
20
  #
47
- def ( collection )
21
+ def Σ( collection )
48
22
  collection.reduce { |acc, element|
49
23
  acc + ( block_given? ? yield( element ) : element )
50
24
  }
51
25
  end
52
- alias :Σ :∑
53
26
 
54
27
  # Product. The argument is expected to be a collection; block can be specified.
55
28
  # Basically same as chaining .reduce( :* ) to the end; Π() notation can be
56
29
  # more readable at times.
57
30
  #
58
- def ( collection )
31
+ def Π( collection )
59
32
  collection.reduce { |acc, element|
60
33
  acc * ( block_given? ? yield( element ) : element )
61
34
  }
62
35
  end
63
- alias :Π :∏
64
36
  end
65
37
 
38
+
39
+ # Defined aliases:
40
+ #
41
+ # * <b>★</b> – alias for include
42
+ # * <b>ç</b> for +class+ in several method names
43
+ #
66
44
  class Module
67
- alias :ç_variable_set :class_variable_set
68
- alias :ç_variable_get :class_variable_get
69
- alias :ç_variable_defined? :class_variable_defined?
70
- alias :remove_ç_variable :remove_class_variable
45
+ alias include
46
+
47
+ alias ç_variable_set class_variable_set
48
+ alias ç_variable_get class_variable_get
49
+ alias ç_variable_defined? class_variable_defined?
50
+ alias remove_ç_variable remove_class_variable
51
+ end
52
+
53
+
54
+
55
+ # Defined aliases
56
+ #
57
+ # * <b>√</b> – root of arbitrary degree ( x.√( n ) is n ** ( 1 / x ) ).
58
+ # * <b>sqrt</b> as in +4.sqrt+ for square root (Math#sqrt).
59
+ #
60
+ class Numeric
61
+ def √ number
62
+ number ** ( 1.0 / self )
63
+ end
64
+
65
+
66
+ # Square root (using Math#sqrt).
67
+ #
68
+ def sqrt
69
+ Math.sqrt( self )
70
+ end
71
71
  end
72
+
73
+
74
+ # Other abbreviations (eg. for local variables) are optionally encouraged:
75
+ #
76
+ # * <b>ɱ</b> – module (m with hook, U2C6E, compose seq. [m, j])
77
+ # * <b>ꜧ</b> – hash (latin small letter heng, UA727, compose seq. [h, j])
78
+ # * <b>ᴀ</b> – array (small capital A, U1D00, compose seq. [a, `])
79
+ # * <b>ß</b> – symbol (German sharp s, U00DF, compose seq. [s, s])
80
+ # * <b>ς</b> – string (Greek final sigma, U03C2, compose seq. [*, w])
81
+ # * <b>w</b> – abbreviation for "with"
82
+ # * <b>wo</b> – abbreviation for "without"
83
+ #
84
+ # Note on compose sequences:
85
+ #
86
+ # Each compose sequence is preceded the <compose> key, whose location depends
87
+ # on your system configuration. The sequences above comply with the standard
88
+ # Kragen's .XCompose file (https://github.com/kragen/xcompose). In some cases,
89
+ # the characters not in Kragen's file have to be defined manually for
90
+ # comfortable typing.
@@ -1,3 +1,3 @@
1
1
  module YSupport
2
- VERSION = "2.0.28"
2
+ VERSION = "2.0.29"
3
3
  end
data/test/unicode_test.rb CHANGED
@@ -1,33 +1,30 @@
1
1
  #! /usr/bin/ruby
2
2
  #encoding: utf-8
3
3
 
4
- require 'test/unit'
5
- require 'shoulda'
6
- # require 'y_support/all'
4
+ require 'minitest/spec'
5
+ require 'minitest/autorun'
7
6
 
8
- class UnicodeTest < Test::Unit::TestCase
9
- context "Object" do
10
- setup do
11
- require 'y_support/unicode'
12
- end
7
+ describe "y_support/unicode" do
8
+ before do
9
+ require 'y_support/unicode'
10
+ end
13
11
 
14
- should "have a very limited number of one-character Unicode aliases" do
15
- = Object.new
16
- assert ◉.singleton_class == ◉.©
17
- assert ◉.singleton_class == ◉.ⓒ
18
- assert ◉.ç == ◉.class
19
- assert 2 == ( 4 )
20
- assert 10 == ∑(1..4)
21
- assert 10 == Σ(1..4)
22
- assert 24 == ∏(1..4)
23
- assert 24 == Π(1..4)
24
- ɱ = Module.new
25
- ɱ.ç_variable_set :@@meaning, 42
26
- assert ɱ.class_variable_get( :@@meaning ) == 42
27
- assert ɱ.ç_variable_get( :@@meaning ) == 42
28
- assert ɱ.ç_variable_defined?( :@@meaning )
29
- ɱ.remove_ç_variable :@@meaning
30
- assert ! ɱ.ç_variable_defined?( :@@meaning )
31
- end
12
+ it "should define a tiny number of Unicode aliases" do
13
+ o = Object.new
14
+ assert o.singleton_class == o.ⓒ
15
+ assert o.ç == o.class
16
+ assert 10 == Σ(1..4)
17
+ assert 24 == Π(1..4)
18
+ 2.must_equal 4.sqrt
19
+ 3.√( 8 ).must_equal 2
20
+ ɱ = Module.new
21
+ ɱ.ç_variable_set :@@meaning, 42
22
+ assert ɱ.class_variable_get( :@@meaning ) == 42
23
+ assert ɱ.ç_variable_get( :@@meaning ) == 42
24
+ assert ɱ.ç_variable_defined?( :@@meaning )
25
+ ɱ.remove_ç_variable :@@meaning
26
+ assert ! ɱ.ç_variable_defined?( :@@meaning )
27
+ ɱ.module_exec { ★ Comparable }
28
+ assert ɱ < Comparable
32
29
  end
33
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: y_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.28
4
+ version: 2.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport