shuttle_cli 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shuttle_cli/bookmark.rb +13 -4
- data/lib/shuttle_cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fad23e01fe3de79bc2b213efc1df275f06210296
|
4
|
+
data.tar.gz: 50fdfd4f98023771c05b436211646146b90b5e0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cc464ddd40cc3ca07152ebd35152ee0b1189aa57ca86b80f904dff5f27105dd01d52234c67b534650d229d86f3f678138a12a475fc1d5587e68a0b17891e47e
|
7
|
+
data.tar.gz: 169c7f584ff5e59afe752a39c9d2fc8022c0b15526a17dfd07d67f15ffe2894cb3761679050546579409572b1fad5cadddd0a53c97334951e8adcbb4958879c5
|
data/lib/shuttle_cli/bookmark.rb
CHANGED
@@ -1,29 +1,38 @@
|
|
1
1
|
module ShuttleCli
|
2
2
|
class Bookmark
|
3
|
-
attr_accessor :children, :name, :cmd, :number
|
3
|
+
attr_accessor :children, :name, :cmd, :number, :parent
|
4
4
|
|
5
5
|
@@bookmark_number = 1
|
6
6
|
|
7
|
-
def self.new_from_json json
|
7
|
+
def self.new_from_json json, parent: nil
|
8
8
|
obj = new
|
9
9
|
# We are looking at a deep nested hash if we have more than 1 values.
|
10
10
|
if json.length == 1
|
11
11
|
obj.name = json.keys.first
|
12
12
|
obj.children = json.values.flatten.map do |h|
|
13
13
|
# Recursive extract again
|
14
|
-
new_from_json h
|
14
|
+
new_from_json h, parent: obj
|
15
15
|
end
|
16
16
|
else
|
17
17
|
obj.name = json[:name]
|
18
18
|
obj.cmd = json[:cmd]
|
19
19
|
end
|
20
|
+
obj.parent = parent
|
20
21
|
obj.number = @@bookmark_number
|
21
22
|
@@bookmark_number += 1
|
22
23
|
obj
|
23
24
|
end
|
24
25
|
|
26
|
+
def build_name
|
27
|
+
if parent
|
28
|
+
"#{parent.name} - #{name}"
|
29
|
+
else
|
30
|
+
name
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
25
34
|
def to_a
|
26
|
-
[number,
|
35
|
+
[number, build_name, cmd]
|
27
36
|
end
|
28
37
|
|
29
38
|
def connect
|
data/lib/shuttle_cli/version.rb
CHANGED