cloudhead-mutter 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +32 -15
  2. data/VERSION +1 -1
  3. data/lib/mutter.rb +8 -4
  4. data/mutter.gemspec +4 -5
  5. metadata +4 -4
data/README.md CHANGED
@@ -1,21 +1,24 @@
1
1
  mutter
2
2
  ======
3
3
 
4
- > $ my words come out,
5
- > in color and style
4
+ $ my words come out,
5
+ in color and
6
+ style
6
7
 
7
- mutter is the tiny CLI library, with a focus on style.
8
- use it in your apps to have better looking command-line output!
8
+ > mutter is the tiny CLI library, with a focus on style.
9
9
 
10
- printing to the command-line
11
- ----------------------------
10
+ use it in your apps to have _gorgeous_ command-line output!
11
+
12
+ usage (command-line output)
13
+ ---------------------------
12
14
 
13
15
  require 'mutter'
14
16
 
15
17
  mut = Mutter.new
16
- mut.say "hello _world_" # underlines 'world'
17
- mut.say "hello world", :bold # bolds the whole string
18
- mut.say "hello [world]", :cyan # inverts 'world', and colors the string cyan
18
+ mut.say "hello _world_" # underlines 'world'
19
+ mut.say "hello world", :bold # bolds the whole string
20
+ mut.say "hello [world]", :cyan # inverts 'world', and colors the string cyan
21
+ mut.print "bonjour!" # alias of `say`
19
22
 
20
23
  styles
21
24
  ------
@@ -31,12 +34,12 @@ customization
31
34
  -------------
32
35
 
33
36
  styles = {
34
- :warning => {
35
- :match => ['*!', '!*'],
36
- :style => ['yellow', 'bold']
37
+ :warning => { # an alias you can use anywhere in mutter
38
+ :match => ['*!', '!*'], # will match *!mutter!*
39
+ :style => ['yellow', 'bold'] # these styles will be applied to the match
37
40
  },
38
41
  :error => {
39
- :match => '!!',
42
+ :match => '!!', # will match !!mutter!!
40
43
  :style => ['red', 'underline']
41
44
  }
42
45
  }
@@ -44,6 +47,13 @@ customization
44
47
  mut = Mutter.new(styles)
45
48
  mut.say "warning, warning!", :warning
46
49
  mut.say "gosh, we have an !!error!!"
50
+
51
+ ### quick styles
52
+
53
+ mut = Mutter.new :yellow => '~'
54
+ mut.say "~[black on yellow!]~"
55
+
56
+ ### YAML styles
47
57
 
48
58
  mutter can also read styles from _YAML_ files, just give it the path, like so:
49
59
 
@@ -51,5 +61,12 @@ mutter can also read styles from _YAML_ files, just give it the path, like so:
51
61
 
52
62
  There's an example style in `spec/`
53
63
 
54
- have fun!
55
- ---------
64
+ installation
65
+ ------------
66
+
67
+ $ sudo gem install cloudhead-mutter
68
+
69
+ That's it!
70
+ ----------
71
+
72
+ _have fun_
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/lib/mutter.rb CHANGED
@@ -29,7 +29,7 @@ module Mutter
29
29
  when Array
30
30
  @active = obj
31
31
  when Symbol
32
- @active << obj
32
+ self.<< obj
33
33
  when String
34
34
  load obj
35
35
  else raise ArgumentError
@@ -61,6 +61,10 @@ module Mutter
61
61
  end
62
62
  end
63
63
 
64
+ def << style
65
+ @active << style
66
+ end
67
+
64
68
  def parse string
65
69
  @styles.inject(string) do |str, (name, options)|
66
70
  glyph, styles = options[:match], options[:style]
@@ -68,9 +72,9 @@ module Mutter
68
72
  str.gsub(/#{Regexp.escape(glyph.first)}(.+?)
69
73
  #{Regexp.escape(glyph.last)}/x) { stylize $1, styles }
70
74
  else
71
- str.gsub(/(#{Regexp.escape(glyph)}+)(.+?)\1/) { stylize $2, styles }
72
- end
73
- end
75
+ str.gsub(/(#{Regexp.escape(glyph)}+)(.+?)\1/) { stylize $2, styles }
76
+ end
77
+ end
74
78
  end
75
79
 
76
80
  def stylize string, styles = []
data/mutter.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{mutter}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["cloudhead"]
9
- s.date = %q{2009-07-29}
9
+ s.date = %q{2009-07-30}
10
10
  s.email = %q{self@cloudhead.net}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -26,11 +26,10 @@ Gem::Specification.new do |s|
26
26
  "spec/spec_helper.rb",
27
27
  "spec/style.yml"
28
28
  ]
29
- s.has_rdoc = true
30
29
  s.homepage = %q{http://github.com/cloudhead/mutter}
31
30
  s.rdoc_options = ["--charset=UTF-8"]
32
31
  s.require_paths = ["lib"]
33
- s.rubygems_version = %q{1.3.1}
32
+ s.rubygems_version = %q{1.3.5}
34
33
  s.summary = %q{}
35
34
  s.test_files = [
36
35
  "spec/mutter_spec.rb",
@@ -39,7 +38,7 @@ Gem::Specification.new do |s|
39
38
 
40
39
  if s.respond_to? :specification_version then
41
40
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
- s.specification_version = 2
41
+ s.specification_version = 3
43
42
 
44
43
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
44
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudhead-mutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-29 00:00:00 -07:00
12
+ date: 2009-07-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -35,7 +35,7 @@ files:
35
35
  - spec/mutter_spec.rb
36
36
  - spec/spec_helper.rb
37
37
  - spec/style.yml
38
- has_rdoc: true
38
+ has_rdoc: false
39
39
  homepage: http://github.com/cloudhead/mutter
40
40
  licenses:
41
41
  post_install_message:
@@ -60,7 +60,7 @@ requirements: []
60
60
  rubyforge_project:
61
61
  rubygems_version: 1.3.5
62
62
  signing_key:
63
- specification_version: 2
63
+ specification_version: 3
64
64
  summary: ""
65
65
  test_files:
66
66
  - spec/mutter_spec.rb