Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 53 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ $\ = ' -- '
print $', $$, "\n"
```

With English:
With 'English':

```ruby
require "English"
Expand All @@ -44,62 +44,62 @@ The aliases are defined in [English.rb](lib/English.rb), and are as follows, fir

### Builtin to Alias Table

| Builtin | Alias |
| :-----: | ------------------------ |
| $! | $ERROR_INFO |
| $$ | $PID |
| $$ | $PROCESS_ID |
| $& | $MATCH |
| $' | $POSTMATCH |
| $* | $ARGV |
| $+ | $LAST_PAREN_MATCH |
| $, | $OFS |
| $, | $OUTPUT_FIELD_SEPARATOR |
| $. | $INPUT_LINE_NUMBER |
| $. | $NR |
| $/ | $INPUT_RECORD_SEPARATOR |
| $/ | $RS |
| $; | $FIELD_SEPARATOR |
| $; | $FS |
| $< | $DEFAULT_INPUT |
| $> | $DEFAULT_OUTPUT |
| $? | $CHILD_STATUS |
| $@ | $ERROR_POSITION |
| $\ | $ORS |
| $\ | $OUTPUT_RECORD_SEPARATOR |
| $_ | $LAST_READ_LINE |
| $` | $PREMATCH |
| $~ | $LAST_MATCH_INFO |
| Builtin | Alias |
| :------: | -------------------------- |
| `` $! `` | `$ERROR_INFO` |
| `` $$ `` | `$PID` |
| `` $$ `` | `$PROCESS_ID` |
| `` $& `` | `$MATCH` |
| `` $' `` | `$POSTMATCH` |
| `` $* `` | `$ARGV` |
| `` $+ `` | `$LAST_PAREN_MATCH` |
| `` $, `` | `$OFS` |
| `` $, `` | `$OUTPUT_FIELD_SEPARATOR` |
| `` $. `` | `$INPUT_LINE_NUMBER` |
| `` $. `` | `$NR` |
| `` $/ `` | `$INPUT_RECORD_SEPARATOR` |
| `` $/ `` | `$RS` |
| `` $; `` | `$FIELD_SEPARATOR` |
| `` $; `` | `$FS` |
| `` $< `` | `$DEFAULT_INPUT` |
| `` $> `` | `$DEFAULT_OUTPUT` |
| `` $? `` | `$CHILD_STATUS` |
| `` $@ `` | `$ERROR_POSITION` |
| `` $\ `` | `$ORS` |
| `` $\ `` | `$OUTPUT_RECORD_SEPARATOR` |
| `` $_ `` | `$LAST_READ_LINE` |
| `` $` `` | `$PREMATCH` |
| `` $~ `` | `$LAST_MATCH_INFO` |


### Alias to Builtin Table

| Alias | Builtin |
| ------------------------ | :-----: |
| $ARGV | $* |
| $CHILD_STATUS | $? |
| $DEFAULT_INPUT | $< |
| $DEFAULT_OUTPUT | $> |
| $ERROR_INFO | $! |
| $ERROR_POSITION | $@ |
| $FIELD_SEPARATOR | $; |
| $FS | $; |
| $INPUT_LINE_NUMBER | $. |
| $INPUT_RECORD_SEPARATOR | $/ |
| $LAST_MATCH_INFO | $~ |
| $LAST_PAREN_MATCH | $+ |
| $LAST_READ_LINE | $_ |
| $MATCH | $& |
| $NR | $. |
| $OFS | $, |
| $ORS | $\ |
| $OUTPUT_FIELD_SEPARATOR | $, |
| $OUTPUT_RECORD_SEPARATOR | $\ |
| $PID | $$ |
| $POSTMATCH | $' |
| $PREMATCH | $` |
| $PROCESS_ID | $$ |
| $RS | $/ |
| Alias | Builtin |
| -------------------------- | :------: |
| `$ARGV` | `` $* `` |
| `$CHILD_STATUS` | `` $? `` |
| `$DEFAULT_INPUT` | `` $< `` |
| `$DEFAULT_OUTPUT` | `` $> `` |
| `$ERROR_INFO` | `` $! `` |
| `$ERROR_POSITION` | `` $@ `` |
| `$FIELD_SEPARATOR` | `` $; `` |
| `$FS` | `` $; `` |
| `$INPUT_LINE_NUMBER` | `` $. `` |
| `$INPUT_RECORD_SEPARATOR` | `` $/ `` |
| `$LAST_MATCH_INFO` | `` $~ `` |
| `$LAST_PAREN_MATCH` | `` $+ `` |
| `$LAST_READ_LINE` | `` $_ `` |
| `$MATCH` | `` $& `` |
| `$NR` | `` $. `` |
| `$OFS` | `` $, `` |
| `$ORS` | `` $\ `` |
| `$OUTPUT_FIELD_SEPARATOR` | `` $, `` |
| `$OUTPUT_RECORD_SEPARATOR` | `` $\ `` |
| `$PID` | `` $$ `` |
| `$POSTMATCH` | `` $' `` |
| `$PREMATCH` | `` $` `` |
| `$PROCESS_ID` | `` $$ `` |
| `$RS` | `` $/ `` |


## Development
Expand Down
8 changes: 6 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "bundler/gem_tasks"

file "README.md" => "lib/English.rb" do
ruby "bin/alias_markdown_table_generator", "README.md"
generator = "bin/alias_markdown_table_generator"
file "README.md" => ["lib/English.rb", generator] do
ruby generator, "README.md"
end
task "update-alias-table" do
ruby "-i", "bin/alias_list_update.rb", "lib/English.rb"
end
8 changes: 8 additions & 0 deletions bin/alias_list_update.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!ruby
content = ARGF.file.read
list = content.scan(/^alias (\$\S+)( +)(\$.)$/).map do |a, s, b|
"# <tt>#{a}</tt>::#{s}<tt>#{b}</tt>\n"
end
puts content.sub(/^# *Below is a full list.*(?:\n# *\S.*)*\n#\n\K(?:# .*\n)*/) {
list.join("")
}
18 changes: 9 additions & 9 deletions bin/alias_markdown_table_generator
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#
# | Alias | Built-In |
# | ------------------------ | :------: |
# | $ARGV | $* |
# | $CHILD_STATUS | $? |
# | `$ARGV` | `` $* `` |
# | `$CHILD_STATUS` | `` $? `` |
#
# and:
#
# | Built-In | Alias |
# | -------- | :----------------------: |
# | $* | $ARGV |
# | $? | $CHILD_STATUS |
# | :------: | ------------------------ |
# | `` $* `` | `$ARGV` |
# | `` $? `` | `$CHILD_STATUS` |
#
# Some of the formatting done here is not necessary, but is done to make the generated markdown more readable.

Expand All @@ -25,7 +25,7 @@ class FileParser
ALIAS_SOURCE_FILESPEC = File.join(__dir__, '../lib/English.rb')

def self.parse(code_text_lines=File.readlines(ALIAS_SOURCE_FILESPEC))
code_text_lines.grep(/^\s*alias\s+(\S+)\s+(\S+)/) {$~.captures}
code_text_lines.grep(/^\s*alias\s+(\S+)\s+(\S+)/) {["`#$1`", "`` #$2 ``"]}
end
end

Expand Down Expand Up @@ -95,12 +95,12 @@ if __FILE__ == $0
if replace
case line
when /^##?\s/, /^### (?!Alias to Builtin Table)/
puts line
replace = false
else
next
end
else
puts line
end
puts line
end
end
end
50 changes: 25 additions & 25 deletions lib/English.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# "waterbuffalo" =~ /buff/
# print $', $$, "\n"
#
# With English:
# With 'English':
#
# require "English"
#
Expand All @@ -20,30 +20,30 @@
# Below is a full list of descriptive aliases and their associated global
# variable:
#
# $ERROR_INFO:: $!
# $ERROR_POSITION:: $@
# $FS:: $;
# $FIELD_SEPARATOR:: $;
# $OFS:: $,
# $OUTPUT_FIELD_SEPARATOR:: $,
# $RS:: $/
# $INPUT_RECORD_SEPARATOR:: $/
# $ORS:: $\
# $OUTPUT_RECORD_SEPARATOR:: $\
# $INPUT_LINE_NUMBER:: $.
# $NR:: $.
# $LAST_READ_LINE:: $_
# $DEFAULT_OUTPUT:: $>
# $DEFAULT_INPUT:: $<
# $PID:: $$
# $PROCESS_ID:: $$
# $CHILD_STATUS:: $?
# $LAST_MATCH_INFO:: $~
# $ARGV:: $*
# $MATCH:: $&
# $PREMATCH:: $`
# $POSTMATCH:: $'
# $LAST_PAREN_MATCH:: $+
# <tt>$ERROR_INFO</tt>:: <tt>$!</tt>
# <tt>$ERROR_POSITION</tt>:: <tt>$@</tt>
# <tt>$FS</tt>:: <tt>$;</tt>
# <tt>$FIELD_SEPARATOR</tt>:: <tt>$;</tt>
# <tt>$OFS</tt>:: <tt>$,</tt>
# <tt>$OUTPUT_FIELD_SEPARATOR</tt>:: <tt>$,</tt>
# <tt>$RS</tt>:: <tt>$/</tt>
# <tt>$INPUT_RECORD_SEPARATOR</tt>:: <tt>$/</tt>
# <tt>$ORS</tt>:: <tt>$\</tt>
# <tt>$OUTPUT_RECORD_SEPARATOR</tt>:: <tt>$\</tt>
# <tt>$NR</tt>:: <tt>$.</tt>
# <tt>$INPUT_LINE_NUMBER</tt>:: <tt>$.</tt>
# <tt>$LAST_READ_LINE</tt>:: <tt>$_</tt>
# <tt>$DEFAULT_OUTPUT</tt>:: <tt>$></tt>
# <tt>$DEFAULT_INPUT</tt>:: <tt>$<</tt>
# <tt>$PID</tt>:: <tt>$$</tt>
# <tt>$PROCESS_ID</tt>:: <tt>$$</tt>
# <tt>$CHILD_STATUS</tt>:: <tt>$?</tt>
# <tt>$LAST_MATCH_INFO</tt>:: <tt>$~</tt>
# <tt>$ARGV</tt>:: <tt>$*</tt>
# <tt>$MATCH</tt>:: <tt>$&</tt>
# <tt>$PREMATCH</tt>:: <tt>$`</tt>
# <tt>$POSTMATCH</tt>:: <tt>$'</tt>
# <tt>$LAST_PAREN_MATCH</tt>:: <tt>$+</tt>
#
module English end if false

Expand Down