dsl-python 0.16.0 → 0.17.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 +1 -1
- data/bin/npython +31 -11
- data/lib/dsl/python/booleans.rb +1 -0
- data/lib/dsl/python/copyright.rb +1 -0
- data/lib/dsl/python/credits.rb +2 -1
- data/lib/dsl/python/hashes.rb +1 -0
- data/lib/dsl/python/import.rb +31 -2
- data/lib/dsl/python/klasses.rb +1 -0
- data/lib/dsl/python/license.rb +1 -0
- data/lib/dsl/python/none.rb +1 -0
- data/lib/dsl/python/ranges.rb +2 -0
- data/lib/dsl/python/version.rb +1 -1
- data/lib/dsl/python.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53730ec810f653d2a91efbc21fdfb976eb63b7449939d5ac91eb2052926a98a9
|
|
4
|
+
data.tar.gz: e42b22f0d6cf72fb20b1898940cad1f02af4d4b6d0f6e0337a063d0765ee5dd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 635779c8d1814833c4981cfe8b55dc655030faafdd35a13efa4e3e24a63f5021027f14509de2276f305967e55f1bf3ef36e5451ffa6dc7f335998d87e1e7f06c
|
|
7
|
+
data.tar.gz: 736bc13886414941ca91c99e1ef1fd12c022da9c401fd3277910d35bf6ff37b63fd3375fadd246960161336cd6418c0da153de641e5acb510c9d83cf9f128b2c
|
data/README.md
CHANGED
data/bin/npython
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
require "dsl/python"
|
|
3
|
+
require "dsl/python/version"
|
|
2
4
|
|
|
3
|
-
VERSION=
|
|
5
|
+
VERSION=Dsl::Python::VERSION
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
# Open irb
|
|
7
|
+
def open_repl
|
|
7
8
|
text = <<~TEXT
|
|
8
|
-
nPython
|
|
9
|
+
nPython #{VERSION} (main, Nov 16 1970) [GCC] on linux
|
|
9
10
|
Type "help", "copyright", "credits" or "license" for more information.
|
|
10
11
|
TEXT
|
|
11
12
|
puts text
|
|
13
|
+
system("irb --prompt simple --nocolorize --noecho-on-assignment -Ilib -rdsl/python")
|
|
14
|
+
end
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
elsif ["-v", "--version", "-V"].include? ARGV.first
|
|
16
|
+
def show_version
|
|
15
17
|
puts "npython (#{VERSION})"
|
|
16
|
-
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def show_help
|
|
17
21
|
text = <<~TEXT
|
|
18
22
|
usage: npython [option | file ]
|
|
19
23
|
Options:
|
|
@@ -22,10 +26,26 @@ elsif ["-h", "--help", "-?"].include? ARGV.first
|
|
|
22
26
|
|
|
23
27
|
Arguments:
|
|
24
28
|
file : program read from script file
|
|
25
|
-
TEXT
|
|
29
|
+
TEXT
|
|
26
30
|
puts text
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def run_program(name)
|
|
34
|
+
unless File.exist? name
|
|
35
|
+
puts "npython: can't open file '#{name}': [Errno 2] No such file or directory"
|
|
36
|
+
exit 1
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
content = File.read(name)
|
|
30
40
|
eval(content)
|
|
31
41
|
end
|
|
42
|
+
|
|
43
|
+
if ARGV.size.zero?
|
|
44
|
+
open_repl
|
|
45
|
+
elsif ["-v", "--version", "-V"].include? ARGV.first
|
|
46
|
+
show_version
|
|
47
|
+
elsif ["-h", "--help", "-?"].include? ARGV.first
|
|
48
|
+
show_help
|
|
49
|
+
else
|
|
50
|
+
run_program ARGV.first
|
|
51
|
+
end
|
data/lib/dsl/python/booleans.rb
CHANGED
data/lib/dsl/python/copyright.rb
CHANGED
data/lib/dsl/python/credits.rb
CHANGED
|
@@ -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)"
|
data/lib/dsl/python/hashes.rb
CHANGED
data/lib/dsl/python/import.rb
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
this = "this"
|
|
1
4
|
|
|
2
5
|
def import(name)
|
|
3
|
-
|
|
6
|
+
fullname = name + ".py"
|
|
7
|
+
if name.to_s == "this"
|
|
8
|
+
show_zen
|
|
9
|
+
elsif File.exist? name
|
|
4
10
|
load name
|
|
5
11
|
else
|
|
6
|
-
|
|
12
|
+
puts "npython: can't open file '#{name}': [Errno 2] No such file or directory"
|
|
7
13
|
end
|
|
8
14
|
end
|
|
15
|
+
|
|
16
|
+
def show_zen
|
|
17
|
+
text = <<~TEXT
|
|
18
|
+
El Zen de nPython (Inspirado por Matz)
|
|
19
|
+
|
|
20
|
+
1. La felicidad del programador es el fin último.
|
|
21
|
+
2. Lo natural es mejor que lo explícito.
|
|
22
|
+
3. La libertad es mejor que la restricción.
|
|
23
|
+
4. La elegancia supera a la brevedad.
|
|
24
|
+
5. Muchos caminos son mejores que uno solo (TIMTOWTDI).
|
|
25
|
+
6. Si el código se lee como prosa, es buen código.
|
|
26
|
+
7. No castigues al programador por ser inteligente.
|
|
27
|
+
8. La pureza del objeto es sagrada.
|
|
28
|
+
9. La metaprogramación es un superpoder, úsalo con sabiduría.
|
|
29
|
+
10. El lenguaje debe adaptarse al humano, no el humano al lenguaje.
|
|
30
|
+
11. Un bloque es a menudo la respuesta.
|
|
31
|
+
12. Los símbolos son mejores que los strings para la identidad.
|
|
32
|
+
13. El principio de Menor Sorpresa es subjetivo, pero vital.
|
|
33
|
+
14. Si te hace sonreír al escribirlo, es Ruby.
|
|
34
|
+
TEXT
|
|
35
|
+
puts text
|
|
36
|
+
"(Zen)"
|
|
37
|
+
end
|
data/lib/dsl/python/klasses.rb
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
data/lib/dsl/python/license.rb
CHANGED
data/lib/dsl/python/none.rb
CHANGED
data/lib/dsl/python/ranges.rb
CHANGED
data/lib/dsl/python/version.rb
CHANGED
data/lib/dsl/python.rb
CHANGED
|
@@ -6,6 +6,7 @@ require_relative "python/copyright"
|
|
|
6
6
|
require_relative "python/credits"
|
|
7
7
|
require_relative "python/none"
|
|
8
8
|
require_relative "python/hashes"
|
|
9
|
+
require_relative "python/import"
|
|
9
10
|
require_relative "python/license"
|
|
10
11
|
require_relative "python/ranges"
|
|
11
12
|
require_relative "python/strings"
|