printsly 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/common_stuff.rb +14 -0
  3. data/lib/menu.rb +131 -170
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8da3d85ea277260cdc0fac34aae335958ffd635c
4
- data.tar.gz: 98d17e2ba3ca4ae2e42523d24abac413dbc46bc5
3
+ metadata.gz: f8ff8cb068d5c872fd0032f609cb3974082e8835
4
+ data.tar.gz: d46face78c4e39059a0f1bd64bbe7b8465511032
5
5
  SHA512:
6
- metadata.gz: 1c1c0f6663544bee54fd44eeaabab71d652d889509f462d903406d603c42223875e7bf223604b334089987f638a93008ee9abc9a567b302080829ee0f48bd84b
7
- data.tar.gz: f861e7073bb230ec2faaa42cd8fb982fb95fc4d604ca38998d44ff7a01c40d43f471ff232fc69d7a518254233f13617b19d8a2dce71920ff0a48565f0ab046bd
6
+ metadata.gz: b910269dafb13132a9d3481399eefb9910569e9ace4c6c4691667afd846358e83426e93f5af2262278c3b544a99026d968b12b4df8e9022c42aac3762056e309
7
+ data.tar.gz: 23e0abbf1104d1cba54bc5b734200047932fba5122f49a1371d14bc53e875dea742779be311a896df48ad3617282f4dd2ab8a58dbc5b67dedd8cd8928dc73a89
@@ -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
@@ -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
- puts "If this is the first time to run Printsly, please choose " + "[3]".yellow + " and configure."
11
- puts #format
12
- puts "The configuration file is stored in your home directory by default."
13
- work_dir = "Not Set" if work_dir.nil? || work_dir.empty?
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
- puts # formatting
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
- 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.choices
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
77
- end
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 # formatting
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 choices
93
- move = 0
94
- until move == "3"
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 initialize
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
- auto_text
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
- puts # formatting
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
- case
175
- when move == "1"
176
- begin
177
- work_dir_text
178
- puts #format
179
- puts "The working directory is currently: " + work_dir.green
180
- work_dir = choose_file
181
- puts #format
182
- puts "You have chosen " + work_dir.yellow + " Is this correct?"
183
- yes_no
184
- end while not (@yes_no == "yes")
185
- when move == "2"
186
- batchy_text
187
- puts #format
188
- puts "Batch mode is currently turned " + batchy.green + "."
189
- puts #format
190
- case
191
- when batchy == "Off"
192
- puts "Turn batch mode on?"
193
- begin
194
- yes_no
195
- end while not (@yes_no == "yes" or @yes_no == "no")
196
- batchy = "On" if @yes_no == "yes"
197
- when
198
- batchy == "On"
199
- puts "Turn batch mode off?"
200
- begin
201
- yes_no
202
- end while not (@yes_no == "yes" or @yes_no == "no")
203
- batchy = "Off" if @yes_no == "yes"
204
- end
205
- when move == "3"
206
- auto_text
207
- puts #format
208
- puts "Auto provision is currently turned " + auto_mater.green + "."
209
- puts #format
210
- case
211
- when auto_mater == "Off"
212
- puts "Turn auto provision on?"
213
- begin
214
- yes_no
215
- end while not (@yes_no == "yes" or @yes_no == "no")
216
- auto_mater = "On" if @yes_no == "yes"
217
- when
218
- auto_mater == "On"
219
- puts "Turn auto provision off?"
220
- begin
221
- yes_no
222
- end while not (@yes_no == "yes" or @yes_no == "no")
223
- auto_mater = "Off" if @yes_no == "yes"
224
- end
225
- when move == "4"
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.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-01-27 00:00:00.000000000 Z
11
+ date: 2015-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spreadsheet