dsl-python 0.16.0 → 0.18.0
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/README.md +21 -18
- data/bin/npython +8 -25
- data/lib/dsl/python/ansi.rb +83 -0
- data/lib/dsl/python/cli.rb +45 -0
- data/lib/dsl/python/functions/etc.rb +16 -0
- data/lib/dsl/python/functions/import.rb +16 -0
- data/lib/dsl/python/{type.rb → functions/type.rb} +3 -1
- data/lib/dsl/python/klasses.rb +10 -0
- data/lib/dsl/python/{copyright.rb → repl/copyright.rb} +1 -0
- data/lib/dsl/python/{credits.rb → repl/credits.rb} +2 -1
- data/lib/dsl/python/repl/etc.rb +23 -0
- data/lib/dsl/python/{license.rb → repl/license.rb} +1 -0
- data/lib/dsl/python/repl/zen.rb +58 -0
- data/lib/dsl/python/types/array.rb +23 -0
- data/lib/dsl/python/{booleans.rb → types/boolean.rb} +1 -0
- data/lib/dsl/python/{hashes.rb → types/hash.rb} +1 -0
- data/lib/dsl/python/types/integer.rb +37 -0
- data/lib/dsl/python/{none.rb → types/none.rb} +1 -0
- data/lib/dsl/python/{ranges.rb → types/range.rb} +2 -0
- data/lib/dsl/python/types/string.rb +34 -0
- data/lib/dsl/python/version.rb +1 -1
- data/lib/dsl/python.rb +23 -11
- metadata +19 -12
- data/lib/dsl/python/import.rb +0 -8
- data/lib/dsl/python/strings.rb +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2eb743a306a7a67f79aebdbc21f9e7a23a672b9afbebb4397af2d69b9dba83d
|
|
4
|
+
data.tar.gz: 23d92ea3bbf42aac6db5a032546f644bed04c3d22d157c8da8643f3d9208a208
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0aace107c890bd9b63bb5f1c8168ba4dec5d40c5a692b482107fde74286c44b08ca163b59f94bc47298809a4deb470203a6d50c2047da1bfc0604be8b67e21dd
|
|
7
|
+
data.tar.gz: f9425130dcd7cbbf65b55d94fc137ebc826dc6ccd902da814f4177dc971ccdf7d53be28aced41b3fbb069ebc27f89cb34a1d6bd9c2b36bc135ed2284971d37a9
|
data/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Dsl::Python
|
|
2
2
|
|
|
3
3
|
```
|
|
4
|
-
DSL para
|
|
4
|
+
DSL para hacer que Ruby "parezca" Python
|
|
5
5
|
```
|
|
6
6
|
|
|
7
|
-
Este
|
|
7
|
+
Este proyecto que no tiene utilidad práctica. El objetivo es poner a prueba las capacidades del lenguaje Ruby para crear un DSL de Python en un corto espacio de tiempo.
|
|
8
8
|
|
|
9
|
-
> NOTA
|
|
9
|
+
> **NOTA**: La principal diferencia con el original, es que se usa la palabra reservada `end` para delimitar el final de bloque, en lugar de los `:` y sangrado.
|
|
10
10
|
|
|
11
11
|
## Instalación
|
|
12
12
|
|
|
@@ -18,13 +18,13 @@ Este es un proyecto que no tiene utilidad práctica. El objetivo era poner a pru
|
|
|
18
18
|
Crear un programa con el contenido de un programa Python:
|
|
19
19
|
|
|
20
20
|
```python
|
|
21
|
-
|
|
22
|
-
print(
|
|
23
|
-
print(type(
|
|
21
|
+
name = "Obiwan Kwnobi"
|
|
22
|
+
print(name)
|
|
23
|
+
print(type(name)) #=> name is str class
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
print(
|
|
27
|
-
print(type(
|
|
25
|
+
words = name.split()
|
|
26
|
+
print(words)
|
|
27
|
+
print(type(words)) #=> words is list class
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
* Ejecutar con el "intérprete": `npython FILENAME`.
|
|
@@ -32,9 +32,9 @@ print(type(x))
|
|
|
32
32
|
```bash
|
|
33
33
|
$ npython examples/03-variables.py
|
|
34
34
|
4
|
|
35
|
-
<
|
|
35
|
+
<class 'int'>
|
|
36
36
|
Obiwan
|
|
37
|
-
<
|
|
37
|
+
<class 'str'>
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
> Más [ejemplos](./examples/)
|
|
@@ -42,13 +42,14 @@ Obiwan
|
|
|
42
42
|
## Features
|
|
43
43
|
|
|
44
44
|
* Intérpre interactivo `npython`.
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
- Se muestra el Zen de nPython: `import this`, `import that`, `zen`.
|
|
46
|
+
* Tipos de datos:
|
|
47
|
+
- Booleans: `True`, `False`
|
|
48
|
+
- Diccionarios: `dict = {"name": "Obiwan", "age": 55}`
|
|
49
|
+
- None
|
|
50
|
+
- Ranges
|
|
51
|
+
- Strings: `join`.
|
|
52
|
+
* Funciones comunes: `id`, `len`, `type`
|
|
52
53
|
|
|
53
54
|
## Contributing
|
|
54
55
|
|
|
@@ -58,4 +59,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/dvarru
|
|
|
58
59
|
|
|
59
60
|
Enlaces de interés:
|
|
60
61
|
|
|
62
|
+
* [dsl-clang](https://github.com/dvarrui/dsl-clang)
|
|
63
|
+
* [dsl-graph](https://github.com/dvarrui/dsl-graph)
|
|
61
64
|
* [dsl-latin](https://github.com/dvarrui/dsl-latin)
|
data/bin/npython
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
4
|
+
require "dsl/python/cli"
|
|
4
5
|
|
|
5
6
|
if ARGV.size.zero?
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
puts text
|
|
12
|
-
|
|
13
|
-
system("irb --prompt simple --nocolorize --noecho-on-assignment -Ilib -rnpython")
|
|
14
|
-
elsif ["-v", "--version", "-V"].include? ARGV.first
|
|
15
|
-
puts "npython (#{VERSION})"
|
|
16
|
-
elsif ["-h", "--help", "-?"].include? ARGV.first
|
|
17
|
-
text = <<~TEXT
|
|
18
|
-
usage: npython [option | file ]
|
|
19
|
-
Options:
|
|
20
|
-
-h : print this help message and exit (also -? or --help)
|
|
21
|
-
-v : show current version (also -V or --version)
|
|
22
|
-
|
|
23
|
-
Arguments:
|
|
24
|
-
file : program read from script file
|
|
25
|
-
TEXT
|
|
26
|
-
puts text
|
|
7
|
+
Dsl::Python::open_repl
|
|
8
|
+
elsif ["v", "-v", "--version", "-V"].include? ARGV.first
|
|
9
|
+
Dsl::Python::show_version
|
|
10
|
+
elsif ["h", "-h", "--help", "-?"].include? ARGV.first
|
|
11
|
+
Dsl::Python::show_help
|
|
27
12
|
else
|
|
28
|
-
|
|
29
|
-
content = File.read(ARGV.first)
|
|
30
|
-
eval(content)
|
|
13
|
+
Dsl::Python::run_program ARGV.first
|
|
31
14
|
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require "io/console"
|
|
3
|
+
|
|
4
|
+
# Códigos ANSI de color:
|
|
5
|
+
# Color Código Uso en Ruby
|
|
6
|
+
# Rojo \e[31m puts "\e[31mEste texto es rojo\e[0m"
|
|
7
|
+
# Verde \e[32m puts "\e[32mEste texto es verde\e[0m"
|
|
8
|
+
# Amarillo \e[33m puts "\e[33mEste texto es amarillo\e[0m"
|
|
9
|
+
# Reset \e[0m (Obligatorio para volver al color normal)
|
|
10
|
+
|
|
11
|
+
class ANSI
|
|
12
|
+
COLORS = {
|
|
13
|
+
red: "\e[31m",
|
|
14
|
+
green: "\e[32m",
|
|
15
|
+
yellow: "\e[33m"
|
|
16
|
+
}
|
|
17
|
+
RESET = "\e[0m"
|
|
18
|
+
CLEAR_SCREEN = "\e[2J\e[H"
|
|
19
|
+
|
|
20
|
+
attr_reader :height, :width
|
|
21
|
+
|
|
22
|
+
def initialize
|
|
23
|
+
@height, @width = `stty size`.split.map { _1.to_i }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def green(text)
|
|
27
|
+
print_with_color(:green, text)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def red(text)
|
|
31
|
+
print_with_color(:red, text)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def yellow(text)
|
|
35
|
+
print_with_color(:yellow, text)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def print_with_color(color, text)
|
|
39
|
+
"#{COLORS[color]}#{text}#{RESET}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.clear_screen
|
|
43
|
+
print "\e[2J\e[H"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.move_cursor(row, col)
|
|
47
|
+
print "\033[#{row};#{col}H"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.reset_cursor
|
|
51
|
+
print "\e[0m"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.print_text_at(row, col, text)
|
|
55
|
+
print "\033[#{row + 1};#{col}H"
|
|
56
|
+
print text
|
|
57
|
+
print "\e[0m"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.pressed_key
|
|
61
|
+
char = STDIN.read_nonblock(3) rescue nil
|
|
62
|
+
return nil unless char
|
|
63
|
+
|
|
64
|
+
case char
|
|
65
|
+
when "\e[A" then :up
|
|
66
|
+
when "\e[B" then :down
|
|
67
|
+
when "\e[C" then :right
|
|
68
|
+
when "\e[D" then :left
|
|
69
|
+
when "q" then :quit
|
|
70
|
+
else char
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.set_raw_mode
|
|
75
|
+
STDIN.echo = false
|
|
76
|
+
STDIN.raw!
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.set_cooked_mode
|
|
80
|
+
STDIN.cooked!
|
|
81
|
+
STDIN.echo = true
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require_relative "../python"
|
|
2
|
+
require_relative "version"
|
|
3
|
+
|
|
4
|
+
# VERSION=Dsl::Python::VERSION
|
|
5
|
+
|
|
6
|
+
module Dsl
|
|
7
|
+
module Python
|
|
8
|
+
def self.open_repl
|
|
9
|
+
text = <<~TEXT
|
|
10
|
+
nPython #{VERSION} (main, Nov 16 1970) [GCC] on linux
|
|
11
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
|
12
|
+
TEXT
|
|
13
|
+
puts text
|
|
14
|
+
system("irb --nobanner --prompt simple --nocolorize --noecho-on-assignment -Ilib -rdsl/python")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.show_version
|
|
18
|
+
puts "npython #{VERSION}"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.show_help
|
|
22
|
+
text = <<~TEXT
|
|
23
|
+
usage: npython [option | file ]
|
|
24
|
+
Options:
|
|
25
|
+
-h : print this help message and exit (also -? or --help)
|
|
26
|
+
-v : show current version (also -V or --version)
|
|
27
|
+
|
|
28
|
+
Arguments:
|
|
29
|
+
file : program read from script file
|
|
30
|
+
TEXT
|
|
31
|
+
puts text
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.run_program(name)
|
|
35
|
+
unless File.exist? name
|
|
36
|
+
puts "npython: can't open file '#{name}': [Errno 2] No such file or directory"
|
|
37
|
+
exit 1
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
content = File.read(name)
|
|
41
|
+
eval(content)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
def len(obj)
|
|
3
|
+
if obj.respond_to?(:length)
|
|
4
|
+
obj.length
|
|
5
|
+
elsif obj.respond_to?(:count)
|
|
6
|
+
obj.count
|
|
7
|
+
elsif obj.respond_to?(:size)
|
|
8
|
+
obj.size
|
|
9
|
+
else
|
|
10
|
+
puts "TypeError: object of type '#{type(obj)}' has no len()"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def id(obj)
|
|
15
|
+
obj.object_id
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../repl/zen"
|
|
4
|
+
|
|
5
|
+
def import(name)
|
|
6
|
+
fullname = name.to_s + ".py"
|
|
7
|
+
if name.to_s == "this"
|
|
8
|
+
Dsl::Python::show_zen
|
|
9
|
+
elsif name.to_s == "that"
|
|
10
|
+
Dsl::Python::show_zen(ofuscate: true)
|
|
11
|
+
elsif File.exist? name
|
|
12
|
+
load name
|
|
13
|
+
else
|
|
14
|
+
puts "npython: can't open file '#{name}': [Errno 2] No such file or directory"
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/dsl/python/klasses.rb
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Sintaxis: type(nombre_de_la_clase, bases_de_las_que_hereda, diccionario_de_atributos)
|
|
4
|
+
# Persona = type('Persona', (), {'saludar': lambda self: "¡Hola!"})
|
|
5
|
+
|
|
6
|
+
# Ahora puedes usarla como cualquier clase normal:
|
|
7
|
+
# instancia = Persona()
|
|
8
|
+
# print(instancia.saludar()) # Resultado: ¡Hola!
|
|
9
|
+
# print(type(instancia)) # Resultado: <class '__main__.Persona'>
|
|
10
|
+
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
|
|
2
3
|
def credits()
|
|
3
4
|
text = <<~TEXT
|
|
4
5
|
Thanks to Free Software, Yukuhiro Matzumoto, David Vargas Ruiz
|
|
5
6
|
and a cast of thousands for supporting nPython
|
|
6
|
-
development. See
|
|
7
|
+
development. See github.com/dvarrui/dsl-python for more information.
|
|
7
8
|
TEXT
|
|
8
9
|
puts text
|
|
9
10
|
"(Credits)"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../ansi"
|
|
4
|
+
|
|
5
|
+
def whoareyou
|
|
6
|
+
name = ANSI.new.green("dsl-python")
|
|
7
|
+
puts " Hi! I'm a ruby gem called '#{name}'."
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def whereareyou
|
|
11
|
+
text = ANSI.new.green("https://github.com/dvarrui/dsl-python")
|
|
12
|
+
puts " You can find me at: #{text}"
|
|
13
|
+
text = ANSI.new.green("https://rubygems.org/gems/dsl-python")
|
|
14
|
+
puts " And also at: #{text}"
|
|
15
|
+
nil
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def bye
|
|
19
|
+
puts ''
|
|
20
|
+
system("figlet 'I love Ruby'")
|
|
21
|
+
puts ''
|
|
22
|
+
exit
|
|
23
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../ansi"
|
|
4
|
+
|
|
5
|
+
def this
|
|
6
|
+
"this"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def that
|
|
10
|
+
"that"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def zen
|
|
14
|
+
Dsl::Python::show_zen
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
module Dsl
|
|
18
|
+
module Python
|
|
19
|
+
def self.show_zen(ofuscate: false)
|
|
20
|
+
text = <<~TEXT
|
|
21
|
+
El Zen de nPython (Inspirado por Matz)
|
|
22
|
+
|
|
23
|
+
1. La felicidad del programador es el fin último.
|
|
24
|
+
2. Lo natural es mejor que lo explícito.
|
|
25
|
+
3. La libertad es mejor que la restricción.
|
|
26
|
+
4. La elegancia supera a la brevedad.
|
|
27
|
+
5. Muchos caminos son mejores que uno solo (TIMTOWTDI).
|
|
28
|
+
6. Si el código se lee como prosa, es buen código.
|
|
29
|
+
7. No castigues al programador por ser inteligente.
|
|
30
|
+
8. La pureza del objeto es sagrada.
|
|
31
|
+
9. La metaprogramación es un superpoder, úsalo con sabiduría.
|
|
32
|
+
10. El lenguaje debe adaptarse al humano, no el humano al lenguaje.
|
|
33
|
+
11. Un bloque es a menudo la respuesta.
|
|
34
|
+
12. Los símbolos son mejores que los strings para la identidad.
|
|
35
|
+
13. El principio de Menor Sorpresa es subjetivo, pero vital.
|
|
36
|
+
14. Si te hace sonreír al escribirlo, es Ruby.
|
|
37
|
+
TEXT
|
|
38
|
+
|
|
39
|
+
lines = text.split("\n")
|
|
40
|
+
lines.each_with_index do |line, index|
|
|
41
|
+
if line.empty?
|
|
42
|
+
puts ""
|
|
43
|
+
next
|
|
44
|
+
end
|
|
45
|
+
words = line.split
|
|
46
|
+
if index.zero?
|
|
47
|
+
index = words.shift
|
|
48
|
+
else
|
|
49
|
+
index = ANSI.new.green(words.shift)
|
|
50
|
+
end
|
|
51
|
+
text = words.join(" ")
|
|
52
|
+
text = text.gsub(/[^\d\s]/, '*') if ofuscate
|
|
53
|
+
puts " #{index} #{text}"
|
|
54
|
+
end
|
|
55
|
+
nil
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Array
|
|
4
|
+
def __
|
|
5
|
+
puts <<-METHODS
|
|
6
|
+
list.__add__( list.__ge__( list.__iter__() list.__reversed__()
|
|
7
|
+
list.__class__( list.__getattribute__( list.__le__( list.__rmul__(
|
|
8
|
+
list.__class_getitem__( list.__getitem__( list.__len__() list.__setattr__(
|
|
9
|
+
list.__contains__( list.__getstate__() list.__lt__( list.__setitem__(
|
|
10
|
+
list.__delattr__( list.__gt__( list.__mul__( list.__sizeof__()
|
|
11
|
+
list.__delitem__( list.__hash__ list.__ne__( list.__str__()
|
|
12
|
+
list.__dir__() list.__iadd__( list.__new__( list.__subclasshook__(
|
|
13
|
+
list.__doc__ list.__imul__( list.__reduce__()
|
|
14
|
+
list.__eq__( list.__init__( list.__reduce_ex__(
|
|
15
|
+
list.__format__( list.__init_subclass__() list.__repr__()
|
|
16
|
+
METHODS
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_s
|
|
20
|
+
self.inspect.to_s
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Integer
|
|
4
|
+
def __
|
|
5
|
+
puts <<-TEXT
|
|
6
|
+
int.__abs__() int.__floordiv__( int.__le__( int.__rdivmod__( int.__rsub__(
|
|
7
|
+
int.__add__( int.__format__( int.__lshift__( int.__reduce__() int.__rtruediv__(
|
|
8
|
+
int.__and__( int.__ge__( int.__lt__( int.__reduce_ex__( int.__rxor__(
|
|
9
|
+
int.__bool__() int.__getattribute__( int.__mod__( int.__repr__() int.__setattr__(
|
|
10
|
+
int.__ceil__() int.__getnewargs__() int.__mul__( int.__rfloordiv__( int.__sizeof__()
|
|
11
|
+
int.__class__( int.__getstate__() int.__ne__( int.__rlshift__( int.__str__()
|
|
12
|
+
int.__delattr__( int.__gt__( int.__neg__() int.__rmod__( int.__sub__(
|
|
13
|
+
int.__dir__() int.__hash__() int.__new__( int.__rmul__( int.__subclasshook__(
|
|
14
|
+
int.__divmod__( int.__index__() int.__or__( int.__ror__( int.__truediv__(
|
|
15
|
+
int.__doc__ int.__init__( int.__pos__() int.__round__( int.__trunc__()
|
|
16
|
+
int.__eq__( int.__init_subclass__() int.__pow__( int.__rpow__( int.__xor__(
|
|
17
|
+
int.__float__() int.__int__() int.__radd__( int.__rrshift__(
|
|
18
|
+
int.__floor__() int.__invert__() int.__rand__( int.__rshift__(
|
|
19
|
+
TEXT
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def __add__(other)
|
|
23
|
+
self + other
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def __floordiv__(other)
|
|
27
|
+
self / other
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def __mul__(other)
|
|
31
|
+
self * other
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def __sub__(other)
|
|
35
|
+
self - other
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
class String
|
|
3
|
+
def format(arg)
|
|
4
|
+
self % arg
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def join(list)
|
|
8
|
+
list.join(self)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def lower
|
|
12
|
+
self.downcase
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def upper
|
|
16
|
+
self.upcase
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def replace(a, b)
|
|
20
|
+
self.tr(a, b)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def __
|
|
24
|
+
puts " str.__add__( str.__getattribute__( str.__le__( str.__repr__()
|
|
25
|
+
str.__class__( str.__getitem__( str.__len__() str.__rmod__(
|
|
26
|
+
str.__contains__( str.__getnewargs__() str.__lt__( str.__rmul__(
|
|
27
|
+
str.__delattr__( str.__getstate__() str.__mod__( str.__setattr__(
|
|
28
|
+
str.__dir__() str.__gt__( str.__mul__( str.__sizeof__()
|
|
29
|
+
str.__doc__ str.__hash__() str.__ne__( str.__str__()
|
|
30
|
+
str.__eq__( str.__init__( str.__new__( str.__subclasshook__(
|
|
31
|
+
str.__format__( str.__init_subclass__() str.__reduce__()
|
|
32
|
+
str.__ge__( str.__iter__() str.__reduce_ex__( "
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/dsl/python/version.rb
CHANGED
data/lib/dsl/python.rb
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "python/
|
|
4
|
-
require_relative "python/
|
|
5
|
-
require_relative "python/
|
|
6
|
-
require_relative "python/
|
|
7
|
-
require_relative "python/
|
|
8
|
-
|
|
9
|
-
require_relative "python/
|
|
10
|
-
require_relative "python/
|
|
11
|
-
require_relative "python/
|
|
12
|
-
require_relative "python/
|
|
3
|
+
require_relative "python/repl/copyright"
|
|
4
|
+
require_relative "python/repl/credits"
|
|
5
|
+
require_relative "python/repl/etc"
|
|
6
|
+
require_relative "python/repl/license"
|
|
7
|
+
require_relative "python/repl/zen"
|
|
8
|
+
|
|
9
|
+
require_relative "python/types/array"
|
|
10
|
+
require_relative "python/types/boolean"
|
|
11
|
+
require_relative "python/types/hash"
|
|
12
|
+
require_relative "python/types/integer"
|
|
13
|
+
require_relative "python/types/none"
|
|
14
|
+
require_relative "python/types/range"
|
|
15
|
+
require_relative "python/types/string"
|
|
16
|
+
|
|
17
|
+
require_relative "python/functions/etc"
|
|
18
|
+
require_relative "python/functions/import"
|
|
19
|
+
require_relative "python/functions/type"
|
|
20
|
+
|
|
13
21
|
require_relative "python/version"
|
|
14
22
|
|
|
15
23
|
def print(*args)
|
|
16
24
|
if args.is_a? Array
|
|
17
|
-
|
|
25
|
+
if args.count == 1
|
|
26
|
+
puts args.first.to_s
|
|
27
|
+
else
|
|
28
|
+
puts args.join " "
|
|
29
|
+
end
|
|
18
30
|
else
|
|
19
31
|
puts(args)
|
|
20
32
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dsl-python
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Vargas Ruiz
|
|
@@ -23,17 +23,24 @@ files:
|
|
|
23
23
|
- README.md
|
|
24
24
|
- bin/npython
|
|
25
25
|
- lib/dsl/python.rb
|
|
26
|
-
- lib/dsl/python/
|
|
27
|
-
- lib/dsl/python/
|
|
28
|
-
- lib/dsl/python/
|
|
29
|
-
- lib/dsl/python/
|
|
30
|
-
- lib/dsl/python/
|
|
26
|
+
- lib/dsl/python/ansi.rb
|
|
27
|
+
- lib/dsl/python/cli.rb
|
|
28
|
+
- lib/dsl/python/functions/etc.rb
|
|
29
|
+
- lib/dsl/python/functions/import.rb
|
|
30
|
+
- lib/dsl/python/functions/type.rb
|
|
31
31
|
- lib/dsl/python/klasses.rb
|
|
32
|
-
- lib/dsl/python/
|
|
33
|
-
- lib/dsl/python/
|
|
34
|
-
- lib/dsl/python/
|
|
35
|
-
- lib/dsl/python/
|
|
36
|
-
- lib/dsl/python/
|
|
32
|
+
- lib/dsl/python/repl/copyright.rb
|
|
33
|
+
- lib/dsl/python/repl/credits.rb
|
|
34
|
+
- lib/dsl/python/repl/etc.rb
|
|
35
|
+
- lib/dsl/python/repl/license.rb
|
|
36
|
+
- lib/dsl/python/repl/zen.rb
|
|
37
|
+
- lib/dsl/python/types/array.rb
|
|
38
|
+
- lib/dsl/python/types/boolean.rb
|
|
39
|
+
- lib/dsl/python/types/hash.rb
|
|
40
|
+
- lib/dsl/python/types/integer.rb
|
|
41
|
+
- lib/dsl/python/types/none.rb
|
|
42
|
+
- lib/dsl/python/types/range.rb
|
|
43
|
+
- lib/dsl/python/types/string.rb
|
|
37
44
|
- lib/dsl/python/version.rb
|
|
38
45
|
homepage: https://github.com/dvarrui/dsl-python
|
|
39
46
|
licenses:
|
|
@@ -56,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
56
63
|
- !ruby/object:Gem::Version
|
|
57
64
|
version: '0'
|
|
58
65
|
requirements: []
|
|
59
|
-
rubygems_version:
|
|
66
|
+
rubygems_version: 4.0.10
|
|
60
67
|
specification_version: 4
|
|
61
68
|
summary: DSL para programar Python usando Ruby
|
|
62
69
|
test_files: []
|
data/lib/dsl/python/import.rb
DELETED