rdx 0.9.0.pre
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 +7 -0
- data/.rdx +20 -0
- data/README +19 -0
- data/bin/rdx +7 -0
- data/examples/minimal/.rdx +8 -0
- data/examples/minimal/README +10 -0
- data/examples/minimal/lib/other_conventions.rb +64 -0
- data/examples/minimal/lib/the_basics.rb +94 -0
- data/examples/minimal/lib/using_directives.rb +66 -0
- data/examples/minimal/rakefile +27 -0
- data/examples/ruby-2.0.0-p0/README +7 -0
- data/examples/ruby-2.0.0-p0/install/core/.rdx +6 -0
- data/examples/ruby-2.0.0-p0/install/core/README +19 -0
- data/examples/ruby-2.0.0-p0/install/core/Rakefile +61 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/array.c.diff +166 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/bignum.c.diff +11 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/class.c.diff +36 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/compar.c.diff +11 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/complex.c.diff +301 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/cont.c.diff +65 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/dir.c.diff +147 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/re.rdoc.diff +328 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/security.rdoc.diff +8 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/standard_library.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/assignment.rdoc.diff +160 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/calling_methods.rdoc.diff +130 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/control_expressions.rdoc.diff +254 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/exceptions.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/literals.rdoc.diff +54 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/methods.rdoc.diff +157 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/miscellaneous.rdoc.diff +91 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/modules_and_classes.rdoc.diff +161 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/precedence.rdoc.diff +8 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/refinements.rdoc.diff +146 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/encoding.c.diff +276 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/enum.c.diff +281 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/enumerator.c.diff +479 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/error.c.diff +143 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/eval.c.diff +47 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/eval_jump.c.diff +23 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/file.c.diff +752 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/gc.c.diff +195 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/hash.c.diff +84 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/iseq.c.diff +354 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/load.c.diff +53 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/marshal.c.diff +98 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/math.c.diff +110 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/numeric.c.diff +103 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/object.c.diff +295 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/pack.c.diff +18 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/parse.y.diff +23 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/proc.c.diff +155 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/random.c.diff +126 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/range.c.diff +49 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/rational.c.diff +312 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/re.c.diff +207 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/ruby.c.diff +21 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/signal.c.diff +67 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/sprintf.c.diff +29 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/string.c.diff +73 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/struct.c.diff +20 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/time.c.diff +691 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/transcode.c.diff +435 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/variable.c.diff +62 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_backtrace.c.diff +164 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_eval.c.diff +99 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_method.c.diff +17 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_trace.c.diff +393 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/.rdx +6 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/README +19 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/Rakefile +53 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/abbrev.rb.diff +77 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/base64.rb.diff +42 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/benchmark.rb.diff +144 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/cmath.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/forwardable.rb.diff +150 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/mathn.rb.diff +58 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/matrix.rb.diff +657 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/observer.rb.diff +31 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/optparse.rb.diff +147 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/ostruct.rb.diff +78 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/prime.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/pstore.rb.diff +110 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/scanf.rb.diff +100 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/securerandom.rb.diff +144 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/set.rb.diff +637 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/shellwords.rb.diff +66 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/singleton.rb.diff +37 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/tempfile.rb.diff +104 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/thread.rb.diff +38 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/time.rb.diff +140 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/tmpdir.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/uri.rb.diff +39 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/uri/common.rb.diff +237 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/weakref.rb.diff +36 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/yaml/store.rb.diff +27 -0
- data/examples/ruby-2.0.0-p0/rakefile +165 -0
- data/lib/rdx.rb +331 -0
- data/lib/rdx/assertions.rb +484 -0
- data/lib/rdx/binding.rb +151 -0
- data/lib/rdx/code_object.rb +598 -0
- data/lib/rdx/comment.rb +338 -0
- data/lib/rdx/convention.rb +1174 -0
- data/lib/rdx/directive.rb +1432 -0
- data/lib/rdx/example.rb +679 -0
- data/lib/rdx/generator.rb +112 -0
- data/lib/rdx/generator/rdoc.rb +1006 -0
- data/lib/rdx/options.rb +359 -0
- data/lib/rdx/plain_text.rb +65 -0
- data/lib/rdx/reporter.rb +421 -0
- data/lib/rdx/ruby_lex.rb +324 -0
- data/lib/rdx/runner.rb +309 -0
- data/lib/rdx/source_file.rb +94 -0
- data/lib/rdx/specification.rb +194 -0
- data/lib/rdx/statement.rb +248 -0
- data/lib/rdx/store.rb +119 -0
- data/lib/rdx/task.rb +361 -0
- data/lib/rdx/text.rb +688 -0
- data/lib/rdx/version.rb +15 -0
- data/rakefile +64 -0
- metadata +203 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
--- stdlib/orig/lib/observer.rb 2015-06-11 07:51:45 +0000
|
2
|
+
+++ stdlib/patched/lib/observer.rb 2015-06-25 16:12:19 +0000
|
3
|
+
@@ -38,7 +38,8 @@
|
4
|
+
# observer) is not declared or enforced. The +Ticker+ publishes a time and a
|
5
|
+
# price, and the warners receive that. But if you don't ensure that your
|
6
|
+
# contracts are correct, nothing else can warn you.
|
7
|
+
-#
|
8
|
+
+#
|
9
|
+
+# :rdx: is_slow
|
10
|
+
# require "observer"
|
11
|
+
#
|
12
|
+
# class Ticker ### Periodically fetch a stock price.
|
13
|
+
@@ -50,7 +51,7 @@
|
14
|
+
#
|
15
|
+
# def run
|
16
|
+
# lastPrice = nil
|
17
|
+
-# loop do
|
18
|
+
+# 5.times do
|
19
|
+
# price = Price.fetch(@symbol)
|
20
|
+
# print "Current price: #{price}\n"
|
21
|
+
# if price != lastPrice
|
22
|
+
@@ -97,7 +98,8 @@
|
23
|
+
# WarnHigh.new(ticker, 120)
|
24
|
+
# ticker.run
|
25
|
+
#
|
26
|
+
-# Produces:
|
27
|
+
+# Produces something like:
|
28
|
+
+# :rdx: indicative_output
|
29
|
+
#
|
30
|
+
# Current price: 83
|
31
|
+
# Current price: 75
|
@@ -0,0 +1,147 @@
|
|
1
|
+
--- stdlib/orig/lib/optparse.rb 2015-06-11 07:51:45 +0000
|
2
|
+
+++ stdlib/patched/lib/optparse.rb 2015-06-11 07:51:48 +0000
|
3
|
+
@@ -68,19 +68,35 @@
|
4
|
+
#
|
5
|
+
# === Minimal example
|
6
|
+
#
|
7
|
+
+# # File: example.rb
|
8
|
+
# require 'optparse'
|
9
|
+
#
|
10
|
+
# options = {}
|
11
|
+
# OptionParser.new do |opts|
|
12
|
+
-# opts.banner = "Usage: example.rb [options]"
|
13
|
+
+# opts.banner = "Usage: example.rb [options] [arguments...]"
|
14
|
+
#
|
15
|
+
# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
16
|
+
# options[:verbose] = v
|
17
|
+
# end
|
18
|
+
# end.parse!
|
19
|
+
#
|
20
|
+
-# p options
|
21
|
+
-# p ARGV
|
22
|
+
+# puts "options = #{options}"
|
23
|
+
+# puts "ARGV = #{ARGV}"
|
24
|
+
+#
|
25
|
+
+# We give options from the command line:
|
26
|
+
+#
|
27
|
+
+# $ ruby example.rb
|
28
|
+
+# options = {}
|
29
|
+
+# ARGV = []
|
30
|
+
+# $ ruby example.rb -h
|
31
|
+
+# Usage: example.rb [options] [arguments...]
|
32
|
+
+# -v, --[no-]verbose Run verbosely
|
33
|
+
+# $ ruby example.rb -v
|
34
|
+
+# options = {:verbose=>true}
|
35
|
+
+# ARGV = []
|
36
|
+
+# $ ruby example.rb --no-verbose arg1
|
37
|
+
+# options = {:verbose=>false}
|
38
|
+
+# ARGV = ["arg1"]
|
39
|
+
#
|
40
|
+
# === Complete example
|
41
|
+
#
|
42
|
+
@@ -88,6 +104,8 @@
|
43
|
+
# effect of specifying various options. This is probably the best way to learn
|
44
|
+
# the features of +optparse+.
|
45
|
+
#
|
46
|
+
+# # File: example_app
|
47
|
+
+# #! /usr/bin/env ruby
|
48
|
+
# require 'optparse'
|
49
|
+
# require 'optparse/time'
|
50
|
+
# require 'ostruct'
|
51
|
+
@@ -112,7 +130,7 @@
|
52
|
+
# options.verbose = false
|
53
|
+
#
|
54
|
+
# opt_parser = OptionParser.new do |opts|
|
55
|
+
-# opts.banner = "Usage: example.rb [options]"
|
56
|
+
+# opts.banner = "Usage: example_app [options] [arguments...]"
|
57
|
+
#
|
58
|
+
# opts.separator ""
|
59
|
+
# opts.separator "Specific options:"
|
60
|
+
@@ -197,8 +215,37 @@
|
61
|
+
# end # class OptparseExample
|
62
|
+
#
|
63
|
+
# options = OptparseExample.parse(ARGV)
|
64
|
+
+# print "options = "
|
65
|
+
# pp options
|
66
|
+
-# pp ARGV
|
67
|
+
+# puts "ARGV = #{ARGV}"
|
68
|
+
+#
|
69
|
+
+# Running from command line:
|
70
|
+
+#
|
71
|
+
+# $ ./example_app
|
72
|
+
+# options = #<OpenStruct library=[], inplace=false, encoding="utf8", transfer_type=:auto, verbose=false>
|
73
|
+
+# ARGV = []
|
74
|
+
+# $ ./example_app --help
|
75
|
+
+# Usage: example_app [options] [arguments...]
|
76
|
+
+#
|
77
|
+
+# Specific options:
|
78
|
+
+# -r, --require LIBRARY Require the LIBRARY before executing your script
|
79
|
+
+# -i, --inplace [EXTENSION] Edit ARGV files in place
|
80
|
+
+# (make backup if EXTENSION supplied)
|
81
|
+
+# --delay N Delay N seconds before executing
|
82
|
+
+# -t, --time [TIME] Begin execution at given time
|
83
|
+
+# -F, --irs [OCTAL] Specify record separator (default \0)
|
84
|
+
+# --list x,y,z Example 'list' of arguments
|
85
|
+
+# --code CODE Select encoding
|
86
|
+
+# (jis,sjis,iso-2022-jp,shift_jis,euc-jp,utf8,binary)
|
87
|
+
+# --type [TYPE] Select transfer type (text, binary, auto)
|
88
|
+
+# -v, --[no-]verbose Run verbosely
|
89
|
+
+#
|
90
|
+
+# Common options:
|
91
|
+
+# -h, --help Show this message
|
92
|
+
+# --version Show version
|
93
|
+
+# $ ./example_app -rset -vi --code=sjis an_argument another_argument
|
94
|
+
+# options = #<OpenStruct library=["set"], inplace=true, encoding="shift_jis", transfer_type=:auto, verbose=true, extension="">
|
95
|
+
+# ARGV = ["an_argument", "another_argument"]
|
96
|
+
#
|
97
|
+
# === Shell Completion
|
98
|
+
#
|
99
|
+
@@ -618,6 +665,7 @@
|
100
|
+
# +long_opts+:: List of long style options.
|
101
|
+
# +nolong_opts+:: List of long style options with "no-" prefix.
|
102
|
+
#
|
103
|
+
+ # :rdx: off
|
104
|
+
# prepend(switch, short_opts, long_opts, nolong_opts)
|
105
|
+
#
|
106
|
+
def prepend(*args)
|
107
|
+
@@ -634,6 +682,7 @@
|
108
|
+
# +long_opts+:: List of long style options.
|
109
|
+
# +nolong_opts+:: List of long style options with "no-" prefix.
|
110
|
+
#
|
111
|
+
+ # :rdx: off
|
112
|
+
# append(switch, short_opts, long_opts, nolong_opts)
|
113
|
+
#
|
114
|
+
def append(*args)
|
115
|
+
@@ -913,6 +962,7 @@
|
116
|
+
# +t+:: Argument class specifier, any object including Class.
|
117
|
+
# +pat+:: Pattern for argument, defaults to +t+ if it responds to match.
|
118
|
+
#
|
119
|
+
+ # :rdx: off
|
120
|
+
# accept(t, pat, &block)
|
121
|
+
#
|
122
|
+
def accept(*args, &blk) top.accept(*args, &blk) end
|
123
|
+
@@ -925,7 +975,7 @@
|
124
|
+
# Directs to reject specified class argument.
|
125
|
+
#
|
126
|
+
# +t+:: Argument class specifier, any object including Class.
|
127
|
+
- #
|
128
|
+
+ # :rdx: off
|
129
|
+
# reject(t)
|
130
|
+
#
|
131
|
+
def reject(*args, &blk) top.reject(*args, &blk) end
|
132
|
+
@@ -1097,6 +1147,7 @@
|
133
|
+
#
|
134
|
+
# Creates an OptionParser::Switch from the parameters. The parsed argument
|
135
|
+
# value is passed to the given block, where it can be processed.
|
136
|
+
+ # :rdx: off
|
137
|
+
#
|
138
|
+
# See at the beginning of OptionParser for some full examples.
|
139
|
+
#
|
140
|
+
@@ -1896,6 +1947,7 @@
|
141
|
+
#
|
142
|
+
# Substitution of getopts is possible as follows. Also see
|
143
|
+
# OptionParser#getopts.
|
144
|
+
+ # :rdx: off
|
145
|
+
#
|
146
|
+
# def getopts(*args)
|
147
|
+
# ($OPT = ARGV.getopts(*args)).each do |opt, val|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
--- stdlib/orig/lib/ostruct.rb 2015-06-11 07:51:45 +0000
|
2
|
+
+++ stdlib/patched/lib/ostruct.rb 2015-06-25 16:14:12 +0000
|
3
|
+
@@ -23,15 +23,15 @@
|
4
|
+
# person.age = 70
|
5
|
+
# person.pension = 300
|
6
|
+
#
|
7
|
+
-# puts person.name # -> "John Smith"
|
8
|
+
-# puts person.age # -> 70
|
9
|
+
-# puts person.address # -> nil
|
10
|
+
+# person.name # => "John Smith"
|
11
|
+
+# person.age # => 70
|
12
|
+
+# person.address # => nil
|
13
|
+
#
|
14
|
+
# An OpenStruct employs a Hash internally to store the methods and values and
|
15
|
+
# can even be initialized with one:
|
16
|
+
#
|
17
|
+
# australia = OpenStruct.new(:country => "Australia", :population => 20_000_000)
|
18
|
+
-# p australia # -> <OpenStruct country="Australia" population=20000000>
|
19
|
+
+# australia # > #<OpenStruct country="Australia", population=20000000>
|
20
|
+
#
|
21
|
+
# Hash keys with spaces or characters that would normally not be able to use for
|
22
|
+
# method calls (e.g. ()[]*) will not be immediately available on the
|
23
|
+
@@ -39,12 +39,12 @@
|
24
|
+
# reached through the Object#send method.
|
25
|
+
#
|
26
|
+
# measurements = OpenStruct.new("length (in inches)" => 24)
|
27
|
+
-# measurements.send("length (in inches)") # -> 24
|
28
|
+
+# measurements.send("length (in inches)") # => 24
|
29
|
+
#
|
30
|
+
# data_point = OpenStruct.new(:queued? => true)
|
31
|
+
-# data_point.queued? # -> true
|
32
|
+
+# data_point.queued? # => true
|
33
|
+
# data_point.send("queued?=",false)
|
34
|
+
-# data_point.queued? # -> false
|
35
|
+
+# data_point.queued? # => false
|
36
|
+
#
|
37
|
+
# Removing the presence of a method requires the execution the delete_field
|
38
|
+
# method as setting the property value to +nil+ will not remove the method.
|
39
|
+
@@ -53,10 +53,10 @@
|
40
|
+
# first_pet.owner = nil
|
41
|
+
# second_pet = OpenStruct.new(:name => 'Rowdy')
|
42
|
+
#
|
43
|
+
-# first_pet == second_pet # -> false
|
44
|
+
+# first_pet == second_pet # => false
|
45
|
+
#
|
46
|
+
# first_pet.delete_field(:owner)
|
47
|
+
-# first_pet == second_pet # -> true
|
48
|
+
+# first_pet == second_pet # => true
|
49
|
+
#
|
50
|
+
#
|
51
|
+
# == Implementation:
|
52
|
+
@@ -82,7 +82,7 @@
|
53
|
+
# hash = { "country" => "Australia", :population => 20_000_000 }
|
54
|
+
# data = OpenStruct.new(hash)
|
55
|
+
#
|
56
|
+
- # p data # -> <OpenStruct country="Australia" population=20000000>
|
57
|
+
+ # data # > #<OpenStruct country="Australia", population=20000000>
|
58
|
+
#
|
59
|
+
def initialize(hash=nil)
|
60
|
+
@table = {}
|
61
|
+
@@ -191,7 +191,7 @@
|
62
|
+
# Returns the value of a member.
|
63
|
+
#
|
64
|
+
# person = OpenStruct.new('name' => 'John Smith', 'age' => 70)
|
65
|
+
- # person[:age] # => 70, same as ostruct.age
|
66
|
+
+ # person[:age] # => 70 # same as ostruct.age
|
67
|
+
#
|
68
|
+
def [](name)
|
69
|
+
@table[name.to_sym]
|
70
|
+
@@ -201,7 +201,7 @@
|
71
|
+
# Sets the value of a member.
|
72
|
+
#
|
73
|
+
# person = OpenStruct.new('name' => 'John Smith', 'age' => 70)
|
74
|
+
- # person[:age] = 42 # => equivalent to ostruct.age = 42
|
75
|
+
+ # person[:age] = 42 # equivalent to person.age = 42
|
76
|
+
# person.age # => 42
|
77
|
+
#
|
78
|
+
def []=(name, value)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
--- stdlib/orig/lib/prime.rb 2015-06-11 07:51:45 +0000
|
2
|
+
+++ stdlib/patched/lib/prime.rb 2015-06-11 07:51:48 +0000
|
3
|
+
@@ -47,9 +47,19 @@
|
4
|
+
#
|
5
|
+
# == Example
|
6
|
+
#
|
7
|
+
-# Prime.each(100) do |prime|
|
8
|
+
-# p prime #=> 2, 3, 5, 7, 11, ...., 97
|
9
|
+
+# Prime.each(100).each_slice(5) do |*primes|
|
10
|
+
+# puts primes.join(', ') + ', '
|
11
|
+
# end
|
12
|
+
+# puts '...'
|
13
|
+
+#
|
14
|
+
+# produces:
|
15
|
+
+#
|
16
|
+
+# 2, 3, 5, 7, 11,
|
17
|
+
+# 13, 17, 19, 23, 29,
|
18
|
+
+# 31, 37, 41, 43, 47,
|
19
|
+
+# 53, 59, 61, 67, 71,
|
20
|
+
+# 73, 79, 83, 89, 97,
|
21
|
+
+# ...
|
22
|
+
#
|
23
|
+
# Prime is Enumerable:
|
24
|
+
#
|
25
|
+
@@ -174,9 +184,8 @@
|
26
|
+
# and a natural number -- an exponent.
|
27
|
+
#
|
28
|
+
# == Example
|
29
|
+
- # For <tt>[[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]]</tt>, it returns:
|
30
|
+
- #
|
31
|
+
- # p_1**e_1 * p_2**e_2 * .... * p_n**e_n.
|
32
|
+
+ # For <tt>[[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]]</tt>, it returns
|
33
|
+
+ # <tt>p_1**e_1 * p_2**e_2 * .... * p_n**e_n</tt>:
|
34
|
+
#
|
35
|
+
# Prime.int_from_prime_division([[2,2], [3,1]]) #=> 12
|
36
|
+
def int_from_prime_division(pd)
|
37
|
+
@@ -199,13 +208,8 @@
|
38
|
+
# +ZeroDivisionError+:: when +value+ is zero.
|
39
|
+
#
|
40
|
+
# == Example
|
41
|
+
- # For an arbitrary integer:
|
42
|
+
- #
|
43
|
+
- # n = p_1**e_1 * p_2**e_2 * .... * p_n**e_n,
|
44
|
+
- #
|
45
|
+
- # prime_division(n) returns:
|
46
|
+
- #
|
47
|
+
- # [[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]].
|
48
|
+
+ # For an arbitrary integer <tt>n = p_1**e_1 * p_2**e_2 * .... * p_n**e_n</tt>,
|
49
|
+
+ # <tt>prime_division(n)</tt> returns <tt>[[p_1, e_1], [p_2, e_2], ...., [p_n, e_n]]</tt>:
|
50
|
+
#
|
51
|
+
# Prime.prime_division(12) #=> [[2,2], [3,1]]
|
52
|
+
#
|
@@ -0,0 +1,110 @@
|
|
1
|
+
--- stdlib/orig/lib/pstore.rb 2015-06-11 07:51:45 +0000
|
2
|
+
+++ stdlib/patched/lib/pstore.rb 2015-06-25 16:15:54 +0000
|
3
|
+
@@ -1,6 +1,7 @@
|
4
|
+
# = PStore -- Transactional File Storage for Ruby Objects
|
5
|
+
#
|
6
|
+
# pstore.rb -
|
7
|
+
+# :rdx: off
|
8
|
+
# originally by matz
|
9
|
+
# documentation by Kev Jackson and James Edward Gray II
|
10
|
+
# improved by Hongli Lai
|
11
|
+
@@ -24,7 +25,10 @@
|
12
|
+
# marshalled, for example.
|
13
|
+
#
|
14
|
+
# == Usage example:
|
15
|
+
-#
|
16
|
+
+# :rdx: toplevel
|
17
|
+
+# :rdx: in_tmpdir
|
18
|
+
+# :rdx: indicative_numbers
|
19
|
+
+#
|
20
|
+
# require "pstore"
|
21
|
+
#
|
22
|
+
# # a mock wiki object...
|
23
|
+
@@ -68,14 +72,35 @@
|
24
|
+
#
|
25
|
+
# ### Some time later... ###
|
26
|
+
#
|
27
|
+
+# require "pp"
|
28
|
+
+#
|
29
|
+
# # read wiki data...
|
30
|
+
# wiki.transaction(true) do # begin read-only transaction, no changes allowed
|
31
|
+
# wiki.roots.each do |data_root_name|
|
32
|
+
-# p data_root_name
|
33
|
+
-# p wiki[data_root_name]
|
34
|
+
+# puts "data_root_name = #{data_root_name.inspect}", ""
|
35
|
+
+# pp wiki[data_root_name]
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
+#-- rdx
|
40
|
+
+# Object.send :remove_const, :WikiPage
|
41
|
+
+#++
|
42
|
+
+#
|
43
|
+
+# produces:
|
44
|
+
+#
|
45
|
+
+# data_root_name = "HomePage"
|
46
|
+
+#
|
47
|
+
+# #<WikiPage:0x0034ad21
|
48
|
+
+# @page_name="HomePage",
|
49
|
+
+# @revisions=
|
50
|
+
+# [{:created=>2015-06-03 12:27:18 +0200,
|
51
|
+
+# :author=>"James Edward Gray II",
|
52
|
+
+# :contents=>"A page about the JoysOfDocumentation..."}]>
|
53
|
+
+# data_root_name = :wiki_index
|
54
|
+
+#
|
55
|
+
+# ["HomePage", "JoysOfDocumentation"]
|
56
|
+
+#
|
57
|
+
+#
|
58
|
+
# == Transaction modes
|
59
|
+
#
|
60
|
+
# By default, file integrity is only ensured as long as the operating system
|
61
|
+
@@ -182,7 +207,8 @@
|
62
|
+
# store clobbers the old data.
|
63
|
+
#
|
64
|
+
# == Example:
|
65
|
+
- #
|
66
|
+
+ # :rdx: in_tmpdir
|
67
|
+
+ #
|
68
|
+
# require "pstore"
|
69
|
+
#
|
70
|
+
# store = PStore.new("data_file.pstore")
|
71
|
+
@@ -193,6 +219,17 @@
|
72
|
+
# "James Gray" => ["erb.rb", "pstore.rb"] }
|
73
|
+
# end # commit changes to data store file
|
74
|
+
#
|
75
|
+
+ # # Now to see the content:
|
76
|
+
+ #
|
77
|
+
+ # store[:single_object] # raises PStore::Error
|
78
|
+
+ # single_object = obj_heirarchy = nil
|
79
|
+
+ # store.transaction do
|
80
|
+
+ # single_object = store[:single_object]
|
81
|
+
+ # obj_heirarchy = store[:obj_heirarchy]
|
82
|
+
+ # end
|
83
|
+
+ # single_object #=> "My data..."
|
84
|
+
+ # obj_heirarchy["James Gray"] #=> ["erb.rb", "pstore.rb"]
|
85
|
+
+ #
|
86
|
+
# *WARNING*: This method is only valid in a PStore#transaction and it cannot
|
87
|
+
# be read-only. It will raise PStore::Error if called at any other time.
|
88
|
+
#
|
89
|
+
@@ -254,7 +291,20 @@
|
90
|
+
#
|
91
|
+
# store[:three] = 3 # this change is never reached
|
92
|
+
# end
|
93
|
+
- #
|
94
|
+
+ #
|
95
|
+
+ # # Now to see the content:
|
96
|
+
+ #
|
97
|
+
+ # store.commit # raises PStore::Error
|
98
|
+
+ # one = two = three = nil
|
99
|
+
+ # store.transaction do
|
100
|
+
+ # one = store[:one]
|
101
|
+
+ # two = store[:two]
|
102
|
+
+ # three = store[:three]
|
103
|
+
+ # end
|
104
|
+
+ # one #=> 1
|
105
|
+
+ # two #=> 2
|
106
|
+
+ # three #=> nil
|
107
|
+
+ #
|
108
|
+
# *WARNING*: This method is only valid in a PStore#transaction. It will
|
109
|
+
# raise PStore::Error if called at any other time.
|
110
|
+
#
|
@@ -0,0 +1,100 @@
|
|
1
|
+
--- stdlib/orig/lib/scanf.rb 2015-06-11 07:51:45 +0000
|
2
|
+
+++ stdlib/patched/lib/scanf.rb 2015-06-25 17:34:52 +0000
|
3
|
+
@@ -42,6 +42,7 @@
|
4
|
+
#
|
5
|
+
#
|
6
|
+
# == Basic usage
|
7
|
+
+# :rdx: off
|
8
|
+
#
|
9
|
+
# require 'scanf'
|
10
|
+
#
|
11
|
+
@@ -60,7 +61,8 @@
|
12
|
+
# (including partial matches, but not including complete failures). The
|
13
|
+
# actual return value of scanf when called with a block is an array
|
14
|
+
# containing the results of all the executions of the block.
|
15
|
+
-#
|
16
|
+
+#
|
17
|
+
+# :rdx: on
|
18
|
+
# str = "123 abc 456 def 789 ghi"
|
19
|
+
# str.scanf("%d%s") { |num,str| [ num * 2, str.upcase ] }
|
20
|
+
# # => [[246, "ABC"], [912, "DEF"], [1578, "GHI"]]
|
21
|
+
@@ -184,7 +186,8 @@
|
22
|
+
#
|
23
|
+
# When using IO#scanf under Windows, make sure you open your files in
|
24
|
+
# binary mode:
|
25
|
+
-#
|
26
|
+
+#
|
27
|
+
+# :rdx: off -
|
28
|
+
# File.open("filename", "rb")
|
29
|
+
#
|
30
|
+
# so that scanf can keep track of characters correctly.
|
31
|
+
@@ -596,17 +599,26 @@
|
32
|
+
# yielding each match as it is encountered in the string.
|
33
|
+
# A block is not necessary though, as the results will simply
|
34
|
+
# be aggregated into the final array.
|
35
|
+
+ #
|
36
|
+
+ # :rdx: in_tmpdir!
|
37
|
+
#
|
38
|
+
- # "123 456".block_scanf("%d")
|
39
|
+
- # # => [123, 456]
|
40
|
+
+ # # File: iotest
|
41
|
+
+ # 123 456 789
|
42
|
+
+ #
|
43
|
+
+ # Then from the main application:
|
44
|
+
+ # io = File.new 'iotest', 'rb'
|
45
|
+
+ # io.scanf("%d") # => [123]
|
46
|
+
+ # io.scanf("%d%d") # => [456, 789]
|
47
|
+
+ # io.scanf("%d") # => [] # eof reached
|
48
|
+
#
|
49
|
+
# If a block is given, the value from that is returned from
|
50
|
+
# the yield is added to an output array.
|
51
|
+
- #
|
52
|
+
- # "123 456".block_scanf("%d) do |digit,| # the ',' unpacks the Array
|
53
|
+
+ #
|
54
|
+
+ # io.rewind
|
55
|
+
+ # io.scanf("%d") do |digit,| # the ',' unpacks the Array
|
56
|
+
# digit + 100
|
57
|
+
# end
|
58
|
+
- # # => [223, 556]
|
59
|
+
+ # # => [223, 556, 889]
|
60
|
+
#
|
61
|
+
# See Scanf for details on creating a format string.
|
62
|
+
#
|
63
|
+
@@ -701,13 +713,12 @@
|
64
|
+
# arr = "123 456".scanf("%d%d")
|
65
|
+
# # => [123, 456]
|
66
|
+
#
|
67
|
+
- # require 'pp'
|
68
|
+
- #
|
69
|
+
- # "this 123 read that 456 other".scanf("%s%d%s") {|m| pp m}
|
70
|
+
+ # "this 123 read that 456 other".scanf("%s%d%s") {|m| p m}
|
71
|
+
#
|
72
|
+
- # # ["this", 123, "read"]
|
73
|
+
- # # ["that", 456, "other"]
|
74
|
+
- # # => [["this", 123, "read"], ["that", 456, "other"]]
|
75
|
+
+ # produces:
|
76
|
+
+ #
|
77
|
+
+ # ["this", 123, "read"]
|
78
|
+
+ # ["that", 456, "other"]
|
79
|
+
#
|
80
|
+
# See Scanf for details on creating a format string.
|
81
|
+
#
|
82
|
+
@@ -728,16 +739,8 @@
|
83
|
+
|
84
|
+
# Scans the current string until the match is exhausted
|
85
|
+
# yielding each match as it is encountered in the string.
|
86
|
+
- # A block is not necessary as the results will simply
|
87
|
+
- # be aggregated into the final array.
|
88
|
+
- #
|
89
|
+
- # "123 456".block_scanf("%d")
|
90
|
+
- # # => [123, 456]
|
91
|
+
- #
|
92
|
+
- # If a block is given, the value from that is returned from
|
93
|
+
- # the yield is added to an output array.
|
94
|
+
- #
|
95
|
+
- # "123 456".block_scanf("%d) do |digit,| # the ',' unpacks the Array
|
96
|
+
+ #
|
97
|
+
+ # "123 456".block_scanf("%d") do |digit,| # the ',' unpacks the Array
|
98
|
+
# digit + 100
|
99
|
+
# end
|
100
|
+
# # => [223, 556]
|