challah 0.3.4 → 0.3.5

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.
Files changed (48) hide show
  1. data/CHANGELOG.md +4 -0
  2. data/lib/challah/version.rb +1 -1
  3. data/lib/tasks/crud.rake +23 -53
  4. data/vendor/bundle/cache/highline-1.6.11.gem +0 -0
  5. data/vendor/bundle/gems/highline-1.6.11/AUTHORS +3 -0
  6. data/vendor/bundle/gems/highline-1.6.11/CHANGELOG +304 -0
  7. data/vendor/bundle/gems/highline-1.6.11/COPYING +340 -0
  8. data/vendor/bundle/gems/highline-1.6.11/INSTALL +55 -0
  9. data/vendor/bundle/gems/highline-1.6.11/LICENSE +7 -0
  10. data/vendor/bundle/gems/highline-1.6.11/README +63 -0
  11. data/vendor/bundle/gems/highline-1.6.11/Rakefile +53 -0
  12. data/vendor/bundle/gems/highline-1.6.11/TODO +6 -0
  13. data/vendor/bundle/gems/highline-1.6.11/examples/ansi_colors.rb +38 -0
  14. data/vendor/bundle/gems/highline-1.6.11/examples/asking_for_arrays.rb +18 -0
  15. data/vendor/bundle/gems/highline-1.6.11/examples/basic_usage.rb +75 -0
  16. data/vendor/bundle/gems/highline-1.6.11/examples/color_scheme.rb +32 -0
  17. data/vendor/bundle/gems/highline-1.6.11/examples/limit.rb +12 -0
  18. data/vendor/bundle/gems/highline-1.6.11/examples/menus.rb +65 -0
  19. data/vendor/bundle/gems/highline-1.6.11/examples/overwrite.rb +19 -0
  20. data/vendor/bundle/gems/highline-1.6.11/examples/page_and_wrap.rb +322 -0
  21. data/vendor/bundle/gems/highline-1.6.11/examples/password.rb +7 -0
  22. data/vendor/bundle/gems/highline-1.6.11/examples/trapping_eof.rb +22 -0
  23. data/vendor/bundle/gems/highline-1.6.11/examples/using_readline.rb +17 -0
  24. data/vendor/bundle/gems/highline-1.6.11/highline.gemspec +36 -0
  25. data/vendor/bundle/gems/highline-1.6.11/lib/highline/color_scheme.rb +136 -0
  26. data/vendor/bundle/gems/highline-1.6.11/lib/highline/compatibility.rb +16 -0
  27. data/vendor/bundle/gems/highline-1.6.11/lib/highline/import.rb +43 -0
  28. data/vendor/bundle/gems/highline-1.6.11/lib/highline/menu.rb +398 -0
  29. data/vendor/bundle/gems/highline-1.6.11/lib/highline/question.rb +465 -0
  30. data/vendor/bundle/gems/highline-1.6.11/lib/highline/string_extensions.rb +98 -0
  31. data/vendor/bundle/gems/highline-1.6.11/lib/highline/style.rb +184 -0
  32. data/vendor/bundle/gems/highline-1.6.11/lib/highline/system_extensions.rb +180 -0
  33. data/vendor/bundle/gems/highline-1.6.11/lib/highline.rb +978 -0
  34. data/vendor/bundle/gems/highline-1.6.11/setup.rb +1360 -0
  35. data/vendor/bundle/gems/highline-1.6.11/site/highline.css +65 -0
  36. data/vendor/bundle/gems/highline-1.6.11/site/images/logo.png +0 -0
  37. data/vendor/bundle/gems/highline-1.6.11/site/index.html +58 -0
  38. data/vendor/bundle/gems/highline-1.6.11/test/string_methods.rb +34 -0
  39. data/vendor/bundle/gems/highline-1.6.11/test/tc_color_scheme.rb +98 -0
  40. data/vendor/bundle/gems/highline-1.6.11/test/tc_highline.rb +962 -0
  41. data/vendor/bundle/gems/highline-1.6.11/test/tc_import.rb +54 -0
  42. data/vendor/bundle/gems/highline-1.6.11/test/tc_menu.rb +429 -0
  43. data/vendor/bundle/gems/highline-1.6.11/test/tc_string_extension.rb +22 -0
  44. data/vendor/bundle/gems/highline-1.6.11/test/tc_string_highline.rb +40 -0
  45. data/vendor/bundle/gems/highline-1.6.11/test/tc_style.rb +569 -0
  46. data/vendor/bundle/gems/highline-1.6.11/test/ts_all.rb +18 -0
  47. data/vendor/bundle/specifications/highline-1.6.11.gemspec +29 -0
  48. metadata +63 -8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Challah 0.3.5
2
+
3
+ * Now using [Highline](https://github.com/JEG2/highline) for rake tasks instead of sloppy custom methods.
4
+
1
5
  ## Challah 0.3.4
2
6
 
3
7
  * Added `challah/test` include to allow for testing in your app.
@@ -1,3 +1,3 @@
1
1
  module Challah
2
- VERSION = "0.3.4" unless defined?(::Challah::VERSION)
2
+ VERSION = "0.3.5" unless defined?(::Challah::VERSION)
3
3
  end
data/lib/tasks/crud.rake CHANGED
@@ -1,4 +1,6 @@
1
- namespace :challah do
1
+ require 'highline/import'
2
+
3
+ namespace :challah do
2
4
  namespace :permissions do
3
5
  desc "Create a new permission"
4
6
  task :create => :environment do
@@ -8,15 +10,12 @@ namespace :challah do
8
10
  banner('Creating a permission')
9
11
 
10
12
  # Grab the required fields.
11
- name = ask!('Name:')
13
+ name = ask('Permission name: ')
12
14
  key = name.to_s.parameterize.underscore
13
- key = ask("Key [#{key}]:", key)
14
- description = ask('Description [optional]:')
15
- locked = ask('Lock this permission [Yes/No, Default: No]', 'No')
16
-
17
- locked = locked.to_s.downcase.strip.first == 'y'
15
+ key = ask('Key: ') { |q| q.default = key }
16
+ description = ask('Description (optional): ')
18
17
 
19
- permission = Permission.new(:name => name, :key => key, :description => description, :locked => locked)
18
+ permission = Permission.new(:name => name, :key => key, :description => description)
20
19
 
21
20
  puts "\n"
22
21
 
@@ -38,14 +37,10 @@ namespace :challah do
38
37
  banner('Creating a role')
39
38
 
40
39
  # Grab the required fields.
41
- name = ask!('Name:')
42
- description = ask('Description [optional]:')
43
- path = ask('Default path [default: /]', '/')
44
- locked = ask('Lock this role [Yes/No, Default: No]', 'No')
40
+ name = ask('Name: ')
41
+ description = ask('Description (optional): ')
45
42
 
46
- locked = locked.to_s.downcase.strip.first == 'y'
47
-
48
- role = Role.new(:name => name, :description => description, :default_path => path, :locked => locked)
43
+ role = Role.new(:name => name, :description => description)
49
44
 
50
45
  puts "\n"
51
46
 
@@ -73,18 +68,24 @@ namespace :challah do
73
68
  end
74
69
 
75
70
  # Grab the required fields.
76
- first_name = ask!('First name:')
77
- last_name = ask!('Last name:')
78
- email = ask!('Email:')
79
- username = ask('Username [leave blank to use email address]:', email)
80
- password = ask('Password:')
71
+ first_name = ask('First name: ')
72
+ last_name = ask('Last name: ')
73
+ email = ask('Email: ')
74
+ username = ask('Username: ') { |q| q.default = email }
75
+ password = ask('Password: ') { |q| q.echo = false }
76
+ confirm = ask('Password again: ') { |q| q.echo = false }
81
77
 
82
78
  role_id = Role.admin.id
83
79
 
84
80
  # First user is always going to be an admin, otherwise ask for the role
85
81
  unless first_user
86
- role = ask_for_role
87
- role_id = role.id if role
82
+ choose do |menu|
83
+ menu.prompt = 'Choose a role for this user: '
84
+
85
+ Role.all.each do |role|
86
+ menu.choice(role.name) { role_id = role.id }
87
+ end
88
+ end
88
89
  end
89
90
 
90
91
  user = User.new(:first_name => first_name, :last_name => last_name, :email => email, :username => username, :role_id => role_id, :password => password, :password_confirmation => password)
@@ -121,35 +122,4 @@ def check_for_tables
121
122
  puts "Oops, you need to run `rake challah:setup` before you create a user. The users table is required."
122
123
  exit 1
123
124
  end
124
- end
125
-
126
- def role_names
127
- @role_names ||= Role.all.collect(&:name).sort.join('|')
128
- end
129
-
130
- def ask_for_role
131
- role_name = ask!("Role Name: [#{role_names}]")
132
- role = Role.find_by_name(role_name)
133
- return ask_for_role unless role
134
- role
135
- end
136
-
137
- def ask!(question)
138
- ask(question, nil, false)
139
- end
140
-
141
- def ask(question, default = nil, allow_blank = true)
142
- print " -> #{question} "
143
-
144
- result = STDIN.gets.chomp
145
-
146
- if result.nil? or result.to_s.strip == ""
147
- if allow_blank
148
- return default
149
- else
150
- return ask(question, default, allow_blank)
151
- end
152
- else
153
- return result
154
- end
155
125
  end
@@ -0,0 +1,3 @@
1
+ James Edward Gray II:: {james@grayproductions.net}[mailto:james@grayproductions.net]
2
+ Gregory Brown:: {gregory.t.brown@gmail.com}[mailto:gregory.t.brown@gmail.com]
3
+ Richard LeBer:: {richard.leber@gmail.com}[mailto:richard.leber@gmail.com]
@@ -0,0 +1,304 @@
1
+ = Change Log
2
+
3
+ Below is a complete listing of changes for each revision of HighLine.
4
+
5
+ == 1.6.11
6
+
7
+ * Fixed a bad test. (Fix by Diego Elio Pettenò.)
8
+
9
+ == 1.6.10
10
+
11
+ * Fixed a regression that prevented asking for String arguments (by Jeffery
12
+ Sman.)
13
+ * Fixed a testing incompatibility (by Hans de Graaff.)
14
+
15
+ == 1.6.9
16
+
17
+ * The new list modes now properly ignore escapes when sizing.
18
+ * Added a project gemspec file.
19
+ * Fixed a bug that prevented the use of termios (by tomdz).
20
+ * Switch to JLine to provide better echo support on JRuby (by tomdz).
21
+
22
+ == 1.6.8
23
+
24
+ * Fix missing <tt>ERASE_CHAR</tt> reference (by Aaron Gifford).
25
+
26
+ == 1.6.7
27
+
28
+ * Fixed bug introduced in 1.6.6 attempted fix (by Aaron Gifford).
29
+
30
+ == 1.6.6
31
+
32
+ * Fixed old style references causing <tt>HighLine::String</tt> errors (by Aaron Gifford).
33
+
34
+ == 1.6.5
35
+
36
+ * HighLine#list() now correctly handles empty lists (fix by Lachlan Dowding).
37
+ * HighLine#list() now supports <tt>:uneven_columns_across</tt> and
38
+ <tt>:uneven_columns_down</tt> modes.
39
+
40
+ == 1.6.4
41
+
42
+ * Add introspection methods to color_scheme: definition, keys, to_hash.
43
+ * Add tests for new methods.
44
+
45
+ == 1.6.3
46
+
47
+ * Add color NONE.
48
+ * Add RGB color capability.
49
+ * Made 'color' available as a class or instance method of HighLine, for
50
+ instance: HighLine.color("foo", :blue)) or highline_obj.color("foo", :blue)
51
+ are now both possible and equivalent.
52
+ * Add HighLine::String class with convenience methods: #color (alias
53
+ #foreground), #on (alias #background), colors, and styles. See
54
+ lib/string_extensions.rb.
55
+ * Add (optional) ability to extend String with the same convenience methods from
56
+ HighLine::String, using Highline.colorize_strings.
57
+
58
+ == 1.6.2
59
+
60
+ * Correctly handle STDIN being closed before we receive any data (fix by
61
+ mleinart).
62
+ * Try if msvcrt, if we can't load crtdll on Windows (fix by pepijnve).
63
+ * A fix for nil_on_handled not running the action (reported by Andrew Davey).
64
+
65
+ == 1.6.1
66
+
67
+ * Fixed raw_no_echo_mode so that it uses stty -icanon rather than cbreak
68
+ as cbreak does not appear to be the posixly correct argument. It fails
69
+ on Solaris if cbreak is used.
70
+ * Fixed an issue that kept Menu from showing the correct choices for
71
+ disambiguation.
72
+ * Removed a circular require that kept Ruby 1.9.2 from loading HighLine.
73
+ * Fixed a bug that caused infinite looping when wrapping text without spaces.
74
+ * Fixed it so that :auto paging accounts for the two lines it adds.
75
+ * On JRuby, improved error message about ffi-ncurses. Before 1.5.3,
76
+ HighLine was silently swallowing error messages when ffi-ncurses gem
77
+ was installed without ncurses present on the system.
78
+ * Reverted Aaron Simmons's patch to allow redirecting STDIN on Windows. This
79
+ is the only way we could find to restore HighLine's character reading to
80
+ working order.
81
+
82
+ == 1.5.2
83
+
84
+ * Added support for using the ffi-ncurses gem which is supported in JRuby.
85
+ * Added gem build instructions.
86
+
87
+ == 1.5.1
88
+
89
+ * Fixed the long standing echo true bug.
90
+ (reported by Lauri Tuominen)
91
+ * Improved Windows API calls to support the redirection of STDIN.
92
+ (patch by Aaron Simmons)
93
+ * Updated gem specification to avoid a deprecated call.
94
+ * Made a minor documentation clarification about character mode support.
95
+ * Worked around some API changes in Ruby's standard library in Ruby 1.9.
96
+ (patch by Jake Benilov)
97
+
98
+ == 1.5.0
99
+
100
+ * Fixed a bug that would prevent Readline from showing all completions.
101
+ (reported by Yaohan Chen)
102
+ * Added the ability to pass a block to HighLine#agree().
103
+ (patch by Yaohan Chen)
104
+
105
+ == 1.4.0
106
+
107
+ * Made the code grabbing terminal size a little more cross-platform by
108
+ adding support for Solaris. (patch by Ronald Braswell and Coey Minear)
109
+
110
+ == 1.2.9
111
+
112
+ * Additional work on the backspacing issue. (patch by Jeremy Hinegardner)
113
+ * Fixed Readline prompt bug. (patch by Jeremy Hinegardner)
114
+
115
+ == 1.2.8
116
+
117
+ * Fixed backspacing past the prompt and interrupting a prompt bugs.
118
+ (patch by Jeremy Hinegardner)
119
+
120
+ == 1.2.7
121
+
122
+ * Fixed the stty indent bug.
123
+ * Fixed the echo backspace bug.
124
+ * Added HighLine::track_eof=() setting to work are threaded eof?() calls.
125
+
126
+ == 1.2.6
127
+
128
+ Patch by Jeremy Hinegardner:
129
+
130
+ * Added ColorScheme support.
131
+ * Added HighLine::Question.overwrite mode.
132
+ * Various documentation fixes.
133
+
134
+ == 1.2.5
135
+
136
+ * Really fixed the bug I tried to fix in 1.2.4.
137
+
138
+ == 1.2.4
139
+
140
+ * Fixed a crash causing bug when using menus, reported by Patrick Hof.
141
+
142
+ == 1.2.3
143
+
144
+ * Treat Cygwin like a Posix OS, instead of a native Windows environment.
145
+
146
+ == 1.2.2
147
+
148
+ * Minor documentation corrections.
149
+ * Applied Thomas Werschleiln's patch to fix termio buffering on Solaris.
150
+ * Applied Justin Bailey's patch to allow canceling paged output.
151
+ * Fixed a documentation bug in the description of character case settings.
152
+ * Added a notice about termios in HighLine::Question#echo.
153
+ * Finally working around the infamous "fast typing" bug
154
+
155
+ == 1.2.1
156
+
157
+ * Applied Justin Bailey's fix for the page_print() infinite loop bug.
158
+ * Made a SystemExtensions module to expose OS level functionality other
159
+ libraries may want to access.
160
+ * Publicly exposed the get_character() method, per user requests.
161
+ * Added terminal_size(), output_cols(), and output_rows() methods.
162
+ * Added :auto setting for warp_at=() and page_at=().
163
+
164
+ == 1.2.0
165
+
166
+ * Improved RubyForge and gem spec project descriptions.
167
+ * Added basic examples to README.
168
+ * Added a VERSION constant.
169
+ * Added support for hidden menu commands.
170
+ * Added Object.or_ask() when using highline/import.
171
+
172
+ == 1.0.4
173
+
174
+ * Moved the HighLine project to Subversion.
175
+ * HighLine's color escapes can now be disabled.
176
+ * Fixed EOF bug introduced in the last release.
177
+ * Updated HighLine web page.
178
+ * Moved to a forked development/stable version numbering.
179
+
180
+ == 1.0.2
181
+
182
+ * Removed old and broken help tests.
183
+ * Fixed test case typo found by David A. Black.
184
+ * Added ERb escapes processing to lists, for coloring list items. Color escapes
185
+ do not add to list element size.
186
+ * HighLine now throws EOFError when input is exhausted.
187
+
188
+ == 1.0.1
189
+
190
+ * Minor bug fix: Moved help initialization to before response building, so help
191
+ would show up in the default responses.
192
+
193
+ == 1.0.0
194
+
195
+ * Fixed documentation typo pointed out by Gavin Kistner.
196
+ * Added <tt>gather = ...</tt> option to question for fetching entire Arrays or
197
+ Hashes filled with answers. You can set +gather+ to a count of answers to
198
+ collect, a String or Regexp matching the end of input, or a Hash where each
199
+ key can be used in a new question.
200
+ * Added File support to HighLine.ask(). You can specify a _directory_ and a
201
+ _glob_ pattern that combine into a list of file choices the user can select
202
+ from. You can choose to receive the user's answer as an open filehandle or as
203
+ a Pathname object.
204
+ * Added Readline support for history and editing.
205
+ * Added tab completion for menu and file selection selection (requires
206
+ Readline).
207
+ * Added an optional character limit for input.
208
+ * Added a complete help system to HighLine's shell menu creation tools.
209
+
210
+ == 0.6.1
211
+
212
+ * Removed termios dependancy in gem, to fix Windows' install.
213
+
214
+ == 0.6.0
215
+
216
+ * Implemented HighLine.choose() for menu handling.
217
+ * Provided shortcut <tt>choose(item1, item2, ...)</tt> for simple menus.
218
+ * Allowed Ruby code to be attached to each menu item, to create a complete
219
+ menu solution.
220
+ * Provided for total customization of the menu layout.
221
+ * Allowed for menu selection by index, name or both.
222
+ * Added a _shell_ mode to allow menu selection with additional details
223
+ following the name.
224
+ * Added a list() utility method that can be invoked just like color(). It can
225
+ layout Arrays for you in any output in the modes <tt>:columns_across</tt>,
226
+ <tt>:columns_down</tt>, <tt>:inline</tt> and <tt>:rows</tt>
227
+ * Added support for <tt>echo = "*"</tt> style settings. User code can now
228
+ choose the echo character this way.
229
+ * Modified HighLine to user the "termios" library for character input, if
230
+ available. Will return to old behavior (using "stty"), if "termios" cannot be
231
+ loaded.
232
+ * Improved "stty" state restoring code.
233
+ * Fixed "stty" code to handle interrupt signals.
234
+ * Improved the default auto-complete error message and exposed this message
235
+ through the +responses+ interface as <tt>:no_completion</tt>.
236
+
237
+ == 0.5.0
238
+
239
+ * Implemented <tt>echo = false</tt> for HighLine::Question objects, primarily to
240
+ make fetching passwords trivial.
241
+ * Fixed an auto-complete bug that could cause a crash when the user gave an
242
+ answer that didn't complete to any valid choice.
243
+ * Implemented +case+ for HighLine::Question objects to provide character case
244
+ conversions on given answers. Can be set to <tt>:up</tt>, <tt>:down</tt>, or
245
+ <tt>:capitalize</tt>.
246
+ * Exposed <tt>@answer</tt> to the response system, to allow response that are
247
+ aware of incorrect input.
248
+ * Implemented +confirm+ for HighLine::Question objects to allow for verification
249
+ for sensitive user choices. If set to +true+, user will have to answer an
250
+ "Are you sure? " question. Can also be set to the question to confirm with
251
+ the user.
252
+
253
+ == 0.4.0
254
+
255
+ * Added <tt>@wrap_at</tt> and <tt>@page_at</tt> settings and accessors to
256
+ HighLine, to control text flow.
257
+ * Implemented line wrapping with adjustable limit.
258
+ * Implemented paged printing with adjustable limit.
259
+
260
+ == 0.3.0
261
+
262
+ * Added support for installing with setup.rb.
263
+ * All output is now treated as an ERb sequence, allowing Ruby code to be
264
+ embedded in output strings.
265
+ * Added support for ANSI color sequences in say(). (And everything else
266
+ by extension.)
267
+ * Added whitespace handling for answers. Can be set to <tt>:strip</tt>,
268
+ <tt>:chomp</tt>, <tt>:collapse</tt>, <tt>:strip_and_collapse</tt>,
269
+ <tt>:chomp_and_collapse</tt>, <tt>:remove</tt>, or <tt>:none</tt>.
270
+ * Exposed question details to ERb completion through @question, to allow for
271
+ intelligent responses.
272
+ * Simplified HighLine internals using @question.
273
+ * Added support for fetching single character input either with getc() or
274
+ HighLine's own cross-platform terminal input routine.
275
+ * Improved type conversion to handle user defined classes.
276
+
277
+ == 0.2.0
278
+
279
+ * Added Unit Tests to cover an already fixed output bug in the future.
280
+ * Added Rakefile and setup test action (default).
281
+ * Renamed HighLine::Answer to HighLine::Question to better illustrate its role.
282
+ * Renamed fetch_line() to get_response() to better define its goal.
283
+ * Simplified explain_error in terms of the Question object.
284
+ * Renamed accept?() to in_range?() to better define purpose.
285
+ * Reworked valid?() into valid_answer?() to better fit Question object.
286
+ * Reworked <tt>@member</tt> into <tt>@in</tt>, to make it easier to remember and
287
+ switched implementation to include?().
288
+ * Added range checks for @above and @below.
289
+ * Fixed the bug causing ask() to swallow NoMethodErrors.
290
+ * Rolled ask_on_error() into responses.
291
+ * Redirected imports to Kernel from Object.
292
+ * Added support for <tt>validate = lambda { ... }</tt>.
293
+ * Added default answer support.
294
+ * Fixed bug that caused ask() to die with an empty question.
295
+ * Added complete documentation.
296
+ * Improve the implemetation of agree() to be the intended "yes" or "no" only
297
+ question.
298
+ * Added Rake tasks for documentation and packaging.
299
+ * Moved project to RubyForge.
300
+
301
+ == 0.1.0
302
+
303
+ * Initial release as the solution to
304
+ {Ruby Quiz #29}[http://www.rubyquiz.com/quiz29.html].