dsl-python 0.19.0 → 0.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: febe5712a15cb8f68bb07dac949484bb607d46b283a76181a63db4ddb70d6faa
4
- data.tar.gz: 5c1a5e28bbd0db0d972e494cb7fa9439432bc32b3869022e4d8d5ae9fac2270a
3
+ metadata.gz: 79b4ff2a17e321801b7d0f6f1f0ede3803b05560caca9602c2d7d190483c3a81
4
+ data.tar.gz: 4773c0bdc56d29aff9507ea1a9147abd566632b28088ed982e8882d9ce18d1ec
5
5
  SHA512:
6
- metadata.gz: cb22bfbef89bc09178df63299a45080f70212d60fcb0c48771c3a716f35c251b3685ebf88cdbbdd2b1ff413c2fe24433d5862400a871217b43fb06f6016565cd
7
- data.tar.gz: 36a5c4e75e6cdf706135159229b5f6608d5e164a8468359923149713adba10d6a28449655d856f2e6b0ca2e29fdd5f7287ecebb3d0161c71aae6914cda35bc3e
6
+ metadata.gz: ae9e7d3899600e11d18fe39f8f7e2013ff818c546598c0f8944dbf4374e152d7362a470cac93622dd878f884b353290967aa295b9cc1b52c4cf84dddb0835038
7
+ data.tar.gz: c5be922b1ab00dc12affa16cd5cf9375a71507c183260f4873c5db9f5c2c6d964752db11803dffed1213bb51e9978f79c9f7c2c005523a06b3f7ed7430c14b7a
@@ -1,22 +1,55 @@
1
1
  # frozen_string_literal: true
2
+ require "io/console"
2
3
 
3
4
  class Array
5
+ def append(item)
6
+ self.<<(item)
7
+ end
8
+
4
9
  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
10
+ names = %w[
11
+ list.__add__( list.__ge__( list.__iter__() list.__reversed__()
12
+ list.__class__( list.__getattribute__( list.__le__( list.__rmul__(
13
+ list.__class_getitem__( list.__getitem__( list.__len__() list.__setattr__(
14
+ list.__contains__( list.__getstate__() list.__lt__( list.__setitem__(
15
+ list.__delattr__( list.__gt__( list.__mul__( list.__sizeof__()
16
+ list.__delitem__( list.__hash__( list.__ne__( list.__str__(
17
+ list.__dir__() list.__iadd__( list.__new__( list.__subclasshook__(
18
+ list.__doc__( list.__imul__( list.__reduce__() list.__eq__(
19
+ list.__init__( list.__reduce_ex__() list.__format__( list.__init_subclass__()
20
+ list.__repr__()]
21
+ Dsl::Python.puts_in_columns(names.sort)
17
22
  end
18
23
 
24
+ def __add__(other) = self.concat(other)
25
+ def __getitem__(index) = self.at(index)
26
+ def __len__ = self.length
27
+ def __sizeof__ = 40 + self.count * 8
28
+ # require 'objspace'
29
+ # mi_array = ["npython", "cli", "version"]
30
+ # puts ObjectSpace.memsize_of(mi_array)
31
+ def __str__ = self.to_s
32
+
19
33
  def to_s
20
34
  inspect
21
35
  end
22
36
  end
37
+
38
+ module Dsl
39
+ module Python
40
+ def self.puts_in_columns(values)
41
+ space = " "
42
+ tab = space * 3
43
+ max_value = values.map {_1.length}.max
44
+ max_value += tab.size
45
+
46
+ max_screen = IO.console.winsize[1]
47
+ max_col = max_screen / max_value
48
+ values.each_slice(max_col) do |items|
49
+ words = items.map { _1 + space * (max_value - _1.length)}
50
+ puts words.join
51
+ end
52
+ nil
53
+ end
54
+ end
55
+ end
@@ -3,31 +3,24 @@ class String
3
3
  self % arg
4
4
  end
5
5
 
6
- def join(list)
7
- list.join(self)
8
- end
9
-
10
- def lower
11
- downcase
12
- end
13
-
14
- def upper
15
- upcase
16
- end
17
-
18
- def replace(a, b)
19
- tr(a, b)
20
- end
6
+ def join(list) = list.join(self)
7
+ def lower = downcase
8
+ def replace(a, b) = tr(a, b)
9
+ def title = capitalize
10
+ def upper = upcase
21
11
 
22
12
  def __
23
- puts " str.__add__( str.__getattribute__( str.__le__( str.__repr__()
24
- str.__class__( str.__getitem__( str.__len__() str.__rmod__(
25
- str.__contains__( str.__getnewargs__() str.__lt__( str.__rmul__(
26
- str.__delattr__( str.__getstate__() str.__mod__( str.__setattr__(
27
- str.__dir__() str.__gt__( str.__mul__( str.__sizeof__()
28
- str.__doc__ str.__hash__() str.__ne__( str.__str__()
29
- str.__eq__( str.__init__( str.__new__( str.__subclasshook__(
30
- str.__format__( str.__init_subclass__() str.__reduce__()
31
- str.__ge__( str.__iter__() str.__reduce_ex__( "
13
+ names = %w[
14
+ str.__add__( str.__getattribute__( str.__le__( str.__repr__()
15
+ str.__class__( str.__getitem__( str.__len__() str.__rmod__(
16
+ str.__contains__( str.__getnewargs__() str.__lt__( str.__rmul__(
17
+ str.__delattr__( str.__getstate__() str.__mod__( str.__setattr__(
18
+ str.__dir__() str.__gt__( str.__mul__( str.__sizeof__()
19
+ str.__doc__ str.__hash__() str.__ne__( str.__str__()
20
+ str.__eq__( str.__init__( str.__new__( str.__subclasshook__(
21
+ str.__format__( str.__init_subclass__() str.__reduce__()
22
+ str.__ge__( str.__iter__() str.__reduce_ex__(
23
+ ]
24
+ Dsl::Python.puts_in_columns(names.sort)
32
25
  end
33
26
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Dsl
4
4
  module Python
5
- VERSION = "0.19.0"
5
+ VERSION = "0.20.0"
6
6
  end
7
7
  end
8
8
 
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.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz