tins 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/Gemfile +2 -0
- data/README.md +25 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/examples/bb3.stm +15 -15
- data/examples/concatenate_compare.mtm +26 -26
- data/examples/length_difference.mtm +12 -12
- data/examples/let.rb +2 -2
- data/examples/ones_difference.mtm +7 -7
- data/examples/ones_difference.stm +19 -19
- data/examples/prefix-equals-suffix-reversed-with-infix.stm +33 -33
- data/examples/recipe_common.rb +0 -32
- data/lib/tins.rb +1 -2
- data/lib/tins/annotate.rb +1 -1
- data/lib/tins/ask_and_send.rb +16 -0
- data/lib/tins/case_predicate.rb +7 -0
- data/lib/tins/dslkit.rb +7 -54
- data/lib/tins/file_binary.rb +1 -3
- data/lib/tins/method_description.rb +4 -2
- data/lib/tins/null.rb +1 -1
- data/lib/tins/string_version.rb +1 -3
- data/lib/tins/terminal.rb +18 -10
- data/lib/tins/thread_local.rb +2 -3
- data/lib/tins/token.rb +4 -1
- data/lib/tins/version.rb +1 -1
- data/lib/tins/xt.rb +2 -1
- data/lib/tins/xt/case_predicate.rb +8 -0
- data/lib/tins/xt/dslkit.rb +0 -1
- data/lib/tins/xt/named.rb +14 -26
- data/lib/tins/{time_freezer.rb → xt/time_freezer.rb} +0 -0
- data/tests/ask_and_send_test.rb +14 -0
- data/tests/attempt_test.rb +0 -6
- data/tests/case_predicate_test.rb +29 -0
- data/tests/dslkit_test.rb +0 -2
- data/tests/if_predicate_test.rb +1 -1
- data/tests/method_description_test.rb +15 -2
- data/tests/test_helper.rb +4 -0
- data/tins.gemspec +7 -7
- metadata +23 -28
- data/examples/bb3_19.stm +0 -26
- data/examples/concatenate_compare_19.mtm +0 -31
- data/examples/length_difference_19.mtm +0 -17
- data/examples/ones_difference_19.mtm +0 -12
- data/examples/ones_difference_19.stm +0 -25
- data/examples/prefix-equals-suffix-reversed-with-infix_19.stm +0 -38
- data/lib/tins/round.rb +0 -51
- data/lib/tins/xt/round.rb +0 -13
- data/tests/round_test.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa1bf4ee9dea65d5c11f563451d6642c5fe1884c
|
4
|
+
data.tar.gz: 1c7146c7571c21394db79a1d390507b3895e2e44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19a5df0f5e8e5d13c1a868a369b1aa6e5ef85f75a91e37bf815c0954aefe71f4a602889ee12b37b1c12e8dce3669730ea39bd93620205391ec6012ba9eb16d53
|
7
|
+
data.tar.gz: f0d23c8f50f2638bd4d06ecd56abc6fce27036dfdc67573234f02cbe9db9fefe45c8b8ae6dfa8f3e281a35d85931b40b4d813efa31ff79b0c7077cb0d11b4283
|
data/.travis.yml
CHANGED
@@ -2,7 +2,7 @@ rvm:
|
|
2
2
|
- 1.9.2
|
3
3
|
- 1.9.3
|
4
4
|
- 2.0.0
|
5
|
-
- 2.1.
|
5
|
+
- 2.1.2
|
6
6
|
- ruby-head
|
7
7
|
- rbx-19mode
|
8
8
|
- jruby-19mode
|
@@ -11,3 +11,5 @@ matrix:
|
|
11
11
|
- rvm: ruby-head
|
12
12
|
- rvm: rbx-19mode
|
13
13
|
- rvm: jruby-19mode
|
14
|
+
env:
|
15
|
+
- CODECLIMATE_REPO_TOKEN=62d082406430ccf662c2e401976b613c0091e26fcfb546f92b1f2b391951cf50
|
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Tins - Useful tools library in Ruby
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
Non yet.
|
6
|
+
|
7
|
+
## Badges
|
8
|
+
|
9
|
+
[](https://codeclimate.com/github/flori/tins)
|
10
|
+
|
11
|
+
[](https://codeclimate.com/github/flori/tins)
|
12
|
+
|
13
|
+
## Download
|
14
|
+
|
15
|
+
The homepage of this library is located at
|
16
|
+
|
17
|
+
* http://flori.github.com/tins
|
18
|
+
|
19
|
+
## Author
|
20
|
+
|
21
|
+
Florian Frank mailto:flori@ping.de
|
22
|
+
|
23
|
+
## License
|
24
|
+
|
25
|
+
This software is licensed under the MIT (Expat) license.
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
data/examples/bb3.stm
CHANGED
@@ -5,22 +5,22 @@
|
|
5
5
|
# Busy Beaver: 3-state, 2-symbol
|
6
6
|
|
7
7
|
# state A
|
8
|
-
1. cond :
|
9
|
-
2. write :
|
10
|
-
3. right :
|
11
|
-
4. write :
|
12
|
-
5. right :
|
8
|
+
1. cond if: 'B', then: 2, else: 4
|
9
|
+
2. write symbol: '1', goto: 3
|
10
|
+
3. right goto: 6
|
11
|
+
4. write symbol: '1', goto: 5
|
12
|
+
5. right goto: 16
|
13
13
|
# state B
|
14
|
-
6. cond :
|
15
|
-
7. write :
|
16
|
-
8. right :
|
17
|
-
9. write :
|
18
|
-
10. right :
|
14
|
+
6. cond if: 'B', then: 7, else: 9
|
15
|
+
7. write symbol: 'B', goto: 8
|
16
|
+
8. right goto: 11
|
17
|
+
9. write symbol: '1', goto: 10
|
18
|
+
10. right goto: 6
|
19
19
|
# state C
|
20
|
-
11. cond :
|
21
|
-
12. write :
|
22
|
-
13. left :
|
23
|
-
14. write :
|
24
|
-
15. left :
|
20
|
+
11. cond if: 'B', then: 12, else: 14
|
21
|
+
12. write symbol: '1', goto: 13
|
22
|
+
13. left goto: 11
|
23
|
+
14. write symbol: '1', goto: 15
|
24
|
+
15. left goto: 1
|
25
25
|
# halt
|
26
26
|
16. halt
|
@@ -2,30 +2,30 @@
|
|
2
2
|
# Call with four binary numbers on the tape:
|
3
3
|
# $ turing.rb concatenate_compare.mtm 110 1 11 01
|
4
4
|
|
5
|
-
1. right 1, :
|
6
|
-
2. cond 1, :
|
7
|
-
3. right 2, :
|
8
|
-
4. cond 2, :
|
9
|
-
5. cond 2, :
|
10
|
-
6. write 1, :
|
11
|
-
7. write 1, :
|
12
|
-
8. right 1, :
|
13
|
-
9. right 3, :
|
14
|
-
10. cond 3, :
|
15
|
-
11. right 4, :
|
16
|
-
12. cond 4, :
|
17
|
-
13. cond 4, :
|
18
|
-
14. write 3, :
|
19
|
-
15. write 3, :
|
20
|
-
16. right 3, :
|
21
|
-
17. left 3, :
|
22
|
-
18. left 1, :
|
23
|
-
19. cond 3, :
|
24
|
-
20. cond 1, :
|
25
|
-
21. cond 1, :
|
26
|
-
22. cond 3, :
|
27
|
-
23. cond 1, :
|
28
|
-
24. write 0, :
|
29
|
-
25. write 0, :
|
30
|
-
26. right 0, :
|
5
|
+
1. right 1, goto: 2
|
6
|
+
2. cond 1, if: 'B', then: 3, else: 1
|
7
|
+
3. right 2, goto: 4
|
8
|
+
4. cond 2, if: '0', then: 7, else: 5
|
9
|
+
5. cond 2, if: '1', then: 6, else: 9
|
10
|
+
6. write 1, symbol: '1', goto: 8
|
11
|
+
7. write 1, symbol: '0', goto: 8
|
12
|
+
8. right 1, goto: 3
|
13
|
+
9. right 3, goto: 10
|
14
|
+
10. cond 3, if: 'B', then: 11, else: 9
|
15
|
+
11. right 4, goto: 12
|
16
|
+
12. cond 4, if: '0', then: 14, else: 13
|
17
|
+
13. cond 4, if: '1', then: 15, else: 17
|
18
|
+
14. write 3, symbol: '0', goto: 16
|
19
|
+
15. write 3, symbol: '1', goto: 16
|
20
|
+
16. right 3, goto: 11
|
21
|
+
17. left 3, goto: 18
|
22
|
+
18. left 1, goto: 19
|
23
|
+
19. cond 3, if: '0', then: 20, else: 22
|
24
|
+
20. cond 1, if: '0', then: 17, else: 24
|
25
|
+
21. cond 1, if: '1', then: 17, else: 24
|
26
|
+
22. cond 3, if: '1', then: 21, else: 23
|
27
|
+
23. cond 1, if: 'B', then: 25, else: 24
|
28
|
+
24. write 0, symbol: '0', goto: 26
|
29
|
+
25. write 0, symbol: '1', goto: 26
|
30
|
+
26. right 0, goto: 27
|
31
31
|
27. halt
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# Call with two [ab]* strings on the tapes:
|
3
3
|
# $ turing.rb prefix-equals-suffix-reversed-with-infix.stm ab ababab
|
4
4
|
|
5
|
-
1. right 1, :
|
6
|
-
2. right 2, :
|
7
|
-
3. cond 1, :
|
8
|
-
4. cond 2, :
|
9
|
-
5. cond 2, :
|
10
|
-
6. write 0, :
|
11
|
-
7. right 0, :
|
12
|
-
8. right 2, :
|
13
|
-
9. write 0, :
|
14
|
-
10. right 0, :
|
15
|
-
11. right 1, :
|
16
|
-
12. cond 1, :
|
5
|
+
1. right 1, goto: 2
|
6
|
+
2. right 2, goto: 3
|
7
|
+
3. cond 1, if: 'B', then: 5, else: 4
|
8
|
+
4. cond 2, if: 'B', then: 9, else: 1
|
9
|
+
5. cond 2, if: 'B', then: 13, else: 6
|
10
|
+
6. write 0, symbol: 'b', goto: 7
|
11
|
+
7. right 0, goto: 8
|
12
|
+
8. right 2, goto: 5
|
13
|
+
9. write 0, symbol: 'a', goto: 10
|
14
|
+
10. right 0, goto: 11
|
15
|
+
11. right 1, goto: 12
|
16
|
+
12. cond 1, if: 'B', then: 13, else: 9
|
17
17
|
13. halt
|
data/examples/let.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# Call with two strings of ones on the tape:
|
3
3
|
# $ turing.rb ones_difference.mtm 1111 11
|
4
4
|
|
5
|
-
0. right 1, :
|
6
|
-
1. right 2, :
|
7
|
-
2. cond 1, :
|
8
|
-
3. cond 2, :
|
9
|
-
4. cond 2, :
|
10
|
-
5. write 0, :
|
11
|
-
6. left 0, :
|
5
|
+
0. right 1, goto: 1
|
6
|
+
1. right 2, goto: 2
|
7
|
+
2. cond 1, if: '1', then: 3, else: 4
|
8
|
+
3. cond 2, if: '1', then: 0, else: 5
|
9
|
+
4. cond 2, if: '1', then: 5, else: 7
|
10
|
+
5. write 0, symbol: '1', goto: 6
|
11
|
+
6. left 0, goto: 0
|
12
12
|
7. halt
|
@@ -2,24 +2,24 @@
|
|
2
2
|
# Call with two strings of ones on the tape:
|
3
3
|
# $ turing.rb ones_difference.stm 1111 11
|
4
4
|
|
5
|
-
1. right :
|
6
|
-
2. cond :
|
7
|
-
3. right :
|
8
|
-
4. cond :
|
9
|
-
5. right :
|
10
|
-
6. cond :
|
11
|
-
7. left :
|
12
|
-
8. write :
|
13
|
-
9. left :
|
14
|
-
10. cond :
|
15
|
-
11. left :
|
16
|
-
12. cond :
|
17
|
-
13. right :
|
18
|
-
14. cond :
|
19
|
-
15. write :
|
20
|
-
16. write :
|
21
|
-
17. left :
|
22
|
-
18. right :
|
23
|
-
19. cond :
|
5
|
+
1. right goto: 2
|
6
|
+
2. cond if: '1', then: 1, else: 3
|
7
|
+
3. right goto: 4
|
8
|
+
4. cond if: '1', then: 5, else: 17
|
9
|
+
5. right goto: 6
|
10
|
+
6. cond if: '1', then: 5, else: 7
|
11
|
+
7. left goto: 8
|
12
|
+
8. write symbol: 'B', goto: 9
|
13
|
+
9. left goto: 10
|
14
|
+
10. cond if: '1', then: 9, else: 11
|
15
|
+
11. left goto: 12
|
16
|
+
12. cond if: '1', then: 11, else: 13
|
17
|
+
13. right goto: 14
|
18
|
+
14. cond if: '1', then: 15, else: 16
|
19
|
+
15. write symbol: 'B', goto: 1
|
20
|
+
16. write symbol: '1', goto: 18
|
21
|
+
17. left goto: 20
|
22
|
+
18. right goto: 19
|
23
|
+
19. cond if: '1', then: 18, else: 21
|
24
24
|
20. halt
|
25
25
|
21. halt
|
@@ -2,37 +2,37 @@
|
|
2
2
|
# Call with a binary number on the tape:
|
3
3
|
# $ turing.rb prefix-equals-suffix-reversed-with-infix.stm 100101001
|
4
4
|
|
5
|
-
0. right :
|
6
|
-
1. cond :
|
7
|
-
2. write :
|
8
|
-
3. right :
|
9
|
-
4. cond :
|
10
|
-
5. right :
|
11
|
-
6. cond :
|
12
|
-
7. left :
|
13
|
-
8. cond :
|
14
|
-
9. write :
|
15
|
-
10. left :
|
16
|
-
11. cond :
|
17
|
-
12. cond :
|
18
|
-
13. cond :
|
19
|
-
14. write :
|
20
|
-
15. right :
|
21
|
-
16. cond :
|
22
|
-
17. right :
|
23
|
-
18. cond :
|
24
|
-
19. left :
|
25
|
-
20. cond :
|
26
|
-
21. write :
|
27
|
-
22. left :
|
28
|
-
23. cond :
|
29
|
-
24. cond :
|
30
|
-
25. write :
|
31
|
-
26. left :
|
32
|
-
27. cond :
|
33
|
-
28. cond :
|
34
|
-
29. write :
|
35
|
-
30. write :
|
5
|
+
0. right goto: 1
|
6
|
+
1. cond if: '0', then: 2, else: 13
|
7
|
+
2. write symbol: 'O', goto: 3
|
8
|
+
3. right goto: 4
|
9
|
+
4. cond if: 'B', then: 21, else: 5
|
10
|
+
5. right goto: 6
|
11
|
+
6. cond if: 'B', then: 7, else: 5
|
12
|
+
7. left goto: 8
|
13
|
+
8. cond if: '0', then: 9, else: 21
|
14
|
+
9. write symbol: 'B', goto: 10
|
15
|
+
10. left goto: 11
|
16
|
+
11. cond if: '0', then: 10, else: 12
|
17
|
+
12. cond if: '1', then: 10, else: 0
|
18
|
+
13. cond if: '1', then: 14, else: 31
|
19
|
+
14. write symbol: 'I', goto: 15
|
20
|
+
15. right goto: 16
|
21
|
+
16. cond if: 'B', then: 21, else: 17
|
22
|
+
17. right goto: 18
|
23
|
+
18. cond if: 'B', then: 19, else: 17
|
24
|
+
19. left goto: 20
|
25
|
+
20. cond if: '1', then: 9, else: 21
|
26
|
+
21. write symbol: 'B', goto: 22
|
27
|
+
22. left goto: 23
|
28
|
+
23. cond if: '0', then: 21, else: 24
|
29
|
+
24. cond if: '1', then: 21, else: 25
|
30
|
+
25. write symbol: 'B', goto: 26
|
31
|
+
26. left goto: 27
|
32
|
+
27. cond if: 'O', then: 29, else: 28
|
33
|
+
28. cond if: 'I', then: 30, else: 32
|
34
|
+
29. write symbol: '0', goto: 26
|
35
|
+
30. write symbol: '1', goto: 26
|
36
36
|
31. halt
|
37
|
-
32. right :
|
38
|
-
33. cond :
|
37
|
+
32. right goto: 33
|
38
|
+
33. cond if: 'B', then: 31, else: 32
|
data/examples/recipe_common.rb
CHANGED
@@ -63,35 +63,3 @@ class Unit
|
|
63
63
|
"#@n #{name}#{@n > 1 ? 's' : ''}"
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
67
|
-
class Unit
|
68
|
-
class << self
|
69
|
-
def inherited(klass)
|
70
|
-
units << klass
|
71
|
-
end
|
72
|
-
|
73
|
-
attr_accessor :units
|
74
|
-
|
75
|
-
def unit(name, amount)
|
76
|
-
name = name.to_s.gsub(/s$/, '').capitalize
|
77
|
-
if klass = units.find { |n| n.to_s == name }
|
78
|
-
klass.new(amount)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
self.units = []
|
83
|
-
|
84
|
-
def initialize(n = 1)
|
85
|
-
@n = n
|
86
|
-
end
|
87
|
-
|
88
|
-
def name
|
89
|
-
self.class.name.downcase
|
90
|
-
end
|
91
|
-
|
92
|
-
attr_reader :n
|
93
|
-
|
94
|
-
def to_s
|
95
|
-
"#@n #{name}#{@n > 1 ? 's' : ''}"
|
96
|
-
end
|
97
|
-
end
|
data/lib/tins.rb
CHANGED
@@ -20,7 +20,6 @@ module Tins
|
|
20
20
|
require 'tins/partial_application'
|
21
21
|
require 'tins/range_plus'
|
22
22
|
require 'tins/require_maybe'
|
23
|
-
require 'tins/round'
|
24
23
|
require 'tins/secure_write'
|
25
24
|
require 'tins/shuffle'
|
26
25
|
require 'tins/string_camelize'
|
@@ -30,7 +29,6 @@ module Tins
|
|
30
29
|
require 'tins/time_dummy'
|
31
30
|
require 'tins/date_dummy'
|
32
31
|
require 'tins/date_time_dummy'
|
33
|
-
require 'tins/time_freezer'
|
34
32
|
require 'tins/to_proc'
|
35
33
|
require 'tins/uniq_by'
|
36
34
|
require 'tins/version'
|
@@ -49,6 +47,7 @@ module Tins
|
|
49
47
|
require 'tins/annotate'
|
50
48
|
require 'tins/token'
|
51
49
|
require 'tins/dslkit'
|
50
|
+
require 'tins/case_predicate'
|
52
51
|
if defined? ::Encoding
|
53
52
|
require 'tins/string_byte_order_mark'
|
54
53
|
end
|
data/lib/tins/annotate.rb
CHANGED
data/lib/tins/ask_and_send.rb
CHANGED
@@ -11,5 +11,21 @@ module Tins
|
|
11
11
|
__send__(method_name, *args, &block)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def ask_and_send_or_self(method_name, *args, &block)
|
16
|
+
if respond_to?(method_name)
|
17
|
+
__send__(method_name, *args, &block)
|
18
|
+
else
|
19
|
+
self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def ask_and_send_or_self!(method_name, *args, &block)
|
24
|
+
if respond_to?(method_name, true)
|
25
|
+
__send__(method_name, *args, &block)
|
26
|
+
else
|
27
|
+
self
|
28
|
+
end
|
29
|
+
end
|
14
30
|
end
|
15
31
|
end
|