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.rb +8 -6
  5. data/lib/rye/box.rb +1 -1
  6. data/rye.gemspec +8 -47
  7. metadata +29 -52
  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.rb +0 -758
  39. data/vendor/highline-1.5.1/lib/highline/color_scheme.rb +0 -120
  40. data/vendor/highline-1.5.1/lib/highline/compatibility.rb +0 -17
  41. data/vendor/highline-1.5.1/lib/highline/import.rb +0 -43
  42. data/vendor/highline-1.5.1/lib/highline/menu.rb +0 -395
  43. data/vendor/highline-1.5.1/lib/highline/question.rb +0 -463
  44. data/vendor/highline-1.5.1/lib/highline/system_extensions.rb +0 -193
  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,19 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # overwrite.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
- prompt = "here is your password:"
12
- ask(
13
- "#{prompt} <%= color('mypassword', RED, BOLD) %> (Press Any Key to blank) "
14
- ) do |q|
15
- q.overwrite = true
16
- q.echo = false # overwrite works best when echo is false.
17
- q.character = true # if this is set to :getc then overwrite does not work
18
- end
19
- say("<%= color('Look! blanked out!', GREEN) %>")
@@ -1,322 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # page_and_wrap.rb
4
- #
5
- # Created by James Edward Gray II on 2005-05-07.
6
- # Copyright 2005 Gray Productions. All rights reserved.
7
-
8
- require "rubygems"
9
- require "highline/import"
10
-
11
- $terminal.wrap_at = 80
12
- $terminal.page_at = 22
13
-
14
- say(<<END)
15
- THE UNITED STATES CONSTITUTION
16
-
17
- We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.
18
-
19
- Article. I.
20
-
21
- Section 1.
22
-
23
- All legislative Powers herein granted shall be vested in a Congress of the United States, which shall consist of a Senate and House of Representatives.
24
-
25
- Section. 2.
26
-
27
- Clause 1: The House of Representatives shall be composed of Members chosen every second Year by the People of the several States, and the Electors in each State shall have the Qualifications requisite for Electors of the most numerous Branch of the State Legislature.
28
-
29
- Clause 2: No Person shall be a Representative who shall not have attained to the Age of twenty five Years, and been seven Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of that State in which he shall be chosen.
30
-
31
- Clause 3: Representatives and direct Taxes shall be apportioned among the several States which may be included within this Union, according to their respective Numbers, which shall be determined by adding to the whole Number of free Persons, including those bound to Service for a Term of Years, and excluding Indians not taxed, three fifths of all other Persons. (See Note 2) The actual Enumeration shall be made within three Years after the first Meeting of the Congress of the United States, and within every subsequent Term of ten Years, in such Manner as they shall by Law direct. The Number of Representatives shall not exceed one for every thirty Thousand, but each State shall have at Least one Representative; and until such enumeration shall be made, the State of New Hampshire shall be entitled to chuse three, Massachusetts eight, Rhode-Island and Providence Plantations one, Connecticut five, New-York six, New Jersey four, Pennsylvania eight, Delaware one, Maryland six, Virginia ten, North Carolina five, South Carolina five, and Georgia three.
32
-
33
- Clause 4: When vacancies happen in the Representation from any State, the Executive Authority thereof shall issue Writs of Election to fill such Vacancies.
34
-
35
- Clause 5: The House of Representatives shall chuse their Speaker and other Officers; and shall have the sole Power of Impeachment.
36
-
37
- Section. 3.
38
-
39
- Clause 1: The Senate of the United States shall be composed of two Senators from each State, chosen by the Legislature thereof, (See Note 3) for six Years; and each Senator shall have one Vote.
40
-
41
- Clause 2: Immediately after they shall be assembled in Consequence of the first Election, they shall be divided as equally as may be into three Classes. The Seats of the Senators of the first Class shall be vacated at the Expiration of the second Year, of the second Class at the Expiration of the fourth Year, and of the third Class at the Expiration of the sixth Year, so that one third may be chosen every second Year; and if Vacancies happen by Resignation, or otherwise, during the Recess of the Legislature of any State, the Executive thereof may make temporary Appointments until the next Meeting of the Legislature, which shall then fill such Vacancies. (See Note 4)
42
-
43
- Clause 3: No Person shall be a Senator who shall not have attained to the Age of thirty Years, and been nine Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of that State for which he shall be chosen.
44
-
45
- Clause 4: The Vice President of the United States shall be President of the Senate, but shall have no Vote, unless they be equally divided.
46
-
47
- Clause 5: The Senate shall chuse their other Officers, and also a President pro tempore, in the Absence of the Vice President, or when he shall exercise the Office of President of the United States.
48
-
49
- Clause 6: The Senate shall have the sole Power to try all Impeachments. When sitting for that Purpose, they shall be on Oath or Affirmation. When the President of the United States is tried, the Chief Justice shall preside: And no Person shall be convicted without the Concurrence of two thirds of the Members present.
50
-
51
- Clause 7: Judgment in Cases of Impeachment shall not extend further than to removal from Office, and disqualification to hold and enjoy any Office of honor, Trust or Profit under the United States: but the Party convicted shall nevertheless be liable and subject to Indictment, Trial, Judgment and Punishment, according to Law.
52
-
53
- Section. 4.
54
-
55
- Clause 1: The Times, Places and Manner of holding Elections for Senators and Representatives, shall be prescribed in each State by the Legislature thereof; but the Congress may at any time by Law make or alter such Regulations, except as to the Places of chusing Senators.
56
-
57
- Clause 2: The Congress shall assemble at least once in every Year, and such Meeting shall be on the first Monday in December, (See Note 5) unless they shall by Law appoint a different Day.
58
-
59
- Section. 5.
60
-
61
- Clause 1: Each House shall be the Judge of the Elections, Returns and Qualifications of its own Members, and a Majority of each shall constitute a Quorum to do Business; but a smaller Number may adjourn from day to day, and may be authorized to compel the Attendance of absent Members, in such Manner, and under such Penalties as each House may provide.
62
-
63
- Clause 2: Each House may determine the Rules of its Proceedings, punish its Members for disorderly Behaviour, and, with the Concurrence of two thirds, expel a Member.
64
-
65
- Clause 3: Each House shall keep a Journal of its Proceedings, and from time to time publish the same, excepting such Parts as may in their Judgment require Secrecy; and the Yeas and Nays of the Members of either House on any question shall, at the Desire of one fifth of those Present, be entered on the Journal.
66
-
67
- Clause 4: Neither House, during the Session of Congress, shall, without the Consent of the other, adjourn for more than three days, nor to any other Place than that in which the two Houses shall be sitting.
68
-
69
- Section. 6.
70
-
71
- Clause 1: The Senators and Representatives shall receive a Compensation for their Services, to be ascertained by Law, and paid out of the Treasury of the United States. (See Note 6) They shall in all Cases, except Treason, Felony and Breach of the Peace, beprivileged from Arrest during their Attendance at the Session of their respective Houses, and in going to and returning from the same; and for any Speech or Debate in either House, they shall not be questioned in any other Place.
72
-
73
- Clause 2: No Senator or Representative shall, during the Time for which he was elected, be appointed to any civil Office under the Authority of the United States, which shall have been created, or the Emoluments whereof shall have been encreased during such time; and no Person holding any Office under the United States, shall be a Member of either House during his Continuance in Office.
74
-
75
- Section. 7.
76
-
77
- Clause 1: All Bills for raising Revenue shall originate in the House of Representatives; but the Senate may propose or concur with Amendments as on other Bills.
78
-
79
- Clause 2: Every Bill which shall have passed the House of Representatives and the Senate, shall, before it become a Law, be presented to the President of the United States; If he approve he shall sign it, but if not he shall return it, with his Objections to that House in which it shall have originated, who shall enter the Objections at large on their Journal, and proceed to reconsider it. If after such Reconsideration two thirds of that House shall agree to pass the Bill, it shall be sent, together with the Objections, to the other House, by which it shall likewise be reconsidered, and if approved by two thirds of that House, it shall become a Law. But in all such Cases the Votes of both Houses shall be determined by yeas and Nays, and the Names of the Persons voting for and against the Bill shall be entered on the Journal of each House respectively. If any Bill shall not be returned by the President within ten Days (Sundays excepted) after it shall have been presented to him, the Same shall be a Law, in like Manner as if he had signed it, unless the Congress by their Adjournment prevent its Return, in which Case it shall not be a Law.
80
-
81
- Clause 3: Every Order, Resolution, or Vote to which the Concurrence of the Senate and House of Representatives may be necessary (except on a question of Adjournment) shall be presented to the President of the United States; and before the Same shall take Effect, shall be approved by him, or being disapproved by him, shall be repassed by two thirds of the Senate and House of Representatives, according to the Rules and Limitations prescribed in the Case of a Bill.
82
-
83
- Section. 8.
84
-
85
- Clause 1: The Congress shall have Power To lay and collect Taxes, Duties, Imposts and Excises, to pay the Debts and provide for the common Defence and general Welfare of the United States; but all Duties, Imposts and Excises shall be uniform throughout the United States;
86
-
87
- Clause 2: To borrow Money on the credit of the United States;
88
-
89
- Clause 3: To regulate Commerce with foreign Nations, and among the several States, and with the Indian Tribes;
90
-
91
- Clause 4: To establish an uniform Rule of Naturalization, and uniform Laws on the subject of Bankruptcies throughout the United States;
92
-
93
- Clause 5: To coin Money, regulate the Value thereof, and of foreign Coin, and fix the Standard of Weights and Measures;
94
-
95
- Clause 6: To provide for the Punishment of counterfeiting the Securities and current Coin of the United States;
96
-
97
- Clause 7: To establish Post Offices and post Roads;
98
-
99
- Clause 8: To promote the Progress of Science and useful Arts, by securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries;
100
-
101
- Clause 9: To constitute Tribunals inferior to the supreme Court;
102
-
103
- Clause 10: To define and punish Piracies and Felonies committed on the high Seas, and Offences against the Law of Nations;
104
-
105
- Clause 11: To declare War, grant Letters of Marque and Reprisal, and make Rules concerning Captures on Land and Water;
106
-
107
- Clause 12: To raise and support Armies, but no Appropriation of Money to that Use shall be for a longer Term than two Years;
108
-
109
- Clause 13: To provide and maintain a Navy;
110
-
111
- Clause 14: To make Rules for the Government and Regulation of the land and naval Forces;
112
-
113
- Clause 15: To provide for calling forth the Militia to execute the Laws of the Union, suppress Insurrections and repel Invasions;
114
-
115
- Clause 16: To provide for organizing, arming, and disciplining, the Militia, and for governing such Part of them as may be employed in the Service of the United States, reserving to the States respectively, the Appointment of the Officers, and the Authority of training the Militia according to the discipline prescribed by Congress;
116
-
117
- Clause 17: To exercise exclusive Legislation in all Cases whatsoever, over such District (not exceeding ten Miles square) as may, byCession of particular States, and the Acceptance of Congress, become the Seat of the Government of the United States, and to exercise like Authority over all Places purchased by the Consent of the Legislature of the State in which the Same shall be, for the Erection of Forts, Magazines, Arsenals, dock-Yards, and other needful Buildings;--And
118
-
119
- Clause 18: To make all Laws which shall be necessary and proper for carrying into Execution the foregoing Powers, and all other Powers vested by this Constitution in the Government of the United States, or in any Department or Officer thereof.
120
-
121
- Section. 9.
122
-
123
- Clause 1: The Migration or Importation of such Persons as any of the States now existing shall think proper to admit, shall not be prohibited by the Congress prior to the Year one thousand eight hundred and eight, but a Tax or duty may be imposed on such Importation, not exceeding ten dollars for each Person.
124
-
125
- Clause 2: The Privilege of the Writ of Habeas Corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it.
126
-
127
- Clause 3: No Bill of Attainder or ex post facto Law shall be passed.
128
-
129
- Clause 4: No Capitation, or other direct, Tax shall be laid, unless in Proportion to the Census or Enumeration herein before directed to be taken. (See Note 7)
130
-
131
- Clause 5: No Tax or Duty shall be laid on Articles exported from any State.
132
-
133
- Clause 6: No Preference shall be given by any Regulation of Commerce or Revenue to the Ports of one State over those of another: nor shall Vessels bound to, or from, one State, be obliged to enter, clear, or pay Duties in another.
134
-
135
- Clause 7: No Money shall be drawn from the Treasury, but in Consequence of Appropriations made by Law; and a regular Statement and Account of the Receipts and Expenditures of all public Money shall be published from time to time.
136
-
137
- Clause 8: No Title of Nobility shall be granted by the United States: And no Person holding any Office of Profit or Trust under them, shall, without the Consent of the Congress, accept of any present, Emolument, Office, or Title, of any kind whatever, from any King, Prince, or foreign State.
138
-
139
- Section. 10.
140
-
141
- Clause 1: No State shall enter into any Treaty, Alliance, or Confederation; grant Letters of Marque and Reprisal; coin Money; emit Bills of Credit; make any Thing but gold and silver Coin a Tender in Payment of Debts; pass any Bill of Attainder, ex post facto Law, or Law impairing the Obligation of Contracts, or grant any Title of Nobility.
142
-
143
- Clause 2: No State shall, without the Consent of the Congress, lay any Imposts or Duties on Imports or Exports, except what may be absolutely necessary for executing it's inspection Laws: and the net Produce of all Duties and Imposts, laid by any State on Imports or Exports, shall be for the Use of the Treasury of the United States; and all such Laws shall be subject to the Revision and Controul of the Congress.
144
-
145
- Clause 3: No State shall, without the Consent of Congress, lay any Duty of Tonnage, keep Troops, or Ships of War in time of Peace, enter into any Agreement or Compact with another State, or with a foreign Power, or engage in War, unless actually invaded, or in such imminent Danger as will not admit of delay.
146
-
147
- Article. II.
148
-
149
- Section. 1.
150
-
151
- Clause 1: The executive Power shall be vested in a President of the United States of America. He shall hold his Office during the Term of four Years, and, together with the Vice President, chosen for the same Term, be elected, as follows
152
-
153
- Clause 2: Each State shall appoint, in such Manner as the Legislature thereof may direct, a Number of Electors, equal to the whole Number of Senators and Representatives to which the State may be entitled in the Congress: but no Senator or Representative, or Person holding an Office of Trust or Profit under the United States, shall be appointed an Elector.
154
-
155
- Clause 3: The Electors shall meet in their respective States, and vote by Ballot for two Persons, of whom one at least shall not be an Inhabitant of the same State with themselves. And they shall make a List of all the Persons voted for, and of the Number of Votes for each; which List they shall sign and certify, and transmit sealed to the Seat of the Government of the United States, directed to the President of the Senate. The President of the Senate shall, in the Presence of the Senate and House of Representatives, open all the Certificates, and the Votes shall then be counted. The Person having the greatest Number of Votes shall be the President, if such Number be a Majority of the whole Number of Electors appointed; and if there be more than one who have such Majority, and have an equal Number of Votes, then the House of Representatives shall immediately chuse by Ballot one of them for President; and if no Person have a Majority, then from the five highest on the List the said House shall in like Manner chuse the President. But in chusing the President, the Votes shall be taken by States, the Representation from each State having one Vote; A quorum for this Purpose shall consist of a Member or Members from two thirds of the States, and a Majority of all the States shall be necessary to a Choice. In every Case, after the Choice of the President, the Person having the greatest Number of Votes of the Electors shall be the Vice President. But if there should remain two or more who have equal Votes, the Senate shall chuse from them by Ballot the Vice President. (See Note 8)
156
-
157
- Clause 4: The Congress may determine the Time of chusing the Electors, and the Day on which they shall give their Votes; which Day shall be the same throughout the United States.
158
-
159
- Clause 5: No Person except a natural born Citizen, or a Citizen of the United States, at the time of the Adoption of this Constitution, shall be eligible to the Office of President; neither shall any Person be eligible to that Office who shall not have attained to the Age of thirty five Years, and been fourteen Years a Resident within the United States.
160
-
161
- Clause 6: In Case of the Removal of the President from Office, or of his Death, Resignation, or Inability to discharge the Powers and Duties of the said Office, (See Note 9) the Same shall devolve on the VicePresident, and the Congress may by Law provide for the Case of Removal, Death, Resignation or Inability, both of the President and Vice President, declaring what Officer shall then act as President, and such Officer shall act accordingly, until the Disability be removed, or a President shall be elected.
162
-
163
- Clause 7: The President shall, at stated Times, receive for his Services, a Compensation, which shall neither be encreased nor diminished during the Period for which he shall have been elected, and he shall not receive within that Period any other Emolument from the United States, or any of them.
164
-
165
- Clause 8: Before he enter on the Execution of his Office, he shall take the following Oath or Affirmation:--"I do solemnly swear (or affirm) that I will faithfully execute the Office of President of the United States, and will to the best of my Ability, preserve, protect and defend the Constitution of the United States."
166
-
167
- Section. 2.
168
-
169
- Clause 1: The President shall be Commander in Chief of the Army and Navy of the United States, and of the Militia of the several States, when called into the actual Service of the United States; he may require the Opinion, in writing, of the principal Officer in each of the executive Departments, upon any Subject relating to the Duties of their respective Offices, and he shall have Power to grant Reprieves and Pardons for Offences against the United States, except in Cases of Impeachment.
170
-
171
- Clause 2: He shall have Power, by and with the Advice and Consent of the Senate, to make Treaties, provided two thirds of the Senators present concur; and he shall nominate, and by and with the Advice and Consent of the Senate, shall appoint Ambassadors, other public Ministers and Consuls, Judges of the supreme Court, and all other Officers of the United States, whose Appointments are not herein otherwise provided for, and which shall be established by Law: but the Congress may by Law vest the Appointment of such inferior Officers, as they think proper, in the President alone, in the Courts of Law, or in the Heads of Departments.
172
-
173
- Clause 3: The President shall have Power to fill up all Vacancies that may happen during the Recess of the Senate, by granting Commissions which shall expire at the End of their next Session.
174
-
175
- Section. 3.
176
-
177
- He shall from time to time give to the Congress Information of the State of the Union, and recommend to their Consideration such Measures as he shall judge necessary and expedient; he may, on extraordinary Occasions, convene both Houses, or either of them, and in Case of Disagreement between them, with Respect to the Time of Adjournment, he may adjourn them to such Time as he shall think proper; he shall receive Ambassadors and other public Ministers; he shall take Care that the Laws be faithfully executed, and shall Commission all the Officers of the United States.
178
-
179
- Section. 4.
180
-
181
- The President, Vice President and all civil Officers of the United States, shall be removed from Office on Impeachment for, and Conviction of, Treason, Bribery, or other high Crimes and Misdemeanors.
182
-
183
- Article. III.
184
-
185
- Section. 1.
186
-
187
- The judicial Power of the United States, shall be vested in one supreme Court, and in such inferior Courts as the Congress may from time to time ordain and establish. The Judges, both of the supreme and inferior Courts, shall hold their Offices during good Behaviour, and shall, at stated Times, receive for their Services, a Compensation, which shall not be diminished during their Continuance in Office.
188
-
189
- Section. 2.
190
-
191
- Clause 1: The judicial Power shall extend to all Cases, in Law and Equity, arising under this Constitution, the Laws of the United States, and Treaties made, or which shall be made, under their Authority;--to all Cases affecting Ambassadors, other public Ministers and Consuls;--to all Cases of admiralty and maritime Jurisdiction;--to Controversies to which the United States shall be a Party;--to Controversies between two or more States;--between a State and Citizens of another State; (See Note 10)--between Citizens of different States, --between Citizens of the same State claiming Lands under Grants of different States, and between a State, or the Citizens thereof, and foreign States, Citizens or Subjects.
192
-
193
- Clause 2: In all Cases affecting Ambassadors, other public Ministers and Consuls, and those in which a State shall be Party, the supreme Court shall have original Jurisdiction. In all the other Cases before mentioned, the supreme Court shall have appellate Jurisdiction, both as to Law and Fact, with such Exceptions, and under such Regulations as the Congress shall make.
194
-
195
- Clause 3: The Trial of all Crimes, except in Cases of Impeachment, shall be by Jury; and such Trial shall be held in the State where the said Crimes shall have been committed; but when not committed within any State, the Trial shall be at such Place or Places as the Congress may by Law have directed.
196
-
197
- Section. 3.
198
-
199
- Clause 1: Treason against the United States, shall consist only in levying War against them, or in adhering to their Enemies, giving them Aid and Comfort. No Person shall be convicted of Treason unless on the Testimony of two Witnesses to the same overt Act, or on Confession in open Court.
200
-
201
- Clause 2: The Congress shall have Power to declare the Punishment of Treason, but no Attainder of Treason shall work Corruption of Blood, or Forfeiture except during the Life of the Person attainted.
202
-
203
- Article. IV.
204
-
205
- Section. 1.
206
-
207
- Full Faith and Credit shall be given in each State to the public Acts, Records, and judicial Proceedings of every other State. And the Congress may by general Laws prescribe the Manner in which such Acts, Records and Proceedings shall be proved, and the Effect thereof.
208
-
209
- Section. 2.
210
-
211
- Clause 1: The Citizens of each State shall be entitled to all Privileges and Immunities of Citizens in the several States.
212
-
213
- Clause 2: A Person charged in any State with Treason, Felony, or other Crime, who shall flee from Justice, and be found in another State, shall on Demand of the executive Authority of the State from which he fled, be delivered up, to be removed to the State having Jurisdiction of the Crime.
214
-
215
- Clause 3: No Person held to Service or Labour in one State, under the Laws thereof, escaping into another, shall, in Consequence of any Law or Regulation therein, be discharged from such Service or Labour, but shall be delivered up on Claim of the Party to whom such Service or Labour may be due. (See Note 11)
216
-
217
- Section. 3.
218
-
219
- Clause 1: New States may be admitted by the Congress into this Union; but no new State shall be formed or erected within the Jurisdiction of any other State; nor any State be formed by the Junction of two or more States, or Parts of States, without the Consent of the Legislatures of the States concerned as well as of the Congress.
220
-
221
- Clause 2: The Congress shall have Power to dispose of and make all needful Rules and Regulations respecting the Territory or other Property belonging to the United States; and nothing in this Constitution shall be so construed as to Prejudice any Claims of the United States, or of any particular State.
222
-
223
- Section. 4.
224
-
225
- The United States shall guarantee to every State in this Union a Republican Form of Government, and shall protect each of them against Invasion; and on Application of the Legislature, or of the Executive (when the Legislature cannot be convened) against domestic Violence.
226
-
227
- Article. V.
228
-
229
- The Congress, whenever two thirds of both Houses shall deem it necessary, shall propose Amendments to this Constitution, or, on the Application of the Legislatures of two thirds of the several States, shall call a Convention for proposing Amendments, which, in either Case, shall be valid to all Intents and Purposes, as Part of this Constitution, when ratified by the Legislatures of three fourths of the several States, or by Conventions in three fourths thereof, as the one or the other Mode of Ratification may be proposed by the Congress; Provided that no Amendment which may be made prior to the Year One thousand eight hundred and eight shall in any Manner affect the first and fourth Clauses in the Ninth Section of the first Article; and that no State, without its Consent, shall be deprived of its equal Suffrage in the Senate.
230
-
231
- Article. VI.
232
-
233
- Clause 1: All Debts contracted and Engagements entered into, before the Adoption of this Constitution, shall be as valid against the United States under this Constitution, as under the Confederation.
234
-
235
- Clause 2: This Constitution, and the Laws of the United States which shall be made in Pursuance thereof; and all Treaties made, or which shall be made, under the Authority of the United States, shall be the supreme Law of the Land; and the Judges in every State shall be bound thereby, any Thing in the Constitution or Laws of any State to the Contrary notwithstanding.
236
-
237
- Clause 3: The Senators and Representatives before mentioned, and the Members of the several State Legislatures, and all executive and judicial Officers, both of the United States and of the several States, shall be bound by Oath or Affirmation, to support this Constitution; but no religious Test shall ever be required as a Qualification to any Office or public Trust under the United States.
238
-
239
- Article. VII.
240
-
241
- The Ratification of the Conventions of nine States, shall be sufficient for the Establishment of this Constitution between the States so ratifying the Same.
242
- done in Convention by the Unanimous Consent of the States present the Seventeenth Day of September in the Year of our Lord one thousand seven hundred and Eighty seven and of the Independence of the United States of America the Twelfth In witness whereof We have hereunto subscribed our Names,
243
-
244
- GO WASHINGTON--Presidt. and deputy from Virginia
245
-
246
- [Signed also by the deputies of twelve States.]
247
-
248
- Delaware
249
-
250
- Geo: Read
251
- Gunning Bedford jun
252
- John Dickinson
253
- Richard Bassett
254
- Jaco: Broom
255
-
256
- Maryland
257
-
258
- James MCHenry
259
- Dan of ST ThoS. Jenifer
260
- DanL Carroll.
261
-
262
- Virginia
263
-
264
- John Blair--
265
- James Madison Jr.
266
-
267
- North Carolina
268
-
269
- WM Blount
270
- RichD. Dobbs Spaight.
271
- Hu Williamson
272
-
273
- South Carolina
274
-
275
- J. Rutledge
276
- Charles 1ACotesworth Pinckney
277
- Charles Pinckney
278
- Pierce Butler.
279
-
280
- Georgia
281
-
282
- William Few
283
- Abr Baldwin
284
-
285
- New Hampshire
286
-
287
- John Langdon
288
- Nicholas Gilman
289
-
290
- Massachusetts
291
-
292
- Nathaniel Gorham
293
- Rufus King
294
-
295
- Connecticut
296
- WM. SamL. Johnson
297
- Roger Sherman
298
-
299
- New York
300
-
301
- Alexander Hamilton
302
-
303
- New Jersey
304
-
305
- Wil: Livingston
306
- David Brearley.
307
- WM. Paterson.
308
- Jona: Dayton
309
-
310
- Pennsylvania
311
-
312
- B Franklin
313
- Thomas Mifflin
314
- RobT Morris
315
- Geo. Clymer
316
- ThoS. FitzSimons
317
- Jared Ingersoll
318
- James Wilson.
319
- Gouv Morris
320
-
321
- Attest William Jackson Secretary
322
- END
@@ -1,7 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- require "rubygems"
4
- require "highline/import"
5
-
6
- pass = ask("Enter your password: ") { |q| q.echo = false }
7
- puts "Your password is #{pass}!"
@@ -1,22 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # trapping_eof.rb
4
- #
5
- # Created by James Edward Gray II on 2006-02-20.
6
- # Copyright 2006 Gray Productions. All rights reserved.
7
-
8
- require "rubygems"
9
- require "highline/import"
10
-
11
- loop do
12
- begin
13
- name = ask("What's your name?")
14
- break if name == "exit"
15
- puts "Hello, #{name}!"
16
- rescue EOFError # HighLine throws this if @input.eof?
17
- break
18
- end
19
- end
20
-
21
- puts "Goodbye, dear friend."
22
- exit
@@ -1,17 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # using_readline.rb
4
- #
5
- # Created by James Edward Gray II on 2005-07-06.
6
- # Copyright 2005 Gray Productions. All rights reserved.
7
-
8
- require "rubygems"
9
- require "highline/import"
10
-
11
- loop do
12
- cmd = ask("Enter command: ", %w{save sample load reset quit}) do |q|
13
- q.readline = true
14
- end
15
- say("Executing \"#{cmd}\"...")
16
- break if cmd == "quit"
17
- end
@@ -1,758 +0,0 @@
1
- #!/usr/local/bin/ruby -w
2
-
3
- # highline.rb
4
- #
5
- # Created by James Edward Gray II on 2005-04-26.
6
- # Copyright 2005 Gray Productions. All rights reserved.
7
- #
8
- # See HighLine for documentation.
9
- #
10
- # This is Free Software. See LICENSE and COPYING for details.
11
-
12
- require "erb"
13
- require "optparse"
14
- require "stringio"
15
- require "abbrev"
16
- require "highline/compatibility"
17
- require "highline/system_extensions"
18
- require "highline/question"
19
- require "highline/menu"
20
- require "highline/color_scheme"
21
-
22
-
23
- #
24
- # A HighLine object is a "high-level line oriented" shell over an input and an
25
- # output stream. HighLine simplifies common console interaction, effectively
26
- # replacing puts() and gets(). User code can simply specify the question to ask
27
- # and any details about user interaction, then leave the rest of the work to
28
- # HighLine. When HighLine.ask() returns, you'll have the answer you requested,
29
- # even if HighLine had to ask many times, validate results, perform range
30
- # checking, convert types, etc.
31
- #
32
- class HighLine
33
- # The version of the installed library.
34
- VERSION = "1.5.1".freeze
35
-
36
- # An internal HighLine error. User code does not need to trap this.
37
- class QuestionError < StandardError
38
- # do nothing, just creating a unique error type
39
- end
40
-
41
- # The setting used to disable color output.
42
- @@use_color = true
43
-
44
- # Pass +false+ to _setting_ to turn off HighLine's color escapes.
45
- def self.use_color=( setting )
46
- @@use_color = setting
47
- end
48
-
49
- # Returns true if HighLine is currently using color escapes.
50
- def self.use_color?
51
- @@use_color
52
- end
53
-
54
- # The setting used to disable EOF tracking.
55
- @@track_eof = true
56
-
57
- # Pass +false+ to _setting_ to turn off HighLine's EOF tracking.
58
- def self.track_eof=( setting )
59
- @@track_eof = setting
60
- end
61
-
62
- # Returns true if HighLine is currently tracking EOF for input.
63
- def self.track_eof?
64
- @@track_eof
65
- end
66
-
67
- # The setting used to control color schemes.
68
- @@color_scheme = nil
69
-
70
- # Pass ColorScheme to _setting_ to turn set a HighLine color scheme.
71
- def self.color_scheme=( setting )
72
- @@color_scheme = setting
73
- end
74
-
75
- # Returns the current color scheme.
76
- def self.color_scheme
77
- @@color_scheme
78
- end
79
-
80
- # Returns +true+ if HighLine is currently using a color scheme.
81
- def self.using_color_scheme?
82
- not @@color_scheme.nil?
83
- end
84
-
85
- #
86
- # Embed in a String to clear all previous ANSI sequences. This *MUST* be
87
- # done before the program exits!
88
- #
89
- CLEAR = "\e[0m"
90
- # An alias for CLEAR.
91
- RESET = CLEAR
92
- # Erase the current line of terminal output.
93
- ERASE_LINE = "\e[K"
94
- # Erase the character under the cursor.
95
- ERASE_CHAR = "\e[P"
96
- # The start of an ANSI bold sequence.
97
- BOLD = "\e[1m"
98
- # The start of an ANSI dark sequence. (Terminal support uncommon.)
99
- DARK = "\e[2m"
100
- # The start of an ANSI underline sequence.
101
- UNDERLINE = "\e[4m"
102
- # An alias for UNDERLINE.
103
- UNDERSCORE = UNDERLINE
104
- # The start of an ANSI blink sequence. (Terminal support uncommon.)
105
- BLINK = "\e[5m"
106
- # The start of an ANSI reverse sequence.
107
- REVERSE = "\e[7m"
108
- # The start of an ANSI concealed sequence. (Terminal support uncommon.)
109
- CONCEALED = "\e[8m"
110
-
111
- # Set the terminal's foreground ANSI color to black.
112
- BLACK = "\e[30m"
113
- # Set the terminal's foreground ANSI color to red.
114
- RED = "\e[31m"
115
- # Set the terminal's foreground ANSI color to green.
116
- GREEN = "\e[32m"
117
- # Set the terminal's foreground ANSI color to yellow.
118
- YELLOW = "\e[33m"
119
- # Set the terminal's foreground ANSI color to blue.
120
- BLUE = "\e[34m"
121
- # Set the terminal's foreground ANSI color to magenta.
122
- MAGENTA = "\e[35m"
123
- # Set the terminal's foreground ANSI color to cyan.
124
- CYAN = "\e[36m"
125
- # Set the terminal's foreground ANSI color to white.
126
- WHITE = "\e[37m"
127
-
128
- # Set the terminal's background ANSI color to black.
129
- ON_BLACK = "\e[40m"
130
- # Set the terminal's background ANSI color to red.
131
- ON_RED = "\e[41m"
132
- # Set the terminal's background ANSI color to green.
133
- ON_GREEN = "\e[42m"
134
- # Set the terminal's background ANSI color to yellow.
135
- ON_YELLOW = "\e[43m"
136
- # Set the terminal's background ANSI color to blue.
137
- ON_BLUE = "\e[44m"
138
- # Set the terminal's background ANSI color to magenta.
139
- ON_MAGENTA = "\e[45m"
140
- # Set the terminal's background ANSI color to cyan.
141
- ON_CYAN = "\e[46m"
142
- # Set the terminal's background ANSI color to white.
143
- ON_WHITE = "\e[47m"
144
-
145
- #
146
- # Create an instance of HighLine, connected to the streams _input_
147
- # and _output_.
148
- #
149
- def initialize( input = $stdin, output = $stdout,
150
- wrap_at = nil, page_at = nil )
151
- @input = input
152
- @output = output
153
-
154
- self.wrap_at = wrap_at
155
- self.page_at = page_at
156
-
157
- @question = nil
158
- @answer = nil
159
- @menu = nil
160
- @header = nil
161
- @prompt = nil
162
- @gather = nil
163
- @answers = nil
164
- @key = nil
165
- end
166
-
167
- include HighLine::SystemExtensions
168
-
169
- # The current column setting for wrapping output.
170
- attr_reader :wrap_at
171
- # The current row setting for paging output.
172
- attr_reader :page_at
173
-
174
- #
175
- # A shortcut to HighLine.ask() a question that only accepts "yes" or "no"
176
- # answers ("y" and "n" are allowed) and returns +true+ or +false+
177
- # (+true+ for "yes"). If provided a +true+ value, _character_ will cause
178
- # HighLine to fetch a single character response. A block can be provided
179
- # to further configure the question as in HighLine.ask()
180
- #
181
- # Raises EOFError if input is exhausted.
182
- #
183
- def agree( yes_or_no_question, character = nil )
184
- ask(yes_or_no_question, lambda { |yn| yn.downcase[0] == ?y}) do |q|
185
- q.validate = /\Ay(?:es)?|no?\Z/i
186
- q.responses[:not_valid] = 'Please enter "yes" or "no".'
187
- q.responses[:ask_on_error] = :question
188
- q.character = character
189
-
190
- yield q if block_given?
191
- end
192
- end
193
-
194
- #
195
- # This method is the primary interface for user input. Just provide a
196
- # _question_ to ask the user, the _answer_type_ you want returned, and
197
- # optionally a code block setting up details of how you want the question
198
- # handled. See HighLine.say() for details on the format of _question_, and
199
- # HighLine::Question for more information about _answer_type_ and what's
200
- # valid in the code block.
201
- #
202
- # If <tt>@question</tt> is set before ask() is called, parameters are
203
- # ignored and that object (must be a HighLine::Question) is used to drive
204
- # the process instead.
205
- #
206
- # Raises EOFError if input is exhausted.
207
- #
208
- def ask( question, answer_type = String, &details ) # :yields: question
209
- @question ||= Question.new(question, answer_type, &details)
210
-
211
- return gather if @question.gather
212
-
213
- # readline() needs to handle it's own output, but readline only supports
214
- # full line reading. Therefore if @question.echo is anything but true,
215
- # the prompt will not be issued. And we have to account for that now.
216
- say(@question) unless (@question.readline and @question.echo == true)
217
- begin
218
- @answer = @question.answer_or_default(get_response)
219
- unless @question.valid_answer?(@answer)
220
- explain_error(:not_valid)
221
- raise QuestionError
222
- end
223
-
224
- @answer = @question.convert(@answer)
225
-
226
- if @question.in_range?(@answer)
227
- if @question.confirm
228
- # need to add a layer of scope to ask a question inside a
229
- # question, without destroying instance data
230
- context_change = self.class.new(@input, @output, @wrap_at, @page_at)
231
- if @question.confirm == true
232
- confirm_question = "Are you sure? "
233
- else
234
- # evaluate ERb under initial scope, so it will have
235
- # access to @question and @answer
236
- template = ERB.new(@question.confirm, nil, "%")
237
- confirm_question = template.result(binding)
238
- end
239
- unless context_change.agree(confirm_question)
240
- explain_error(nil)
241
- raise QuestionError
242
- end
243
- end
244
-
245
- @answer
246
- else
247
- explain_error(:not_in_range)
248
- raise QuestionError
249
- end
250
- rescue QuestionError
251
- retry
252
- rescue ArgumentError, NameError => error
253
- raise if error.is_a?(NoMethodError)
254
- if error.message =~ /ambiguous/
255
- # the assumption here is that OptionParser::Completion#complete
256
- # (used for ambiguity resolution) throws exceptions containing
257
- # the word 'ambiguous' whenever resolution fails
258
- explain_error(:ambiguous_completion)
259
- else
260
- explain_error(:invalid_type)
261
- end
262
- retry
263
- rescue Question::NoAutoCompleteMatch
264
- explain_error(:no_completion)
265
- retry
266
- ensure
267
- @question = nil # Reset Question object.
268
- end
269
- end
270
-
271
- #
272
- # This method is HighLine's menu handler. For simple usage, you can just
273
- # pass all the menu items you wish to display. At that point, choose() will
274
- # build and display a menu, walk the user through selection, and return
275
- # their choice amoung the provided items. You might use this in a case
276
- # statement for quick and dirty menus.
277
- #
278
- # However, choose() is capable of much more. If provided, a block will be
279
- # passed a HighLine::Menu object to configure. Using this method, you can
280
- # customize all the details of menu handling from index display, to building
281
- # a complete shell-like menuing system. See HighLine::Menu for all the
282
- # methods it responds to.
283
- #
284
- # Raises EOFError if input is exhausted.
285
- #
286
- def choose( *items, &details )
287
- @menu = @question = Menu.new(&details)
288
- @menu.choices(*items) unless items.empty?
289
-
290
- # Set _answer_type_ so we can double as the Question for ask().
291
- @menu.answer_type = if @menu.shell
292
- lambda do |command| # shell-style selection
293
- first_word = command.to_s.split.first || ""
294
-
295
- options = @menu.options
296
- options.extend(OptionParser::Completion)
297
- answer = options.complete(first_word)
298
-
299
- if answer.nil?
300
- raise Question::NoAutoCompleteMatch
301
- end
302
-
303
- [answer.last, command.sub(/^\s*#{first_word}\s*/, "")]
304
- end
305
- else
306
- @menu.options # normal menu selection, by index or name
307
- end
308
-
309
- # Provide hooks for ERb layouts.
310
- @header = @menu.header
311
- @prompt = @menu.prompt
312
-
313
- if @menu.shell
314
- selected = ask("Ignored", @menu.answer_type)
315
- @menu.select(self, *selected)
316
- else
317
- selected = ask("Ignored", @menu.answer_type)
318
- @menu.select(self, selected)
319
- end
320
- end
321
-
322
- #
323
- # This method provides easy access to ANSI color sequences, without the user
324
- # needing to remember to CLEAR at the end of each sequence. Just pass the
325
- # _string_ to color, followed by a list of _colors_ you would like it to be
326
- # affected by. The _colors_ can be HighLine class constants, or symbols
327
- # (:blue for BLUE, for example). A CLEAR will automatically be embedded to
328
- # the end of the returned String.
329
- #
330
- # This method returns the original _string_ unchanged if HighLine::use_color?
331
- # is +false+.
332
- #
333
- def color( string, *colors )
334
- return string unless self.class.use_color?
335
-
336
- colors.map! do |c|
337
- if self.class.using_color_scheme? and self.class.color_scheme.include? c
338
- self.class.color_scheme[c]
339
- elsif c.is_a? Symbol
340
- self.class.const_get(c.to_s.upcase)
341
- else
342
- c
343
- end
344
- end
345
- "#{colors.flatten.join}#{string}#{CLEAR}"
346
- end
347
-
348
- #
349
- # This method is a utility for quickly and easily laying out lists. It can
350
- # be accessed within ERb replacements of any text that will be sent to the
351
- # user.
352
- #
353
- # The only required parameter is _items_, which should be the Array of items
354
- # to list. A specified _mode_ controls how that list is formed and _option_
355
- # has different effects, depending on the _mode_. Recognized modes are:
356
- #
357
- # <tt>:columns_across</tt>:: _items_ will be placed in columns, flowing
358
- # from left to right. If given, _option_ is the
359
- # number of columns to be used. When absent,
360
- # columns will be determined based on _wrap_at_
361
- # or a default of 80 characters.
362
- # <tt>:columns_down</tt>:: Identical to <tt>:columns_across</tt>, save
363
- # flow goes down.
364
- # <tt>:inline</tt>:: All _items_ are placed on a single line. The
365
- # last two _items_ are separated by _option_ or
366
- # a default of " or ". All other _items_ are
367
- # separated by ", ".
368
- # <tt>:rows</tt>:: The default mode. Each of the _items_ is
369
- # placed on it's own line. The _option_
370
- # parameter is ignored in this mode.
371
- #
372
- # Each member of the _items_ Array is passed through ERb and thus can contain
373
- # their own expansions. Color escape expansions do not contribute to the
374
- # final field width.
375
- #
376
- def list( items, mode = :rows, option = nil )
377
- items = items.to_ary.map do |item|
378
- ERB.new(item, nil, "%").result(binding)
379
- end
380
-
381
- case mode
382
- when :inline
383
- option = " or " if option.nil?
384
-
385
- case items.size
386
- when 0
387
- ""
388
- when 1
389
- items.first
390
- when 2
391
- "#{items.first}#{option}#{items.last}"
392
- else
393
- items[0..-2].join(", ") + "#{option}#{items.last}"
394
- end
395
- when :columns_across, :columns_down
396
- max_length = actual_length(
397
- items.max { |a, b| actual_length(a) <=> actual_length(b) }
398
- )
399
-
400
- if option.nil?
401
- limit = @wrap_at || 80
402
- option = (limit + 2) / (max_length + 2)
403
- end
404
-
405
- items = items.map do |item|
406
- pad = max_length + (item.length - actual_length(item))
407
- "%-#{pad}s" % item
408
- end
409
- row_count = (items.size / option.to_f).ceil
410
-
411
- if mode == :columns_across
412
- rows = Array.new(row_count) { Array.new }
413
- items.each_with_index do |item, index|
414
- rows[index / option] << item
415
- end
416
-
417
- rows.map { |row| row.join(" ") + "\n" }.join
418
- else
419
- columns = Array.new(option) { Array.new }
420
- items.each_with_index do |item, index|
421
- columns[index / row_count] << item
422
- end
423
-
424
- list = ""
425
- columns.first.size.times do |index|
426
- list << columns.map { |column| column[index] }.
427
- compact.join(" ") + "\n"
428
- end
429
- list
430
- end
431
- else
432
- items.map { |i| "#{i}\n" }.join
433
- end
434
- end
435
-
436
- #
437
- # The basic output method for HighLine objects. If the provided _statement_
438
- # ends with a space or tab character, a newline will not be appended (output
439
- # will be flush()ed). All other cases are passed straight to Kernel.puts().
440
- #
441
- # The _statement_ parameter is processed as an ERb template, supporting
442
- # embedded Ruby code. The template is evaluated with a binding inside
443
- # the HighLine instance, providing easy access to the ANSI color constants
444
- # and the HighLine.color() method.
445
- #
446
- def say( statement )
447
- statement = statement.to_str
448
- return unless statement.length > 0
449
-
450
- template = ERB.new(statement, nil, "%")
451
- statement = template.result(binding)
452
-
453
- statement = wrap(statement) unless @wrap_at.nil?
454
- statement = page_print(statement) unless @page_at.nil?
455
-
456
- if statement[-1, 1] == " " or statement[-1, 1] == "\t"
457
- @output.print(statement)
458
- @output.flush
459
- else
460
- @output.puts(statement)
461
- end
462
- end
463
-
464
- #
465
- # Set to an integer value to cause HighLine to wrap output lines at the
466
- # indicated character limit. When +nil+, the default, no wrapping occurs. If
467
- # set to <tt>:auto</tt>, HighLine will attempt to determing the columns
468
- # available for the <tt>@output</tt> or use a sensible default.
469
- #
470
- def wrap_at=( setting )
471
- @wrap_at = setting == :auto ? output_cols : setting
472
- end
473
-
474
- #
475
- # Set to an integer value to cause HighLine to page output lines over the
476
- # indicated line limit. When +nil+, the default, no paging occurs. If
477
- # set to <tt>:auto</tt>, HighLine will attempt to determing the rows available
478
- # for the <tt>@output</tt> or use a sensible default.
479
- #
480
- def page_at=( setting )
481
- @page_at = setting == :auto ? output_rows : setting
482
- end
483
-
484
- #
485
- # Returns the number of columns for the console, or a default it they cannot
486
- # be determined.
487
- #
488
- def output_cols
489
- return 80 unless @output.tty?
490
- terminal_size.first
491
- rescue
492
- return 80
493
- end
494
-
495
- #
496
- # Returns the number of rows for the console, or a default if they cannot be
497
- # determined.
498
- #
499
- def output_rows
500
- return 24 unless @output.tty?
501
- terminal_size.last
502
- rescue
503
- return 24
504
- end
505
-
506
- private
507
-
508
- #
509
- # A helper method for sending the output stream and error and repeat
510
- # of the question.
511
- #
512
- def explain_error( error )
513
- say(@question.responses[error]) unless error.nil?
514
- if @question.responses[:ask_on_error] == :question
515
- say(@question)
516
- elsif @question.responses[:ask_on_error]
517
- say(@question.responses[:ask_on_error])
518
- end
519
- end
520
-
521
- #
522
- # Collects an Array/Hash full of answers as described in
523
- # HighLine::Question.gather().
524
- #
525
- # Raises EOFError if input is exhausted.
526
- #
527
- def gather( )
528
- @gather = @question.gather
529
- @answers = [ ]
530
- original_question = @question
531
-
532
- @question.gather = false
533
-
534
- case @gather
535
- when Integer
536
- @answers << ask(@question)
537
- @gather -= 1
538
-
539
- original_question.question = ""
540
- until @gather.zero?
541
- @question = original_question
542
- @answers << ask(@question)
543
- @gather -= 1
544
- end
545
- when String, Regexp
546
- @answers << ask(@question)
547
-
548
- original_question.question = ""
549
- until (@gather.is_a?(String) and @answers.last.to_s == @gather) or
550
- (@gather.is_a?(Regexp) and @answers.last.to_s =~ @gather)
551
- @question = original_question
552
- @answers << ask(@question)
553
- end
554
-
555
- @answers.pop
556
- when Hash
557
- @answers = { }
558
- @gather.keys.sort.each do |key|
559
- @question = original_question
560
- @key = key
561
- @answers[key] = ask(@question)
562
- end
563
- end
564
-
565
- @answers
566
- end
567
-
568
- #
569
- # Read a line of input from the input stream and process whitespace as
570
- # requested by the Question object.
571
- #
572
- # If Question's _readline_ property is set, that library will be used to
573
- # fetch input. *WARNING*: This ignores the currently set input stream.
574
- #
575
- # Raises EOFError if input is exhausted.
576
- #
577
- def get_line( )
578
- if @question.readline
579
- require "readline" # load only if needed
580
-
581
- # capture say()'s work in a String to feed to readline()
582
- old_output = @output
583
- @output = StringIO.new
584
- say(@question)
585
- question = @output.string
586
- @output = old_output
587
-
588
- # prep auto-completion
589
- Readline.completion_proc = lambda do |string|
590
- @question.selection.grep(/\A#{Regexp.escape(string)}/)
591
- end
592
-
593
- # work-around ugly readline() warnings
594
- old_verbose = $VERBOSE
595
- $VERBOSE = nil
596
- answer = @question.change_case(
597
- @question.remove_whitespace(
598
- Readline.readline(question, true) ) )
599
- $VERBOSE = old_verbose
600
-
601
- answer
602
- else
603
- raise EOFError, "The input stream is exhausted." if @@track_eof and
604
- @input.eof?
605
-
606
- @question.change_case(@question.remove_whitespace(@input.gets))
607
- end
608
- end
609
-
610
- #
611
- # Return a line or character of input, as requested for this question.
612
- # Character input will be returned as a single character String,
613
- # not an Integer.
614
- #
615
- # This question's _first_answer_ will be returned instead of input, if set.
616
- #
617
- # Raises EOFError if input is exhausted.
618
- #
619
- def get_response( )
620
- return @question.first_answer if @question.first_answer?
621
-
622
- if @question.character.nil?
623
- if @question.echo == true and @question.limit.nil?
624
- get_line
625
- else
626
- raw_no_echo_mode if stty = CHARACTER_MODE == "stty"
627
-
628
- line = ""
629
- backspace_limit = 0
630
- begin
631
-
632
- while character = (stty ? @input.getbyte : get_character(@input))
633
- # honor backspace and delete
634
- if character == 127 or character == 8
635
- line.slice!(-1, 1)
636
- backspace_limit -= 1
637
- else
638
- line << character.chr
639
- backspace_limit = line.size
640
- end
641
- # looking for carriage return (decimal 13) or
642
- # newline (decimal 10) in raw input
643
- break if character == 13 or character == 10 or
644
- (@question.limit and line.size == @question.limit)
645
- if @question.echo != false
646
- if character == 127 or character == 8
647
- # only backspace if we have characters on the line to
648
- # eliminate, otherwise we'll tromp over the prompt
649
- if backspace_limit >= 0 then
650
- @output.print("\b#{ERASE_CHAR}")
651
- else
652
- # do nothing
653
- end
654
- else
655
- if @question.echo == true
656
- @output.print(character.chr)
657
- else
658
- @output.print(@question.echo)
659
- end
660
- end
661
- @output.flush
662
- end
663
- end
664
- ensure
665
- restore_mode if stty
666
- end
667
- if @question.overwrite
668
- @output.print("\r#{ERASE_LINE}")
669
- @output.flush
670
- else
671
- say("\n")
672
- end
673
-
674
- @question.change_case(@question.remove_whitespace(line))
675
- end
676
- elsif @question.character == :getc
677
- @question.change_case(@input.getbyte.chr)
678
- else
679
- response = get_character(@input).chr
680
- if @question.overwrite
681
- @output.print("\r#{ERASE_LINE}")
682
- @output.flush
683
- else
684
- echo = if @question.echo == true
685
- response
686
- elsif @question.echo != false
687
- @question.echo
688
- else
689
- ""
690
- end
691
- say("#{echo}\n")
692
- end
693
- @question.change_case(response)
694
- end
695
- end
696
-
697
- #
698
- # Page print a series of at most _page_at_ lines for _output_. After each
699
- # page is printed, HighLine will pause until the user presses enter/return
700
- # then display the next page of data.
701
- #
702
- # Note that the final page of _output_ is *not* printed, but returned
703
- # instead. This is to support any special handling for the final sequence.
704
- #
705
- def page_print( output )
706
- lines = output.scan(/[^\n]*\n?/)
707
- while lines.size > @page_at
708
- @output.puts lines.slice!(0...@page_at).join
709
- @output.puts
710
- # Return last line if user wants to abort paging
711
- return (["...\n"] + lines.slice(-2,1)).join unless continue_paging?
712
- end
713
- return lines.join
714
- end
715
-
716
- #
717
- # Ask user if they wish to continue paging output. Allows them to type "q" to
718
- # cancel the paging process.
719
- #
720
- def continue_paging?
721
- command = HighLine.new(@input, @output).ask(
722
- "-- press enter/return to continue or q to stop -- "
723
- ) { |q| q.character = true }
724
- command !~ /\A[qQ]\Z/ # Only continue paging if Q was not hit.
725
- end
726
-
727
- #
728
- # Wrap a sequence of _lines_ at _wrap_at_ characters per line. Existing
729
- # newlines will not be affected by this process, but additional newlines
730
- # may be added.
731
- #
732
- def wrap( text )
733
- wrapped = [ ]
734
- text.each_line do |line|
735
- while line =~ /([^\n]{#{@wrap_at + 1},})/
736
- search = $1.dup
737
- replace = $1.dup
738
- if index = replace.rindex(" ", @wrap_at)
739
- replace[index, 1] = "\n"
740
- replace.sub!(/\n[ \t]+/, "\n")
741
- line.sub!(search, replace)
742
- else
743
- line[@wrap_at, 0] = "\n"
744
- end
745
- end
746
- wrapped << line
747
- end
748
- return wrapped.join
749
- end
750
-
751
- #
752
- # Returns the length of the passed +string_with_escapes+, minus and color
753
- # sequence escapes.
754
- #
755
- def actual_length( string_with_escapes )
756
- string_with_escapes.gsub(/\e\[\d{1,2}m/, "").length
757
- end
758
- end