hoe-highline 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +26 -0
  3. data/History.md +4 -0
  4. data/README.md +179 -0
  5. data/Rakefile +142 -0
  6. data/lib/hoe/highline.rb +56 -0
  7. metadata +162 -0
  8. metadata.gz.sig +0 -0
Binary file
@@ -0,0 +1,26 @@
1
+ 2011-03-12 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .hgtags:
4
+ Added tag v0.0.1 for changeset f9a3499e47b2
5
+ [6cb01cee05f5] [master, tip]
6
+
7
+ * .hgsigs:
8
+ Added signature for changeset 4a7fd6f5e4ce
9
+ [f9a3499e47b2] [v0.0.1]
10
+
11
+ * README.md, Rakefile:
12
+ Fixed some README and demo stuff.
13
+ [4a7fd6f5e4ce]
14
+
15
+ * Rakefile:
16
+ Added dependency on Hoe itself.
17
+ [09a1581eede1] [github/master]
18
+
19
+ * .autotest:
20
+ Remove unused autotest config
21
+ [611cdca315db]
22
+
23
+ * .autotest, History.md, Manifest.txt, README.md, Rakefile,
24
+ lib/hoe/highline.rb:
25
+ Initial version
26
+ [12c9e44f7d0e]
@@ -0,0 +1,4 @@
1
+ ## 0.0.1 [2011-01-23] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Initial release.
4
+
@@ -0,0 +1,179 @@
1
+ # hoe_highline
2
+
3
+ * https://bitbucket.org/ged/hoe-highline
4
+ * https://github.com/ged/hoe-highline
5
+
6
+ ## Description
7
+
8
+ A Hoe plugin for building interactive Rake tasks.
9
+
10
+ Hoe-highline, as you might have guessed from the name, adds prompting and
11
+ displaying functions from the [HighLine][highline] gem to your Rake
12
+ environment, allowing you to ask questions, prompt for passwords, build menus,
13
+ and other fun stuff.
14
+
15
+
16
+ ## Installation
17
+
18
+ gem install hoe-highline
19
+
20
+
21
+ ## Usage
22
+
23
+ # in your Rakefile
24
+
25
+ Hoe.plugin :highline
26
+
27
+ Hoe.spec 'mygem' do
28
+
29
+ # Configure the highline terminal to your liking
30
+ highline.wrap_at = :auto # Auto-wrap output
31
+
32
+ end
33
+
34
+ # Generate an email, show it, confirm they want to send it, then prompt
35
+ # for a SMTP connection information before sending
36
+ task :send_email do
37
+ message = generate_email( :full )
38
+ say "About to send this:"
39
+ say( mail )
40
+
41
+ if agree( "Okay to send it? " )
42
+ require 'socket'
43
+ require 'net/smtp'
44
+ require 'etc'
45
+
46
+ username = ask( "Email username: " ) do |q|
47
+ q.default = Etc.getlogin # default to the current user
48
+ end
49
+ password = ask( "Email password: " ) do |q|
50
+ q.echo = '*' # Hide the password
51
+ end
52
+
53
+ say "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
54
+ smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
55
+ smtp.set_debug_output( $stderr )
56
+ smtp.esmtp = true
57
+ smtp.enable_starttls
58
+
59
+ helo = Socket.gethostname
60
+ smtp.start( helo, username, password, :plain ) do |smtp|
61
+ smtp.send_message( message, email_from, *email_to )
62
+ end
63
+ else
64
+ abort "Okay, aborting."
65
+ end
66
+ end
67
+
68
+ There is also a 'demo' task in this library's Rakefile that has a few ideas for things you might want to do. Running it looks like this:
69
+
70
+ hoe-highline Demo
71
+
72
+ You can prompt for a yes-or-no answer with agree()
73
+ Know what I mean (nudge, nudge, wink, wink)? [yn] y
74
+ What's it like?
75
+
76
+ You can ask for input with ask()
77
+ What could be better than that? Nothing!
78
+ Actually, that was a rhetorical question, but you answered: "Nothing!"
79
+
80
+ You can also ask() for things like passwords with a little configuration
81
+ Super sekrit password: **********
82
+ Okay, using your 10-character password for something nefarious...
83
+
84
+ You can also use choose() for building a menu.
85
+ What editor do you prefer?
86
+ 1. Emacs
87
+ 2. vi
88
+ 3. Textmate
89
+ 4. pico
90
+ 5. RubyMine
91
+ 6. FreeRIDE
92
+ ? 3
93
+ Good to know (you picked "Textmate").
94
+
95
+ Or build a complex menu using a block.
96
+ Announce a new release:
97
+ 1. ruby-talk
98
+ 2. Blog
99
+ 3. Twitter
100
+ 4. Exit
101
+ ? 2
102
+ Posting to blog.you.com!
103
+ 1. ruby-talk
104
+ 2. Twitter
105
+ 3. Exit
106
+ ? 1
107
+ Sending mail!
108
+ 1. Twitter
109
+ 2. Exit
110
+ ? 2
111
+
112
+ There is also a list() function for display stuff in a compact list
113
+ For example, here's a list of the available tasks:
114
+ .hg/branch ChangeLog
115
+ check_extra_deps check_manifest
116
+ clobber clobber_docs
117
+ commit-msg.txt config_hoe
118
+ default demo
119
+ deps:list doc
120
+ gem generate_key
121
+ hg:ci hg:commit
122
+ hg:prep_release hg:pull
123
+ hg:push_without_confirmation hg:update
124
+ newb package
125
+ pkg/hoe-highline-0.0.1.gem pkg/hoe-highline-0.0.1.tgz
126
+ pre prerelease
127
+ rcov rcov_overlay
128
+ release_sanity release_to
129
+ ridocs
130
+
131
+ ## Contributing
132
+
133
+ You can check out the current development source with Mercurial via its
134
+ [Bitbucket project][bitbucket]. Or if you prefer Git, via
135
+ [its Github mirror][github].
136
+
137
+ After checking out the source, run:
138
+
139
+ $ rake newb
140
+
141
+ This task will install any missing dependencies, run the tests/specs,
142
+ and generate the API documentation.
143
+
144
+
145
+ ## License
146
+
147
+ Copyright (c) 2011, Michael Granger
148
+ All rights reserved.
149
+
150
+ Redistribution and use in source and binary forms, with or without
151
+ modification, are permitted provided that the following conditions are met:
152
+
153
+ * Redistributions of source code must retain the above copyright notice,
154
+ this list of conditions and the following disclaimer.
155
+
156
+ * Redistributions in binary form must reproduce the above copyright notice,
157
+ this list of conditions and the following disclaimer in the documentation
158
+ and/or other materials provided with the distribution.
159
+
160
+ * Neither the name of the author/s, nor the names of the project's
161
+ contributors may be used to endorse or promote products derived from this
162
+ software without specific prior written permission.
163
+
164
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
165
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
166
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
167
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
168
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
169
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
170
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
171
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
172
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
173
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
174
+
175
+
176
+ [highline]: http://highline.rubyforge.org/
177
+ [bitbucket]: https://bitbucket.org/ged/hoe-highline
178
+ [github]: https://github.com/ged/ruby-openldap
179
+
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'hoe'
4
+
5
+ Hoe.add_include_dirs 'lib'
6
+
7
+ Hoe.plugin :highline
8
+ Hoe.plugin :mercurial
9
+ Hoe.plugin :signing
10
+
11
+ Hoe.plugins.delete :rubyforge
12
+
13
+ hoespec = Hoe.spec 'hoe-highline' do
14
+ self.readme_file = 'README.md'
15
+ self.history_file = 'History.md'
16
+
17
+ self.developer 'Michael Granger', 'ged@FaerieMUD.org'
18
+
19
+ self.extra_deps.push *{
20
+ 'highline' => '~> 1.6',
21
+ 'hoe' => '~> 2.8',
22
+ }
23
+
24
+ self.spec_extras[:licenses] = ["BSD"]
25
+ self.spec_extras[:signing_key] = '/Volumes/Keys/ged-private_gem_key.pem'
26
+
27
+ self.require_ruby_version( '>=1.8.7' )
28
+
29
+ self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
30
+
31
+ self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
32
+
33
+ if self.respond_to?( :highline )
34
+ self.highline.wrap_at = :auto
35
+ else
36
+ abort "Ack! The plugin doesn't seem to be loaded; that won't do at all."
37
+ end
38
+ end
39
+
40
+
41
+ desc "A series of demos of how this plugin can be used"
42
+ task :demo do
43
+ say "<%= color 'hoe-highline Demo', :header %>"
44
+
45
+ say "\n<%= color 'You can prompt for a yes-or-no answer with agree()', :subheader %>"
46
+ if agree "Know what I mean (nudge, nudge, wink, wink)? <%= color '[yn]', :values %> ", true
47
+ say "What's it like?"
48
+ else
49
+ say "Ah, more's the pity."
50
+ end
51
+
52
+ say "\n<%= color 'You can ask for input with ask()', :subheader %>"
53
+ result = ask "What could be better than that? "
54
+ say "Actually, that was a rhetorical question, but you answered: %p" % [ result ]
55
+
56
+ say "\n<%= color 'You can also ask() for things like passwords with a little " +
57
+ "configuration', :subheader %>"
58
+ result = ask( "Super sekrit password: " ) {|q| q.echo = color("*", :warning) }
59
+ say "Okay, using your %d-character password for something nefarious..." % [ result.length ]
60
+
61
+ say "\n<%= color 'You can also use choose() for building a menu.', :subheader %>"
62
+ say "What editor do you prefer?"
63
+ choice = choose( 'Emacs', 'vi', 'Textmate', 'pico', 'RubyMine', 'FreeRIDE' )
64
+ say "Good to know (you picked %p)." % [ choice ]
65
+
66
+ say "\n<%= color 'Or build a complex menu using a block.', :subheader %>"
67
+ say "Announce a new release:"
68
+ done = false
69
+ remaining = [ :mail, :blog, :twitter ]
70
+ until done || remaining.empty?
71
+ choose do |menu|
72
+ menu.choice( "ruby-talk" ) do
73
+ say "Sending mail!"
74
+ remaining.delete( :mail )
75
+ end if remaining.include?( :mail )
76
+
77
+ menu.choice( "Blog" ) do
78
+ say "Posting to blog.you.com!"
79
+ remaining.delete( :blog )
80
+ end if remaining.include?( :blog )
81
+
82
+ menu.choice( "Twitter" ) do
83
+ say "Twerp! Twerp!"
84
+ remaining.delete( :twitter )
85
+ end if remaining.include?( :twitter )
86
+
87
+ menu.choice( "Exit" ) do
88
+ done = true
89
+ end
90
+ end
91
+ end
92
+
93
+ say "\n<%= color 'There is also a list() function for display stuff in a compact " +
94
+ "list', :subheader %>"
95
+ say "For example, here's a list of the available tasks:"
96
+ say list( Rake.application.tasks.map(&:to_s), :columns_across )
97
+
98
+ end
99
+
100
+
101
+ ENV['VERSION'] ||= hoespec.spec.version.to_s
102
+
103
+ begin
104
+ include Hoe::MercurialHelpers
105
+
106
+ ### Task: prerelease
107
+ desc "Append the package build number to package versions"
108
+ task :pre do
109
+ rev = get_numeric_rev()
110
+ trace "Current rev is: %p" % [ rev ]
111
+ hoespec.spec.version.version << "pre#{rev}"
112
+ Rake::Task[:gem].clear
113
+
114
+ Gem::PackageTask.new( hoespec.spec ) do |pkg|
115
+ pkg.need_zip = true
116
+ pkg.need_tar = true
117
+ end
118
+ end
119
+
120
+ ### Make the ChangeLog update if the repo has changed since it was last built
121
+ file '.hg/branch'
122
+ file 'ChangeLog' => '.hg/branch' do |task|
123
+ $stderr.puts "Updating the changelog..."
124
+ content = make_changelog()
125
+ File.open( task.name, 'w', 0644 ) do |fh|
126
+ fh.print( content )
127
+ end
128
+ end
129
+
130
+ # Rebuild the ChangeLog immediately before release
131
+ task :prerelease => 'ChangeLog'
132
+
133
+ rescue NameError => err
134
+ task :no_hg_helpers do
135
+ fail "Couldn't define the :pre task: %s: %s" % [ err.class.name, err.message ]
136
+ end
137
+
138
+ task :pre => :no_hg_helpers
139
+ task 'ChangeLog' => :no_hg_helpers
140
+
141
+ end
142
+
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hoe'
4
+ require 'highline'
5
+ require 'forwardable'
6
+
7
+ # Add Highline command-line interaction functions to Hoe Rakefiles.
8
+ #
9
+ # @author Michael Granger <ged@FaerieMUD.org>
10
+ #
11
+ module Hoe::Highline
12
+ extend Forwardable
13
+
14
+ # Library version constant
15
+ VERSION = '0.0.1'
16
+
17
+ # Version-control revision constant
18
+ REVISION = %q$Revision: 12c9e44f7d0e $
19
+
20
+ # HighLine color scheme
21
+ COLOR_SCHEME = {
22
+ :header => [ :bold, :yellow ],
23
+ :subheader => [ :bold, :white ],
24
+ :values => [ :bold, :white ],
25
+ :error => [ :red ],
26
+ :warning => [ :yellow ],
27
+ :message => [ :reset ],
28
+ }
29
+
30
+
31
+ # The HighLine object used for prompting
32
+ attr_accessor :highline
33
+
34
+
35
+ ### Set up the plugin's instance variables.
36
+ def initialize_highline
37
+ HighLine.color_scheme = HighLine::ColorScheme.new( COLOR_SCHEME )
38
+ @highline = HighLine.new( $stdin, $stderr )
39
+
40
+ self.extra_dev_deps << ['hoe-highline', "~> #{VERSION}"] unless
41
+ self.name == 'hoe-highline'
42
+ end
43
+
44
+
45
+ ### Hoe hook -- add the Highline functions to Kernel when the plugin is
46
+ ### loaded.
47
+ def define_highline_tasks
48
+ $terminal = self.highline
49
+
50
+ ::Kernel.extend( Forwardable )
51
+ ::Kernel.def_delegators :$terminal, :agree, :ask, :choose, :color, :list, :say
52
+ end
53
+
54
+
55
+ end # module Hoe::Highline
56
+
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hoe-highline
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Michael Granger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIDLDCCAhSgAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQwwCgYDVQQDDANnZWQx
20
+ FzAVBgoJkiaJk/IsZAEZFgdfYWVyaWVfMRMwEQYKCZImiZPyLGQBGRYDb3JnMB4X
21
+ DTEwMDkxNjE0NDg1MVoXDTExMDkxNjE0NDg1MVowPDEMMAoGA1UEAwwDZ2VkMRcw
22
+ FQYKCZImiZPyLGQBGRYHX2FlcmllXzETMBEGCgmSJomT8ixkARkWA29yZzCCASIw
23
+ DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALy//BFxC1f/cPSnwtJBWoFiFrir
24
+ h7RicI+joq/ocVXQqI4TDWPyF/8tqkvt+rD99X9qs2YeR8CU/YiIpLWrQOYST70J
25
+ vDn7Uvhb2muFVqq6+vobeTkILBEO6pionWDG8jSbo3qKm1RjKJDwg9p4wNKhPuu8
26
+ KGue/BFb67KflqyApPmPeb3Vdd9clspzqeFqp7cUBMEpFS6LWxy4Gk+qvFFJBJLB
27
+ BUHE/LZVJMVzfpC5Uq+QmY7B+FH/QqNndn3tOHgsPadLTNimuB1sCuL1a4z3Pepd
28
+ TeLBEFmEao5Dk3K/Q8o8vlbIB/jBDTUx6Djbgxw77909x6gI9doU4LD5XMcCAwEA
29
+ AaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFJeoGkOr9l4B
30
+ +saMkW/ZXT4UeSvVMA0GCSqGSIb3DQEBBQUAA4IBAQBG2KObvYI2eHyyBUJSJ3jN
31
+ vEnU3d60znAXbrSd2qb3r1lY1EPDD3bcy0MggCfGdg3Xu54z21oqyIdk8uGtWBPL
32
+ HIa9EgfFGSUEgvcIvaYqiN4jTUtidfEFw+Ltjs8AP9gWgSIYS6Gr38V0WGFFNzIH
33
+ aOD2wmu9oo/RffW4hS/8GuvfMzcw7CQ355wFR4KB/nyze+EsZ1Y5DerCAagMVuDQ
34
+ U0BLmWDFzPGGWlPeQCrYHCr+AcJz+NRnaHCKLZdSKj/RHuTOt+gblRex8FAh8NeA
35
+ cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
36
+ -----END CERTIFICATE-----
37
+
38
+ date: 2011-03-12 00:00:00 -08:00
39
+ default_executable:
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: highline
43
+ prerelease: false
44
+ requirement: &id001 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 1
52
+ - 6
53
+ version: "1.6"
54
+ type: :runtime
55
+ version_requirements: *id001
56
+ - !ruby/object:Gem::Dependency
57
+ name: hoe
58
+ prerelease: false
59
+ requirement: &id002 !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ hash: 19
65
+ segments:
66
+ - 2
67
+ - 8
68
+ version: "2.8"
69
+ type: :runtime
70
+ version_requirements: *id002
71
+ - !ruby/object:Gem::Dependency
72
+ name: hoe-mercurial
73
+ prerelease: false
74
+ requirement: &id003 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ hash: 29
80
+ segments:
81
+ - 1
82
+ - 2
83
+ - 1
84
+ version: 1.2.1
85
+ type: :development
86
+ version_requirements: *id003
87
+ - !ruby/object:Gem::Dependency
88
+ name: hoe
89
+ prerelease: false
90
+ requirement: &id004 !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ hash: 41
96
+ segments:
97
+ - 2
98
+ - 9
99
+ - 1
100
+ version: 2.9.1
101
+ type: :development
102
+ version_requirements: *id004
103
+ description: |-
104
+ A Hoe plugin for building interactive Rake tasks.
105
+
106
+ Hoe-highline, as you might have guessed from the name, adds prompting and
107
+ displaying functions from the [HighLine][highline] gem to your Rake
108
+ environment, allowing you to ask questions, prompt for passwords, build menus,
109
+ and other fun stuff.
110
+ email:
111
+ - ged@FaerieMUD.org
112
+ executables: []
113
+
114
+ extensions: []
115
+
116
+ extra_rdoc_files: []
117
+
118
+ files:
119
+ - ChangeLog
120
+ - History.md
121
+ - README.md
122
+ - Rakefile
123
+ - lib/hoe/highline.rb
124
+ has_rdoc: true
125
+ homepage: https://bitbucket.org/ged/hoe-highline
126
+ licenses:
127
+ - BSD
128
+ post_install_message:
129
+ rdoc_options:
130
+ - --main
131
+ - README.md
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ hash: 57
140
+ segments:
141
+ - 1
142
+ - 8
143
+ - 7
144
+ version: 1.8.7
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ hash: 3
151
+ segments:
152
+ - 0
153
+ version: "0"
154
+ requirements: []
155
+
156
+ rubyforge_project: hoe-highline
157
+ rubygems_version: 1.5.2
158
+ signing_key:
159
+ specification_version: 3
160
+ summary: A Hoe plugin for building interactive Rake tasks
161
+ test_files: []
162
+
Binary file