delano-rye 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGES.txt +7 -0
  2. data/README.rdoc +2 -0
  3. data/bin/rye +1 -0
  4. data/lib/rye/box.rb +1 -1
  5. data/lib/rye.rb +8 -6
  6. data/rye.gemspec +8 -47
  7. metadata +28 -51
  8. data/bin/try +0 -201
  9. data/lib/sys.rb +0 -302
  10. data/try/copying.rb +0 -18
  11. data/try/keys.rb +0 -141
  12. data/tst/10-key1 +0 -27
  13. data/tst/10-key1.pub +0 -1
  14. data/tst/10-key2 +0 -30
  15. data/tst/10-key2.pub +0 -1
  16. data/tst/10_keys_test.rb +0 -88
  17. data/tst/50_rset_test.rb +0 -54
  18. data/tst/60-file.mp3 +0 -0
  19. data/tst/60_rbox_transfer_test.rb +0 -53
  20. data/tst/70_rbox_env_test.rb +0 -19
  21. data/vendor/highline-1.5.1/CHANGELOG +0 -222
  22. data/vendor/highline-1.5.1/INSTALL +0 -35
  23. data/vendor/highline-1.5.1/LICENSE +0 -7
  24. data/vendor/highline-1.5.1/README +0 -63
  25. data/vendor/highline-1.5.1/Rakefile +0 -82
  26. data/vendor/highline-1.5.1/TODO +0 -6
  27. data/vendor/highline-1.5.1/examples/ansi_colors.rb +0 -38
  28. data/vendor/highline-1.5.1/examples/asking_for_arrays.rb +0 -18
  29. data/vendor/highline-1.5.1/examples/basic_usage.rb +0 -75
  30. data/vendor/highline-1.5.1/examples/color_scheme.rb +0 -32
  31. data/vendor/highline-1.5.1/examples/limit.rb +0 -12
  32. data/vendor/highline-1.5.1/examples/menus.rb +0 -65
  33. data/vendor/highline-1.5.1/examples/overwrite.rb +0 -19
  34. data/vendor/highline-1.5.1/examples/page_and_wrap.rb +0 -322
  35. data/vendor/highline-1.5.1/examples/password.rb +0 -7
  36. data/vendor/highline-1.5.1/examples/trapping_eof.rb +0 -22
  37. data/vendor/highline-1.5.1/examples/using_readline.rb +0 -17
  38. data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +0 -120
  39. data/vendor/highline-1.5.1/lib/highline/compatibility.rb +0 -17
  40. data/vendor/highline-1.5.1/lib/highline/import.rb +0 -43
  41. data/vendor/highline-1.5.1/lib/highline/menu.rb +0 -395
  42. data/vendor/highline-1.5.1/lib/highline/question.rb +0 -463
  43. data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +0 -193
  44. data/vendor/highline-1.5.1/lib/highline.rb +0 -758
  45. data/vendor/highline-1.5.1/setup.rb +0 -1360
  46. data/vendor/highline-1.5.1/test/tc_color_scheme.rb +0 -56
  47. data/vendor/highline-1.5.1/test/tc_highline.rb +0 -823
  48. data/vendor/highline-1.5.1/test/tc_import.rb +0 -54
  49. data/vendor/highline-1.5.1/test/tc_menu.rb +0 -429
  50. data/vendor/highline-1.5.1/test/ts_all.rb +0 -15
@@ -1,53 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- #
4
- # Usage: test/60_rbox_upload_test.rb
5
- #
6
-
7
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
8
-
9
- require "rubygems"
10
- require "stringio"
11
- require "yaml"
12
- require "rye"
13
-
14
- tmpdir = Rye.sysinfo.tmpdir
15
-
16
- rbox = Rye::Box.new("localhost", :info => true)
17
- def rbox.rm(*args); cmd('rm', args); end
18
- rbox.rm(:r, :f, "#{tmpdir}/rye-upload") # Silently delete test dir
19
-
20
- # /tmp/rye-upload will be created if it doesn't exist
21
- rbox.upload("README.rdoc", "LICENSE.txt", "#{tmpdir}/rye-upload")
22
-
23
- # A single file can be renamed
24
- rbox.upload("README.rdoc", "#{tmpdir}/rye-upload/README-renamed")
25
-
26
- # StringIO objects can be sent as files
27
- applejack = StringIO.new
28
- applejack.puts "Delano: What's happening Applejack?"
29
- applejack.puts "Applejack: Just trying to get by."
30
- rbox.upload(applejack, "#{tmpdir}/rye-upload/applejack")
31
-
32
- rbox.upload("tst/60-file.mp3", "#{tmpdir}/rye-upload") # demonstrates
33
- rbox.upload("tst/60-file.mp3", "#{tmpdir}/rye-upload") # progress
34
- rbox.upload("tst/60-file.mp3", "#{tmpdir}/rye-upload") # bar
35
-
36
- puts "Content of /tmp/rye-upload"
37
- puts rbox.ls(:l, "#{tmpdir}/rye-upload")
38
-
39
- rbox.download("#{tmpdir}/rye-upload/README.rdoc",
40
- "#{tmpdir}/rye-upload/README-renamed", "#{tmpdir}/rye-download")
41
-
42
- # You can't download a StringIO object. This raises an exception:
43
- #rbox.download(applejack, "#{tmpdir}/rye-download/applejack")
44
- # But you can download _to_ a StringIO object
45
- applejack = StringIO.new
46
- rbox.download("#{tmpdir}/rye-upload/applejack", applejack)
47
-
48
- puts $/, "Content of /tmp/rye-download"
49
- puts rbox.ls(:l, "#{tmpdir}/rye-download")
50
-
51
- puts $/, "Content of applejack StringIO object"
52
- applejack.rewind
53
- puts applejack.read
@@ -1,19 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- #
4
- # Usage: test/70_rbox_env_test.rb
5
- #
6
-
7
- $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
8
-
9
- require "rubygems"
10
- require "stringio"
11
- require "yaml"
12
- require "rye"
13
-
14
- tmpdir = Rye.sysinfo.tmpdir
15
-
16
- rbox = Rye::Box.new("localhost", :info => true)
17
-
18
- puts rbox.getenv['HOME'] # slight delay while vars are fetched
19
- puts rbox.getenv['HOME'] # returned from memory
@@ -1,222 +0,0 @@
1
- = Change Log
2
-
3
- Below is a complete listing of changes for each revision of HighLine.
4
-
5
- == 1.5.1
6
-
7
- * Fixed the long standing echo true bug.
8
- (reported by Lauri Tuominen)
9
- * Improved Windows API calls to support the redirection of STDIN.
10
- (patch by Aaron Simmons)
11
- * Updated gem specification to avoid a deprecated call.
12
- * Made a minor documentation clarification about character mode support.
13
- * Worked around some API changes in Ruby's standard library in Ruby 1.9.
14
- (patch by Jake Benilov)
15
-
16
- == 1.5.0
17
-
18
- * Fixed a bug that would prevent Readline from showing all completions.
19
- (reported by Yaohan Chen)
20
- * Added the ability to pass a block to HighLine#agree().
21
- (patch by Yaohan Chen)
22
-
23
- == 1.4.0
24
-
25
- * Made the code grabbing terminal size a little more cross-platform by
26
- adding support for Solaris. (patch by Ronald Braswell and Coey Minear)
27
-
28
- == 1.2.9
29
-
30
- * Additional work on the backspacing issue. (patch by Jeremy Hinegardner)
31
- * Fixed Readline prompt bug. (patch by Jeremy Hinegardner)
32
-
33
- == 1.2.8
34
-
35
- * Fixed backspacing past the prompt and interrupting a prompt bugs.
36
- (patch by Jeremy Hinegardner)
37
-
38
- == 1.2.7
39
-
40
- * Fixed the stty indent bug.
41
- * Fixed the echo backspace bug.
42
- * Added HighLine::track_eof=() setting to work are threaded eof?() calls.
43
-
44
- == 1.2.6
45
-
46
- Patch by Jeremy Hinegardner:
47
-
48
- * Added ColorScheme support.
49
- * Added HighLine::Question.overwrite mode.
50
- * Various documentation fixes.
51
-
52
- == 1.2.5
53
-
54
- * Really fixed the bug I tried to fix in 1.2.4.
55
-
56
- == 1.2.4
57
-
58
- * Fixed a crash causing bug when using menus, reported by Patrick Hof.
59
-
60
- == 1.2.3
61
-
62
- * Treat Cygwin like a Posix OS, instead of a native Windows environment.
63
-
64
- == 1.2.2
65
-
66
- * Minor documentation corrections.
67
- * Applied Thomas Werschleiln's patch to fix termio buffering on Solaris.
68
- * Applied Justin Bailey's patch to allow canceling paged output.
69
- * Fixed a documentation bug in the description of character case settings.
70
- * Added a notice about termios in HighLine::Question#echo.
71
- * Finally working around the infamous "fast typing" bug
72
-
73
- == 1.2.1
74
-
75
- * Applied Justin Bailey's fix for the page_print() infinite loop bug.
76
- * Made a SystemExtensions module to expose OS level functionality other
77
- libraries may want to access.
78
- * Publicly exposed the get_character() method, per user requests.
79
- * Added terminal_size(), output_cols(), and output_rows() methods.
80
- * Added :auto setting for warp_at=() and page_at=().
81
-
82
- == 1.2.0
83
-
84
- * Improved RubyForge and gem spec project descriptions.
85
- * Added basic examples to README.
86
- * Added a VERSION constant.
87
- * Added support for hidden menu commands.
88
- * Added Object.or_ask() when using highline/import.
89
-
90
- == 1.0.4
91
-
92
- * Moved the HighLine project to Subversion.
93
- * HighLine's color escapes can now be disabled.
94
- * Fixed EOF bug introduced in the last release.
95
- * Updated HighLine web page.
96
- * Moved to a forked development/stable version numbering.
97
-
98
- == 1.0.2
99
-
100
- * Removed old and broken help tests.
101
- * Fixed test case typo found by David A. Black.
102
- * Added ERb escapes processing to lists, for coloring list items. Color escapes
103
- do not add to list element size.
104
- * HighLine now throws EOFError when input is exhausted.
105
-
106
- == 1.0.1
107
-
108
- * Minor bug fix: Moved help initialization to before response building, so help
109
- would show up in the default responses.
110
-
111
- == 1.0.0
112
-
113
- * Fixed documentation typo pointed out by Gavin Kistner.
114
- * Added <tt>gather = ...</tt> option to question for fetching entire Arrays or
115
- Hashes filled with answers. You can set +gather+ to a count of answers to
116
- collect, a String or Regexp matching the end of input, or a Hash where each
117
- key can be used in a new question.
118
- * Added File support to HighLine.ask(). You can specify a _directory_ and a
119
- _glob_ pattern that combine into a list of file choices the user can select
120
- from. You can choose to receive the user's answer as an open filehandle or as
121
- a Pathname object.
122
- * Added Readline support for history and editing.
123
- * Added tab completion for menu and file selection selection (requires
124
- Readline).
125
- * Added an optional character limit for input.
126
- * Added a complete help system to HighLine's shell menu creation tools.
127
-
128
- == 0.6.1
129
-
130
- * Removed termios dependancy in gem, to fix Windows' install.
131
-
132
- == 0.6.0
133
-
134
- * Implemented HighLine.choose() for menu handling.
135
- * Provided shortcut <tt>choose(item1, item2, ...)</tt> for simple menus.
136
- * Allowed Ruby code to be attached to each menu item, to create a complete
137
- menu solution.
138
- * Provided for total customization of the menu layout.
139
- * Allowed for menu selection by index, name or both.
140
- * Added a _shell_ mode to allow menu selection with additional details
141
- following the name.
142
- * Added a list() utility method that can be invoked just like color(). It can
143
- layout Arrays for you in any output in the modes <tt>:columns_across</tt>,
144
- <tt>:columns_down</tt>, <tt>:inline</tt> and <tt>:rows</tt>
145
- * Added support for <tt>echo = "*"</tt> style settings. User code can now
146
- choose the echo character this way.
147
- * Modified HighLine to user the "termios" library for character input, if
148
- available. Will return to old behavior (using "stty"), if "termios" cannot be
149
- loaded.
150
- * Improved "stty" state restoring code.
151
- * Fixed "stty" code to handle interrupt signals.
152
- * Improved the default auto-complete error message and exposed this message
153
- through the +responses+ interface as <tt>:no_completion</tt>.
154
-
155
- == 0.5.0
156
-
157
- * Implemented <tt>echo = false</tt> for HighLine::Question objects, primarily to
158
- make fetching passwords trivial.
159
- * Fixed an auto-complete bug that could cause a crash when the user gave an
160
- answer that didn't complete to any valid choice.
161
- * Implemented +case+ for HighLine::Question objects to provide character case
162
- conversions on given answers. Can be set to <tt>:up</tt>, <tt>:down</tt>, or
163
- <tt>:capitalize</tt>.
164
- * Exposed <tt>@answer</tt> to the response system, to allow response that are
165
- aware of incorrect input.
166
- * Implemented +confirm+ for HighLine::Question objects to allow for verification
167
- for sensitive user choices. If set to +true+, user will have to answer an
168
- "Are you sure? " question. Can also be set to the question to confirm with
169
- the user.
170
-
171
- == 0.4.0
172
-
173
- * Added <tt>@wrap_at</tt> and <tt>@page_at</tt> settings and accessors to
174
- HighLine, to control text flow.
175
- * Implemented line wrapping with adjustable limit.
176
- * Implemented paged printing with adjustable limit.
177
-
178
- == 0.3.0
179
-
180
- * Added support for installing with setup.rb.
181
- * All output is now treated as an ERb sequence, allowing Ruby code to be
182
- embedded in output strings.
183
- * Added support for ANSI color sequences in say(). (And everything else
184
- by extension.)
185
- * Added whitespace handling for answers. Can be set to <tt>:strip</tt>,
186
- <tt>:chomp</tt>, <tt>:collapse</tt>, <tt>:strip_and_collapse</tt>,
187
- <tt>:chomp_and_collapse</tt>, <tt>:remove</tt>, or <tt>:none</tt>.
188
- * Exposed question details to ERb completion through @question, to allow for
189
- intelligent responses.
190
- * Simplified HighLine internals using @question.
191
- * Added support for fetching single character input either with getc() or
192
- HighLine's own cross-platform terminal input routine.
193
- * Improved type conversion to handle user defined classes.
194
-
195
- == 0.2.0
196
-
197
- * Added Unit Tests to cover an already fixed output bug in the future.
198
- * Added Rakefile and setup test action (default).
199
- * Renamed HighLine::Answer to HighLine::Question to better illustrate its role.
200
- * Renamed fetch_line() to get_response() to better define its goal.
201
- * Simplified explain_error in terms of the Question object.
202
- * Renamed accept?() to in_range?() to better define purpose.
203
- * Reworked valid?() into valid_answer?() to better fit Question object.
204
- * Reworked <tt>@member</tt> into <tt>@in</tt>, to make it easier to remember and
205
- switched implementation to include?().
206
- * Added range checks for @above and @below.
207
- * Fixed the bug causing ask() to swallow NoMethodErrors.
208
- * Rolled ask_on_error() into responses.
209
- * Redirected imports to Kernel from Object.
210
- * Added support for <tt>validate = lambda { ... }</tt>.
211
- * Added default answer support.
212
- * Fixed bug that caused ask() to die with an empty question.
213
- * Added complete documentation.
214
- * Improve the implemetation of agree() to be the intended "yes" or "no" only
215
- question.
216
- * Added Rake tasks for documentation and packaging.
217
- * Moved project to RubyForge.
218
-
219
- == 0.1.0
220
-
221
- * Initial release as the solution to
222
- {Ruby Quiz #29}[http://www.rubyquiz.com/quiz29.html].
@@ -1,35 +0,0 @@
1
- = Installing HighLine
2
-
3
- RubyGems is the preferred easy install method for HighLine. However, you can
4
- install HighLine manually as described below.
5
-
6
- == Installing the Gem
7
-
8
- HighLine is intended to be installed via the
9
- RubyGems[http://rubyforge.org/projects/rubygems/] system. To get the latest
10
- version, simply enter the following into your command prompt:
11
-
12
- $ sudo gem install highline
13
-
14
- You must have RubyGems[http://rubyforge.org/projects/rubygems/] installed for
15
- the above to work.
16
-
17
- == Installing Manually
18
-
19
- Download the latest version of HighLine from the
20
- {RubyForge project page}[http://rubyforge.org/frs/?group_id=683]. Navigate to
21
- the root project directory and enter:
22
-
23
- $ sudo ruby setup.rb
24
-
25
- == Using termios
26
-
27
- While not a requirement, HighLine will take advantage of the termios library if
28
- installed (on Unix). This slightly improves HighLine's character reading
29
- capabilities and thus is recommended for all Unix users.
30
-
31
- If using the HighLine gem, you should be able to add termios as easily as:
32
-
33
- $ sudo gem install termios
34
-
35
- For manual installs, consult the termios documentation.
@@ -1,7 +0,0 @@
1
- = License Terms
2
-
3
- Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the
4
- {Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt] by
5
- James Edward Gray II and Greg Brown.
6
-
7
- Please email James[mailto:james@grayproductions.net] with any questions.
@@ -1,63 +0,0 @@
1
- = Read Me
2
-
3
- by James Edward Gray II
4
-
5
- == Description
6
-
7
- Welcome to HighLine.
8
-
9
- HighLine was designed to ease the tedious tasks of doing console input and
10
- output with low-level methods like gets() and puts(). HighLine provides a
11
- robust system for requesting data from a user, without needing to code all the
12
- error checking and validation rules and without needing to convert the typed
13
- Strings into what your program really needs. Just tell HighLine what you're
14
- after, and let it do all the work.
15
-
16
- == Documentation
17
-
18
- See HighLine and HighLine::Question for documentation.
19
-
20
- == Examples
21
-
22
- Basic usage:
23
-
24
- ask("Company? ") { |q| q.default = "none" }
25
-
26
- Validation:
27
-
28
- ask("Age? ", Integer) { |q| q.in = 0..105 }
29
- ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ }
30
-
31
- Type conversion for answers:
32
-
33
- ask("Birthday? ", Date)
34
- ask("Interests? (comma sep list) ", lambda { |str| str.split(/,\s*/) })
35
-
36
- Reading passwords:
37
-
38
- ask("Enter your password: ") { |q| q.echo = false }
39
- ask("Enter your password: ") { |q| q.echo = "x" }
40
-
41
- ERb based output (with HighLine's ANSI color tools):
42
-
43
- say("This should be <%= color('bold', BOLD) %>!")
44
-
45
- Menus:
46
-
47
- choose do |menu|
48
- menu.prompt = "Please choose your favorite programming language? "
49
-
50
- menu.choice(:ruby) { say("Good choice!") }
51
- menu.choices(:python, :perl) { say("Not from around here, are you?") }
52
- end
53
-
54
- For more examples see the examples/ directory of this project.
55
-
56
- == Installing
57
-
58
- See the INSTALL file for instructions.
59
-
60
- == Questions and/or Comments
61
-
62
- Feel free to email {James Edward Gray II}[mailto:james@grayproductions.net] or
63
- {Gregory Brown}[mailto:gregory.t.brown@gmail.com] with any questions.
@@ -1,82 +0,0 @@
1
- require "rake/rdoctask"
2
- require "rake/testtask"
3
- require "rake/gempackagetask"
4
-
5
- require "rubygems"
6
-
7
- dir = File.dirname(__FILE__)
8
- lib = File.join(dir, "lib", "highline.rb")
9
- version = File.read(lib)[/^\s*VERSION\s*=\s*(['"])(\d\.\d\.\d)\1/, 2]
10
-
11
- task :default => [:test]
12
-
13
- Rake::TestTask.new do |test|
14
- test.libs << "test"
15
- test.test_files = [ "test/ts_all.rb" ]
16
- test.verbose = true
17
- end
18
-
19
- Rake::RDocTask.new do |rdoc|
20
- rdoc.rdoc_files.include( "README", "INSTALL",
21
- "TODO", "CHANGELOG",
22
- "AUTHORS", "COPYING",
23
- "LICENSE", "lib/" )
24
- rdoc.main = "README"
25
- rdoc.rdoc_dir = "doc/html"
26
- rdoc.title = "HighLine Documentation"
27
- end
28
-
29
- about "Upload current documentation to Rubyforge"
30
- task :upload_docs => [:rdoc] do
31
- sh "scp -r doc/html/* " +
32
- "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/doc/"
33
- sh "scp -r site/* " +
34
- "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/"
35
- end
36
-
37
- spec = Gem::Specification.new do |spec|
38
- spec.name = "highline"
39
- spec.version = version
40
- spec.platform = Gem::Platform::RUBY
41
- spec.summary = "HighLine is a high-level command-line IO library."
42
- spec.files = Dir.glob("{examples,lib,test}/**/*.rb").
43
- delete_if { |item| item.include?("CVS") } +
44
- ["Rakefile", "setup.rb"]
45
-
46
- spec.test_files = "test/ts_all.rb"
47
- spec.has_rdoc = true
48
- spec.extra_rdoc_files = %w{README INSTALL TODO CHANGELOG LICENSE}
49
- spec.rdoc_options << '--title' << 'HighLine Documentation' <<
50
- '--main' << 'README'
51
-
52
- spec.require_path = 'lib'
53
-
54
- spec.author = "James Edward Gray II"
55
- spec.email = "james@grayproductions.net"
56
- spec.rubyforge_project = "highline"
57
- spec.homepage = "http://highline.rubyforge.org"
58
- spec.description = <<END_DESC
59
- A high-level IO library that provides validation, type conversion, and more for
60
- command-line interfaces. HighLine also includes a complete menu system that can
61
- crank out anything from simple list selection to complete shells with just
62
- minutes of work.
63
- END_DESC
64
- end
65
-
66
- Rake::GemPackageTask.new(spec) do |pkg|
67
- pkg.need_zip = true
68
- pkg.need_tar = true
69
- end
70
-
71
- about "Show library's code statistics"
72
- task :stats do
73
- require 'code_statistics'
74
- CodeStatistics.new( ["HighLine", "lib"],
75
- ["Functionals", "examples"],
76
- ["Units", "test"] ).to_s
77
- end
78
-
79
- about "Add new files to Subversion"
80
- task :add_to_svn do
81
- sh %Q{svn status | ruby -nae 'system "svn add \#{$F[1]}" if $F[0] == "?"' }
82
- end
@@ -1,6 +0,0 @@
1
- = To Do List
2
-
3
- The following is a list of planned expansions for HighLine, in no particular
4
- order.
5
-
6
- * Rent this space.
@@ -1,38 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # ansi_colors.rb
4
- #
5
- # Created by James Edward Gray II on 2005-05-03.
6
- # Copyright 2005 Gray Productions. All rights reserved.
7
-
8
- require "rubygems"
9
- require "highline/import"
10
-
11
- # Supported color sequences.
12
- colors = %w{black red green yellow blue magenta cyan white}
13
-
14
- # Using color() with symbols.
15
- colors.each_with_index do |c, i|
16
- say("This should be <%= color('#{c}', :#{c}) %>!")
17
- if i == 0
18
- say( "This should be " +
19
- "<%= color('white on #{c}', :white, :on_#{c}) %>!")
20
- else
21
- say( "This should be " +
22
- "<%= color( '#{colors[i - 1]} on #{c}',
23
- :#{colors[i - 1]}, :on_#{c} ) %>!")
24
- end
25
- end
26
-
27
- # Using color with constants.
28
- say("This should be <%= color('bold', BOLD) %>!")
29
- say("This should be <%= color('underlined', UNDERLINE) %>!")
30
-
31
- # Using constants only.
32
- say("This might even <%= BLINK %>blink<%= CLEAR %>!")
33
-
34
- # It even works with list wrapping.
35
- erb_digits = %w{Zero One Two Three Four} +
36
- ["<%= color('Five', :blue) %%>"] +
37
- %w{Six Seven Eight Nine}
38
- say("<%= list(#{erb_digits.inspect}, :columns_down, 3) %>")
@@ -1,18 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # asking_for_arrays.rb
4
- #
5
- # Created by James Edward Gray II on 2005-07-05.
6
- # Copyright 2005 Gray Productions. All rights reserved.
7
-
8
- require "rubygems"
9
- require "highline/import"
10
- require "pp"
11
-
12
- grades = ask( "Enter test scores (or a blank line to quit):",
13
- lambda { |ans| ans =~ /^-?\d+$/ ? Integer(ans) : ans} ) do |q|
14
- q.gather = ""
15
- end
16
-
17
- say("Grades:")
18
- pp grades
@@ -1,75 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # basic_usage.rb
4
- #
5
- # Created by James Edward Gray II on 2005-04-28.
6
- # Copyright 2005 Gray Productions. All rights reserved.
7
-
8
- require "rubygems"
9
- require "highline/import"
10
- require "yaml"
11
-
12
- contacts = [ ]
13
-
14
- class NameClass
15
- def self.parse( string )
16
- if string =~ /^\s*(\w+),\s*(\w+)\s*$/
17
- self.new($2, $1)
18
- else
19
- raise ArgumentError, "Invalid name format."
20
- end
21
- end
22
-
23
- def initialize(first, last)
24
- @first, @last = first, last
25
- end
26
-
27
- attr_reader :first, :last
28
- end
29
-
30
- begin
31
- entry = Hash.new
32
-
33
- # basic output
34
- say("Enter a contact:")
35
-
36
- # basic input
37
- entry[:name] = ask("Name? (last, first) ", NameClass) do |q|
38
- q.validate = /\A\w+, ?\w+\Z/
39
- end
40
- entry[:company] = ask("Company? ") { |q| q.default = "none" }
41
- entry[:address] = ask("Address? ")
42
- entry[:city] = ask("City? ")
43
- entry[:state] = ask("State? ") do |q|
44
- q.case = :up
45
- q.validate = /\A[A-Z]{2}\Z/
46
- end
47
- entry[:zip] = ask("Zip? ") do |q|
48
- q.validate = /\A\d{5}(?:-?\d{4})?\Z/
49
- end
50
- entry[:phone] = ask( "Phone? ",
51
- lambda { |p| p.delete("^0-9").
52
- sub(/\A(\d{3})/, '(\1) ').
53
- sub(/(\d{4})\Z/, '-\1') } ) do |q|
54
- q.validate = lambda { |p| p.delete("^0-9").length == 10 }
55
- q.responses[:not_valid] = "Enter a phone numer with area code."
56
- end
57
- entry[:age] = ask("Age? ", Integer) { |q| q.in = 0..105 }
58
- entry[:birthday] = ask("Birthday? ", Date)
59
- entry[:interests] = ask( "Interests? (comma separated list) ",
60
- lambda { |str| str.split(/,\s*/) } )
61
- entry[:description] = ask("Enter a description for this contact.") do |q|
62
- q.whitespace = :strip_and_collapse
63
- end
64
-
65
- contacts << entry
66
- # shortcut for yes and no questions
67
- end while agree("Enter another contact? ", true)
68
-
69
- if agree("Save these contacts? ", true)
70
- file_name = ask("Enter a file name: ") do |q|
71
- q.validate = /\A\w+\Z/
72
- q.confirm = true
73
- end
74
- File.open("#{file_name}.yaml", "w") { |file| YAML.dump(contacts, file) }
75
- end
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
-
3
- # color_scheme.rb
4
- #
5
- # Created by Jeremy Hinegardner on 2007-01-24
6
- # Copyright 2007 Jeremy Hinegardner. All rights reserved
7
-
8
- require 'rubygems'
9
- require 'highline/import'
10
-
11
- # Create a color scheme, naming color patterns with symbol names.
12
- ft = HighLine::ColorScheme.new do |cs|
13
- cs[:headline] = [ :bold, :yellow, :on_black ]
14
- cs[:horizontal_line] = [ :bold, :white, :on_blue]
15
- cs[:even_row] = [ :green ]
16
- cs[:odd_row] = [ :magenta ]
17
- end
18
-
19
- # Assign that color scheme to HighLine...
20
- HighLine.color_scheme = ft
21
-
22
- # ...and use it.
23
- say("<%= color('Headline', :headline) %>")
24
- say("<%= color('-'*20, :horizontal_line) %>")
25
-
26
- # Setup a toggle for rows.
27
- i = true
28
- ("A".."D").each do |row|
29
- row_color = i ? :even_row : :odd_row
30
- say("<%= color('#{row}', '#{row_color}') %>")
31
- i = !i
32
- end
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby -w
2
-
3
- # limit.rb
4
- #
5
- # Created by James Edward Gray II on 2008-11-12.
6
- # Copyright 2008 Gray Productions. All rights reserved.
7
-
8
- require "rubygems"
9
- require "highline/import"
10
-
11
- text = ask("Enter text (max 10 chars): ") { |q| q.limit = 10 }
12
- puts "You entered: #{text}!"