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
@@ -0,0 +1,184 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # color_scheme.rb
4
+ #
5
+ # Created by Richard LeBer on 2011-06-27.
6
+ # Copyright 2011. All rights reserved
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details
9
+
10
+ class HighLine
11
+
12
+ def self.Style(*args)
13
+ args = args.compact.flatten
14
+ if args.size==1
15
+ arg = args.first
16
+ if arg.is_a?(Style)
17
+ Style.list[arg.name] || Style.index(arg)
18
+ elsif arg.is_a?(::String) && arg =~ /^\e\[/ # arg is a code
19
+ if styles = Style.code_index[arg]
20
+ styles.first
21
+ else
22
+ Style.new(:code=>arg)
23
+ end
24
+ elsif style = Style.list[arg]
25
+ style
26
+ elsif HighLine.color_scheme && HighLine.color_scheme[arg]
27
+ HighLine.color_scheme[arg]
28
+ elsif arg.is_a?(Hash)
29
+ Style.new(arg)
30
+ elsif arg.to_s.downcase =~ /^rgb_([a-f0-9]{6})$/
31
+ Style.rgb($1)
32
+ elsif arg.to_s.downcase =~ /^on_rgb_([a-f0-9]{6})$/
33
+ Style.rgb($1).on
34
+ else
35
+ raise NameError, "#{arg.inspect} is not a defined Style"
36
+ end
37
+ else
38
+ name = args
39
+ Style.list[name] || Style.new(:list=>args)
40
+ end
41
+ end
42
+
43
+ class Style
44
+
45
+ def self.index(style)
46
+ if style.name
47
+ @@styles ||= {}
48
+ @@styles[style.name] = style
49
+ end
50
+ if !style.list
51
+ @@code_index ||= {}
52
+ @@code_index[style.code] ||= []
53
+ @@code_index[style.code].reject!{|indexed_style| indexed_style.name == style.name}
54
+ @@code_index[style.code] << style
55
+ end
56
+ style
57
+ end
58
+
59
+ def self.rgb_hex(*colors)
60
+ colors.map do |color|
61
+ color.is_a?(Numeric) ? '%02x'%color : color.to_s
62
+ end.join
63
+ end
64
+
65
+ def self.rgb_parts(hex)
66
+ hex.scan(/../).map{|part| part.to_i(16)}
67
+ end
68
+
69
+ def self.rgb(*colors)
70
+ hex = rgb_hex(*colors)
71
+ name = ('rgb_' + hex).to_sym
72
+ if style = list[name]
73
+ style
74
+ else
75
+ parts = rgb_parts(hex)
76
+ new(:name=>name, :code=>"\e[38;5;#{rgb_number(parts)}m", :rgb=>parts)
77
+ end
78
+ end
79
+
80
+ def self.rgb_number(*parts)
81
+ parts = parts.flatten
82
+ 16 + parts.inject(0) {|kode, part| kode*6 + (part/256.0*6.0).floor}
83
+ end
84
+
85
+ def self.ansi_rgb_to_hex(ansi_number)
86
+ raise "Invalid ANSI rgb code #{ansi_number}" unless (16..231).include?(ansi_number)
87
+ parts = (ansi_number-16).to_s(6).rjust(3,'0').scan(/./).map{|d| (d.to_i*255.0/6.0).ceil}
88
+ rgb_hex(*parts)
89
+ end
90
+
91
+ def self.list
92
+ @@styles ||= {}
93
+ end
94
+
95
+ def self.code_index
96
+ @@code_index ||= {}
97
+ end
98
+
99
+ def self.uncolor(string)
100
+ string.gsub(/\e\[\d+(;\d+)*m/, '')
101
+ end
102
+
103
+ attr_reader :name, :code, :list
104
+ attr_accessor :rgb, :builtin
105
+
106
+ # Single color/styles have :name, :code, :rgb (possibly), :builtin
107
+ # Compound styles have :name, :list, :builtin
108
+ def initialize(defn = {})
109
+ @definition = defn
110
+ @name = defn[:name]
111
+ @code = defn[:code]
112
+ @rgb = defn[:rgb]
113
+ @list = defn[:list]
114
+ @builtin = defn[:builtin]
115
+ if @rgb
116
+ hex = self.class.rgb_hex(@rgb)
117
+ rgb = self.class.rgb_parts(hex)
118
+ @name ||= 'rgb_' + hex
119
+ elsif @list
120
+ @name ||= @list
121
+ end
122
+ self.class.index self unless defn[:no_index]
123
+ end
124
+
125
+ def dup
126
+ self.class.new(@definition)
127
+ end
128
+
129
+ def to_hash
130
+ @definition
131
+ end
132
+
133
+ def color(string)
134
+ code + string + HighLine::CLEAR
135
+ end
136
+
137
+ def code
138
+ if @list
139
+ @list.map{|element| HighLine.Style(element).code}.join
140
+ else
141
+ @code
142
+ end
143
+ end
144
+
145
+ def red
146
+ @rgb && @rgb[0]
147
+ end
148
+
149
+ def green
150
+ @rgb && @rgb[1]
151
+ end
152
+
153
+ def blue
154
+ @rgb && @rgb[2]
155
+ end
156
+
157
+ def variant(new_name, options={})
158
+ raise "Cannot create a variant of a style list (#{inspect})" if @list
159
+ new_code = options[:code] || code
160
+ if options[:increment]
161
+ raise "Unexpected code in #{inspect}" unless new_code =~ /^(.*?)(\d+)(.*)/
162
+ new_code = $1 + ($2.to_i + options[:increment]).to_s + $3
163
+ end
164
+ new_rgb = options[:rgb] || @rgb
165
+ new_style = self.class.new(self.to_hash.merge(:name=>new_name, :code=>new_code, :rgb=>new_rgb))
166
+ end
167
+
168
+ def on
169
+ new_name = ('on_'+@name.to_s).to_sym
170
+ self.class.list[new_name] ||= variant(new_name, :increment=>10)
171
+ end
172
+
173
+ def bright
174
+ raise "Cannot create a bright variant of a style list (#{inspect})" if @list
175
+ new_name = ('bright_'+@name.to_s).to_sym
176
+ if style = self.class.list[new_name]
177
+ style
178
+ else
179
+ new_rgb = @rgb == [0,0,0] ? [128, 128, 128] : @rgb.map {|color| color==0 ? 0 : [color+128,255].min }
180
+ variant(new_name, :increment=>60, :rgb=>new_rgb)
181
+ end
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,180 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # system_extensions.rb
4
+ #
5
+ # Created by James Edward Gray II on 2006-06-14.
6
+ # Copyright 2006 Gray Productions. All rights reserved.
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details.
9
+
10
+ require "highline/compatibility"
11
+
12
+ class HighLine
13
+ module SystemExtensions
14
+ module_function
15
+
16
+ JRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
17
+
18
+ #
19
+ # This section builds character reading and terminal size functions
20
+ # to suit the proper platform we're running on. Be warned: Here be
21
+ # dragons!
22
+ #
23
+ begin
24
+ # Cygwin will look like Windows, but we want to treat it like a Posix OS:
25
+ raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i
26
+
27
+ require "Win32API" # See if we're on Windows.
28
+
29
+ CHARACTER_MODE = "Win32API" # For Debugging purposes only.
30
+
31
+ #
32
+ # Windows savvy getc().
33
+ #
34
+ # *WARNING*: This method ignores <tt>input</tt> and reads one
35
+ # character from +STDIN+!
36
+ #
37
+ def get_character( input = STDIN )
38
+ Win32API.new("msvcrt", "_getch", [ ], "L").Call
39
+ rescue Exception
40
+ Win32API.new("crtdll", "_getch", [ ], "L").Call
41
+ end
42
+
43
+ # A Windows savvy method to fetch the console columns, and rows.
44
+ def terminal_size
45
+ m_GetStdHandle = Win32API.new( 'kernel32',
46
+ 'GetStdHandle',
47
+ ['L'],
48
+ 'L' )
49
+ m_GetConsoleScreenBufferInfo = Win32API.new(
50
+ 'kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L'
51
+ )
52
+
53
+ format = 'SSSSSssssSS'
54
+ buf = ([0] * format.size).pack(format)
55
+ stdout_handle = m_GetStdHandle.call(0xFFFFFFF5)
56
+
57
+ m_GetConsoleScreenBufferInfo.call(stdout_handle, buf)
58
+ bufx, bufy, curx, cury, wattr,
59
+ left, top, right, bottom, maxx, maxy = buf.unpack(format)
60
+ return right - left + 1, bottom - top + 1
61
+ end
62
+ rescue LoadError # If we're not on Windows try...
63
+ begin
64
+ require "termios" # Unix, first choice termios.
65
+
66
+ CHARACTER_MODE = "termios" # For Debugging purposes only.
67
+
68
+ #
69
+ # Unix savvy getc(). (First choice.)
70
+ #
71
+ # *WARNING*: This method requires the "termios" library!
72
+ #
73
+ def get_character( input = STDIN )
74
+ return input.getbyte if input.is_a? StringIO
75
+
76
+ old_settings = Termios.getattr(input)
77
+
78
+ new_settings = old_settings.dup
79
+ new_settings.c_lflag &= ~(Termios::ECHO | Termios::ICANON)
80
+ new_settings.c_cc[Termios::VMIN] = 1
81
+
82
+ begin
83
+ Termios.setattr(input, Termios::TCSANOW, new_settings)
84
+ input.getbyte
85
+ ensure
86
+ Termios.setattr(input, Termios::TCSANOW, old_settings)
87
+ end
88
+ end
89
+ rescue LoadError # If our first choice fails, try using ffi-ncurses.
90
+ begin
91
+ require 'ffi-ncurses' # The ffi gem is builtin to JRUBY and because stty does not
92
+ # work correctly in JRuby manually installing the ffi-ncurses
93
+ # gem is the only way to get highline to operate correctly in
94
+ # JRuby. The ncurses library is only present on unix platforms
95
+ # so this is not a solution for using highline in JRuby on
96
+ # windows.
97
+
98
+ CHARACTER_MODE = "ncurses" # For Debugging purposes only.
99
+
100
+ #
101
+ # ncurses savvy getc().
102
+ #
103
+ def get_character( input = STDIN )
104
+ FFI::NCurses.initscr
105
+ FFI::NCurses.cbreak
106
+ begin
107
+ FFI::NCurses.curs_set 0
108
+ input.getbyte
109
+ ensure
110
+ FFI::NCurses.endwin
111
+ end
112
+ end
113
+
114
+ rescue LoadError => e # If the ffi-ncurses choice fails, try using stty
115
+ CHARACTER_MODE = "stty" # For Debugging purposes only.
116
+
117
+ #
118
+ # Unix savvy getc(). (Second choice.)
119
+ #
120
+ # *WARNING*: This method requires the external "stty" program!
121
+ #
122
+ def get_character( input = STDIN )
123
+ raw_no_echo_mode
124
+
125
+ begin
126
+ input.getbyte
127
+ ensure
128
+ restore_mode
129
+ end
130
+ end
131
+
132
+ #
133
+ # Switched the input mode to raw and disables echo.
134
+ #
135
+ # *WARNING*: This method requires the external "stty" program!
136
+ #
137
+ def raw_no_echo_mode
138
+ @state = `stty -g`
139
+ system "stty raw -echo -icanon isig"
140
+ end
141
+
142
+ #
143
+ # Restores a previously saved input mode.
144
+ #
145
+ # *WARNING*: This method requires the external "stty" program!
146
+ #
147
+ def restore_mode
148
+ system "stty #{@state}"
149
+ end
150
+ end
151
+ end
152
+ if CHARACTER_MODE == 'ncurses'
153
+ #
154
+ # A ncurses savvy method to fetch the console columns, and rows.
155
+ #
156
+ def terminal_size
157
+ size = [80, 40]
158
+ FFI::NCurses.initscr
159
+ begin
160
+ size = FFI::NCurses.getmaxyx(stdscr).reverse
161
+ ensure
162
+ FFI::NCurses.endwin
163
+ end
164
+ size
165
+ end
166
+ else
167
+ # A Unix savvy method using stty that to fetch the console columns, and rows.
168
+ # ... stty does not work in JRuby
169
+ def terminal_size
170
+ if /solaris/ =~ RUBY_PLATFORM and
171
+ `stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/
172
+ [$2, $1].map { |c| x.to_i }
173
+ else
174
+ `stty size`.split.map { |x| x.to_i }.reverse
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end