printsly 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/common_stuff.rb +14 -0
- data/lib/menu.rb +131 -170
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8ff8cb068d5c872fd0032f609cb3974082e8835
|
4
|
+
data.tar.gz: d46face78c4e39059a0f1bd64bbe7b8465511032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b910269dafb13132a9d3481399eefb9910569e9ace4c6c4691667afd846358e83426e93f5af2262278c3b544a99026d968b12b4df8e9022c42aac3762056e309
|
7
|
+
data.tar.gz: 23e0abbf1104d1cba54bc5b734200047932fba5122f49a1371d14bc53e875dea742779be311a896df48ad3617282f4dd2ab8a58dbc5b67dedd8cd8928dc73a89
|
data/lib/common_stuff.rb
CHANGED
@@ -2,6 +2,13 @@ module CommonStuff
|
|
2
2
|
|
3
3
|
@@config_file = File.join(Dir.home, "printsly.json")
|
4
4
|
|
5
|
+
def bar_both
|
6
|
+
puts # formatting
|
7
|
+
puts bar_top.yellow
|
8
|
+
puts bar_low.yellow
|
9
|
+
puts # formatting
|
10
|
+
end
|
11
|
+
|
5
12
|
def prompt
|
6
13
|
print ">> "
|
7
14
|
end
|
@@ -12,6 +19,7 @@ module CommonStuff
|
|
12
19
|
puts "Please enter " + "[yes]".yellow + " or " + "[no]".yellow + ":"
|
13
20
|
prompt; @yes_no = STDIN.gets.chomp.downcase
|
14
21
|
end while not (@yes_no == "yes" or @yes_no == "no")
|
22
|
+
@yes_no
|
15
23
|
end
|
16
24
|
|
17
25
|
def choose_file
|
@@ -65,4 +73,10 @@ module CommonStuff
|
|
65
73
|
puts "confirmation dialogue."
|
66
74
|
end
|
67
75
|
|
76
|
+
def welcome_text
|
77
|
+
puts "If this is the first time to run Printsly, please choose " + "[3]".yellow + " and configure."
|
78
|
+
puts #format
|
79
|
+
puts "The configuration file is stored in your home directory by default."
|
80
|
+
end
|
81
|
+
|
68
82
|
end
|
data/lib/menu.rb
CHANGED
@@ -7,12 +7,10 @@ class Menu
|
|
7
7
|
def initialize
|
8
8
|
case File.exists?(File.join(Dir.home, "printsly.json"))
|
9
9
|
when false
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
batchy = "Off" if batchy.nil? || batchy.empty?
|
15
|
-
auto_mater = "Off" if auto_mater.nil? || auto_mater.empty?
|
10
|
+
welcome_text
|
11
|
+
work_dir = "Not Set"
|
12
|
+
batchy = "Off"
|
13
|
+
auto_mater = "Off"
|
16
14
|
@cur_conf = fill_hash(work_dir, batchy, auto_mater)
|
17
15
|
when true
|
18
16
|
@cur_conf = load_config
|
@@ -24,10 +22,7 @@ class Menu
|
|
24
22
|
move = 0
|
25
23
|
until move == "6"
|
26
24
|
begin
|
27
|
-
|
28
|
-
puts bar_top.yellow
|
29
|
-
puts bar_low.yellow
|
30
|
-
puts # formatting
|
25
|
+
bar_both
|
31
26
|
c = Choice.new "Please choose what you would like to do:",
|
32
27
|
{
|
33
28
|
"1" => "Process Single Spreadsheet",
|
@@ -39,42 +34,46 @@ class Menu
|
|
39
34
|
}
|
40
35
|
move = c.prompt
|
41
36
|
end while not (move == "1" or move == "2" or move == "3" or move == "4" or move == "5" or move == "6")
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
37
|
+
actions(move)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def actions move
|
42
|
+
case
|
43
|
+
when move == "1"
|
44
|
+
begin
|
45
|
+
spread = choose_file
|
46
|
+
puts #formatting
|
47
|
+
puts "You have chosen " + spread.yellow + ". Is this correct?"
|
48
|
+
yes_no
|
49
|
+
end while not (@yes_no == "yes")
|
50
|
+
Printers.new.build(spread)
|
51
|
+
when move == "2"
|
52
|
+
Batch.new.process(@cur_conf)
|
53
|
+
when move == "3"
|
54
|
+
@cur_conf = Configurator.new.choices(@cur_conf)
|
55
|
+
when move == "4"
|
56
|
+
puts #format
|
57
|
+
puts "Current Working Directory: " + @cur_conf[:work_dir].green
|
58
|
+
puts "Current Batch Mode Setting: " + @cur_conf[:batchy].green
|
59
|
+
puts "Current Auto Provision Setting: " + @cur_conf[:auto_mater].green
|
60
|
+
when move == "5"
|
61
|
+
puts #format
|
62
|
+
puts "Resetting to default configuration...".yellow
|
63
|
+
sleep(0.5)
|
64
|
+
puts "...".yellow
|
65
|
+
sleep(0.5)
|
66
|
+
puts "......".red
|
67
|
+
@cur_conf = fill_hash("Not Set", "Off", "Off")
|
68
|
+
save_config(@cur_conf)
|
69
|
+
sleep(0.5)
|
70
|
+
puts ".........done!".green
|
71
|
+
when move == "6"
|
72
|
+
# leave application
|
73
|
+
puts #format
|
74
|
+
puts "As you wish.".yellow
|
75
|
+
puts #format
|
76
|
+
exit
|
78
77
|
end
|
79
78
|
end
|
80
79
|
|
@@ -84,59 +83,22 @@ class Batch
|
|
84
83
|
# Process all spreadsheets in specified directory
|
85
84
|
|
86
85
|
def initialize
|
87
|
-
puts #
|
88
|
-
puts "From here we can process all spreadsheets in the directory of your choice."
|
89
|
-
puts # formatting
|
86
|
+
puts #format
|
90
87
|
end
|
91
88
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
puts # formatting
|
96
|
-
puts bar_top.yellow
|
97
|
-
puts bar_low.yellow
|
98
|
-
puts # formatting
|
99
|
-
|
100
|
-
c = Choice.new "Please choose what you would like to do:",
|
101
|
-
{
|
102
|
-
"1" => "Choose Directory",
|
103
|
-
"2" => "Process All Spreadsheets",
|
104
|
-
"3" => "Return to Main Menu"
|
105
|
-
}
|
106
|
-
move = c.prompt
|
107
|
-
case
|
108
|
-
when move == "1"
|
109
|
-
begin
|
110
|
-
@work_dir = choose_file
|
111
|
-
puts #format
|
112
|
-
puts "You have chosen " + @work_dir.yellow + " Is this correct?"
|
113
|
-
yes_no
|
114
|
-
end while not (@yes_no == "yes")
|
115
|
-
when move == "2"
|
116
|
-
if @work_dir.nil? || @work_dir.empty? || @work_dir == "Not Set"
|
117
|
-
puts #format
|
118
|
-
puts "You must choose a directory to process!".red
|
119
|
-
begin
|
120
|
-
@work_dir = choose_file
|
121
|
-
puts #format
|
122
|
-
puts "You have chosen " + @work_dir.yellow + " Is this correct?"
|
123
|
-
yes_no
|
124
|
-
end while not (@yes_no == "yes")
|
125
|
-
end
|
126
|
-
puts #format
|
127
|
-
puts "I will process " + @work_dir.yellow + " now."
|
128
|
-
sleep(0.5)
|
129
|
-
puts "...".yellow
|
130
|
-
sleep(0.5)
|
131
|
-
puts "......".red
|
132
|
-
sleep(0.5)
|
133
|
-
puts ".........done!".green
|
134
|
-
when move == "3"
|
135
|
-
puts #format
|
136
|
-
puts "Returning to main menu.".yellow
|
137
|
-
return
|
138
|
-
end
|
89
|
+
def process(cur_conf)
|
90
|
+
if cur_conf[:work_dir] == "Not Set" || cur_conf[:auto_mater] == "Off"
|
91
|
+
cur_conf = Configurator.new.choices(cur_conf)
|
139
92
|
end
|
93
|
+
puts "Processing " + cur_conf[:work_dir].yellow + ":"
|
94
|
+
sleep(0.5)
|
95
|
+
#Printers.new.batch(cur_conf[:work_dir]) This will be used once Printers::Batch is built
|
96
|
+
puts "...".yellow
|
97
|
+
sleep(0.5)
|
98
|
+
puts "......".red
|
99
|
+
sleep(0.5)
|
100
|
+
puts ".........done!".green
|
101
|
+
Printers.new.build(cur_conf[:work_dir])
|
140
102
|
end
|
141
103
|
|
142
104
|
end
|
@@ -144,91 +106,90 @@ end
|
|
144
106
|
class Configurator
|
145
107
|
|
146
108
|
# Set and save Printsly defaults
|
147
|
-
def
|
148
|
-
File.new(File.join(Dir.home, "printsly.json"), "w+") unless File.exists?(File.join(Dir.home, "printsly.json"))
|
149
|
-
puts #format
|
150
|
-
puts "Let's configure " + "Printsly".yellow + "."
|
151
|
-
work_dir_text
|
109
|
+
def batch_mode batchy
|
152
110
|
batchy_text
|
153
|
-
|
111
|
+
puts #format
|
112
|
+
puts "Batch mode is currently turned " + batchy.green + "."
|
113
|
+
puts #format
|
114
|
+
case
|
115
|
+
when batchy == "Off"
|
116
|
+
puts "Turn batch mode on?"
|
117
|
+
@yes_no = yes_no
|
118
|
+
batchy = "On" if @yes_no == "yes"
|
119
|
+
when batchy == "On"
|
120
|
+
puts "Turn batch mode off?"
|
121
|
+
@yes_no = yes_no
|
122
|
+
puts @yes_no
|
123
|
+
batchy = "Off" if @yes_no == "yes"
|
124
|
+
end
|
125
|
+
puts batchy
|
126
|
+
batchy
|
154
127
|
end
|
155
128
|
|
156
129
|
def choices(cur_conf)
|
157
|
-
work_dir = cur_conf[:work_dir]
|
158
|
-
batchy = cur_conf[:batchy]
|
159
|
-
auto_mater = cur_conf[:auto_mater]
|
160
130
|
move = 0
|
161
131
|
until move == "4"
|
162
|
-
|
163
|
-
puts bar_top.yellow
|
164
|
-
puts bar_low.yellow
|
165
|
-
puts # formatting
|
132
|
+
bar_both
|
166
133
|
c = Choice.new "What would you like to configure?",
|
167
134
|
{
|
168
|
-
"1" => "Set Working Directory | Current: " + work_dir.green,
|
169
|
-
"2" => "Batch Mode | Current: " + batchy.green,
|
170
|
-
"3" => "Auto Provision? | Current: " + auto_mater.green,
|
135
|
+
"1" => "Set Working Directory | Current: " + cur_conf[:work_dir].green,
|
136
|
+
"2" => "Batch Mode | Current: " + cur_conf[:batchy].green,
|
137
|
+
"3" => "Auto Provision? | Current: " + cur_conf[:auto_mater].green,
|
171
138
|
"4" => "Return To Main Menu."
|
172
139
|
}
|
173
140
|
move = c.prompt
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
puts #format
|
227
|
-
puts "Returning to main menu."
|
228
|
-
@cur_conf = fill_hash(work_dir, batchy, auto_mater)
|
229
|
-
save_config(@cur_conf)
|
230
|
-
return @cur_conf
|
231
|
-
end
|
141
|
+
cur_conf = actions(move, cur_conf)
|
142
|
+
end
|
143
|
+
save_config(cur_conf)
|
144
|
+
return cur_conf
|
145
|
+
end
|
146
|
+
|
147
|
+
def actions move, cur_conf
|
148
|
+
case
|
149
|
+
when move == "1"
|
150
|
+
begin
|
151
|
+
work_dir_text
|
152
|
+
puts #format
|
153
|
+
puts "The working directory is currently: " + cur_conf[:work_dir].green
|
154
|
+
cur_conf[:work_dir] = choose_file
|
155
|
+
puts #format
|
156
|
+
puts "You have chosen " + cur_conf[:work_dir].yellow + " Is this correct?"
|
157
|
+
yes_no
|
158
|
+
end while not (@yes_no == "yes")
|
159
|
+
when move == "2"
|
160
|
+
cur_conf[:batchy] = batch_mode(cur_conf[:batchy])
|
161
|
+
when move == "3"
|
162
|
+
cur_conf[:auto_mater] = provision_mode(cur_conf[:auto_mater])
|
163
|
+
when move == "4"
|
164
|
+
puts #format
|
165
|
+
puts "Returning to main menu."
|
166
|
+
end
|
167
|
+
cur_conf
|
168
|
+
end
|
169
|
+
|
170
|
+
def initialize
|
171
|
+
File.new(File.join(Dir.home, "printsly.json"), "w+") unless File.exists?(File.join(Dir.home, "printsly.json"))
|
172
|
+
puts #format
|
173
|
+
puts "Let's configure " + "Printsly".yellow + "."
|
174
|
+
work_dir_text
|
175
|
+
batchy_text
|
176
|
+
auto_text
|
177
|
+
end
|
178
|
+
|
179
|
+
def provision_mode auto_mater
|
180
|
+
auto_text
|
181
|
+
puts #format
|
182
|
+
puts "Auto provision is currently turned " + auto_mater.green + "."
|
183
|
+
puts #format
|
184
|
+
case
|
185
|
+
when auto_mater == "Off"
|
186
|
+
puts "Turn auto provision on?"
|
187
|
+
@yes_no = yes_no
|
188
|
+
auto_mater = "On" if @yes_no == "yes"
|
189
|
+
when auto_mater == "On"
|
190
|
+
puts "Turn auto provision off?"
|
191
|
+
@yes_no = yes_no
|
192
|
+
auto_mater = "Off" if @yes_no == "yes"
|
232
193
|
end
|
233
194
|
end
|
234
195
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: printsly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kody Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spreadsheet
|