prompter 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,8 @@ Methods are callable directly on the Prompter class, on a Prompter object, inclu
43
43
 
44
44
  Some methods yield the block with the returned value, so you can use them as an easy way to construct hierarchical wizards.
45
45
 
46
- Colorer styles are passable as an option to the called method, and can be redefined entirely by calling Colorer.def_*_styles.
46
+ The Prompter.dye_styles keys are passable as the :style option to the called method and will override the default styles,
47
+ They can also be redefined by setting the Prompter.dye_styles. (see the 'dye' gem for more info)
47
48
 
48
49
  == Documentation and Example
49
50
 
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ task :install, :force do |t, args|
20
20
  File.open('VERSION', 'w') {|f| f.puts version }
21
21
  gem_name = "#{name}-#{version}.gem"
22
22
  sh %(gem build #{name}.gemspec)
23
- sh %(gem install #{gem_name} --local)
23
+ sh %(gem install #{gem_name} --local --no-rdoc --no-ri)
24
24
  puts <<-EOS.gsub(/^ {6}/, '')
25
25
 
26
26
  *******************************************************************************
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -1,4 +1,4 @@
1
- require 'colorer'
1
+ require 'dye'
2
2
 
3
3
  # @author Domizio Demichelis
4
4
  #
@@ -6,12 +6,14 @@ class Prompter
6
6
 
7
7
  VERSION = File.read(File.expand_path('../../VERSION', __FILE__)).strip
8
8
 
9
- Colorer.def_custom_styles :say_style => nil,
10
- :say_echo_style => nil,
11
- :say_notice_style => :yellow,
12
- :say_warning_style => :red,
13
- :ask_style => :magenta,
14
- :hint_style => :green
9
+ class << self ; attr_accessor :dye_styles ; end
10
+
11
+ @dye_styles = { :say_style => nil,
12
+ :say_echo_style => nil,
13
+ :say_notice_style => :yellow,
14
+ :say_warning_style => :red,
15
+ :ask_style => :magenta,
16
+ :hint_style => :green }
15
17
 
16
18
  # Standard constructor, also accepts a block
17
19
  #
@@ -19,6 +21,9 @@ class Prompter
19
21
  # @option opts [String] :prefix The prefix string
20
22
  # @option opts [Boolean] :echo when true adds a line with the result
21
23
  #
24
+ # @yield yields the block with self
25
+ # @yieldparam [Prompter]
26
+ #
22
27
  def initialize(opts={})
23
28
  @prefix = opts[:prefix]
24
29
  @echo = opts[:echo] || true
@@ -27,6 +32,8 @@ class Prompter
27
32
 
28
33
  module Methods
29
34
 
35
+ define_dye_method Prompter.dye_styles
36
+
30
37
  attr_writer :echo, :prefix
31
38
 
32
39
  # The echo instance option (true by default)
@@ -47,7 +54,7 @@ class Prompter
47
54
  # @option opts [String] :prefix The prefix string
48
55
  # @option opts [Boolean] :echo Adds a line showing the input (=> input)
49
56
  # @option opts [String] :hint A string to show the available choices
50
- # @option opts [Symbol] :style The Colorer style name to use for this prompt
57
+ # @option opts [Symbol] :style The Dye style name to use for this prompt
51
58
  # @option opts [Boolean] :force_new_line Forces the addition of a new line (otherwise determined by the end of the prompt string)
52
59
  #
53
60
  def say(message="", opts={})
@@ -55,7 +62,7 @@ class Prompter
55
62
  opts = { :force_new_line => (message !~ /( |\t)$/),
56
63
  :style => :say_style,
57
64
  :prefix => prefix }.merge opts
58
- message = message.send opts[:style] unless opts[:style].nil?
65
+ message = dye(message, *opts[:style]) unless opts[:style].nil?
59
66
  message = (opts[:prefix]||'') + message
60
67
  $stdout.send((opts[:force_new_line] ? :puts : :print), message)
61
68
  $stdout.flush
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.summary = 'Makes your prompts easier to build and prettier to look'
11
11
  s.description = 'A few helpers to create colored, multistep and hierarchical wizards'
12
12
 
13
- s.add_runtime_dependency('colorer', [">= 0.7.0"])
13
+ s.add_runtime_dependency('dye', [">= 0.1.1"])
14
14
  s.add_runtime_dependency('yard', [">= 0.6.3"])
15
15
  s.add_development_dependency('irt', [">= 1.0.9"])
16
16
 
@@ -5,7 +5,6 @@ say "You should see the next line in :ask_style"
5
5
  ask "Please, write the word 'pippo':"
6
6
  _eql?( "pippo" )
7
7
 
8
- Colorer.def_basic_styles :red, true
9
8
  desc "intaractive default ask"
10
9
  say "You should see the next line in :red, and padded with 4 spaces"
11
10
  ask "Please, type <enter>:", :default => 'default', :style => :red, :prefix => ' '
@@ -33,6 +32,3 @@ ml = ask_multiline "Add your data below...",
33
32
  _eql?( ml )
34
33
  say "<START-INPUT>#{ml}<END-INPUT>"
35
34
 
36
-
37
- irt
38
-
@@ -25,7 +25,6 @@ prefix test
25
25
  EOS
26
26
 
27
27
  desc "style override"
28
- Colorer.def_basic_styles :magenta
29
28
  capture { Prompter.say "style override", :style => :magenta }
30
29
  _eql?( "--- \e[0m\e[35mstyle override\e[0m\n" )
31
30
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Domizio Demichelis
@@ -15,23 +15,23 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-29 00:00:00 -04:00
18
+ date: 2011-02-01 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: colorer
22
+ name: dye
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 25
30
30
  segments:
31
31
  - 0
32
- - 7
33
- - 0
34
- version: 0.7.0
32
+ - 1
33
+ - 1
34
+ version: 0.1.1
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency