Skip to content
Open
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
47 changes: 47 additions & 0 deletions Ruby/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Ruby

## Commenting-Out

Because of the lack of comments with a closing token this doesn't work
the same way as other languages. For more info see:

https://github.com/nickboucher/trojan-source/issues/8#issuecomment-962468707

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

## Early Return

Also does not work the same as other languages because of lack of closing token
on comments. See same link as above.

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

## Homoglyph Function

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

## Invisible Function

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

## Stretched String

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

# Variations

Variations that may or may not be applicable in other languages. More info at:

https://github.com/nickboucher/trojan-source/issues/9

## Stretched Regexp

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

## Stretched String List

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]

## Stretched Variable

- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
6 changes: 6 additions & 0 deletions Ruby/commenting-out.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

is_admin = false
⁧⁦ = true; #⁩⁦if is_admin # Begin block if is_admin⁩⁩
puts 'You are an admin.'
⁧⁦ = true; #⁩⁦end # End block if is_admin ⁩⁩
11 changes: 11 additions & 0 deletions Ruby/early-return.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby

$bank = { 'alice' => 100 }

def subtract_funds account, amount
⁧⁦ = amount and return # ⁩⁦# Subtract from acct the value⁩⁩
$bank[account] -= amount
end

subtract_funds 'alice', 50
puts $bank.inspect
11 changes: 11 additions & 0 deletions Ruby/homoglyph-function.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby

def sayНello
puts "Goodbye, World!"
end

def sayHello
puts "Hello, World!"
end

sayНello
13 changes: 13 additions & 0 deletions Ruby/invisible-functions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby

def is_admin
false
end

def is_​admin
true
end

if is_​admin
puts "You are an admin."
end
10 changes: 10 additions & 0 deletions Ruby/stretched-regex.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env ruby

$roles = 'user,manager'
def admin?
$roles =~ /admin⁧⁦|user/ #⁩⁦/ # Restrict from ⁩⁩
end

if admin?
puts 'You are an admin.'
end
7 changes: 7 additions & 0 deletions Ruby/stretched-string-list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env ruby

role = 'User'
privileged = %w(Admin Manager⁧⁦ User) # ⁩⁦) # All roles (except ⁩⁩
if privileged.include? role
puts 'You are an admin.'
end
6 changes: 6 additions & 0 deletions Ruby/stretched-string.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

access_level = "user"
if access_level != "user‮⁦" # Check if admin⁩⁦
puts "You are an admin."
end
6 changes: 6 additions & 0 deletions Ruby/stretched-variable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

role⁧⁦= 'Admin' #⁩⁦ # Condition will ensure 'User' !⁩⁦ = 'User'⁩⁩
if role⁧⁦ == 'Admin'
puts 'You are an admin.'
end