yummi 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4089a0b7687580a80c189b1a1a5bdcffd0839b57
4
+ data.tar.gz: 61844b4fa6a5b833419f6b7ef2f114cd38219d3d
5
+ SHA512:
6
+ metadata.gz: c01ce312dd40c5cc027ed3dd6fceb87fb8ca10fce3f347d2052d63be28b727111f7c86d8f1b0fbd67cf7ca04cf56703214f1c01688aacdad4c16df57e81a7dad
7
+ data.tar.gz: 758f36d1626400b8238810fb189de5bb29c228f08782203af4cc60a025a0981e583b511021826be147e25f3f34b2cf7a52ae5daee2f98f9b13106b1266b49718
data/bin/yummi CHANGED
@@ -34,11 +34,14 @@ end
34
34
  opt.on '-f FORMAT', '--format=FORMAT', 'Sets the format to use (a "%s" means the colorized message)' do |format|
35
35
  @format = format
36
36
  end
37
+ opt.on '-n LEVEL', '--level=LEVEL', Integer, 'Sets the level to filter the patterns' do |n|
38
+ @level = n
39
+ end
37
40
  opt.on '-p PATTERNS', '--pattern=PATTERNS', Array, 'Sets a pattern to colorize each line' do |patterns|
38
41
  @colorizer = Yummi::Colorizers.pattern(patterns)
39
42
  end
40
43
  opt.on '--log', 'Uses the default log pattern to colorize each line' do
41
- @colorizer = Yummi::Colorizers.pattern :log
44
+ @colorizer = Yummi::Colorizers.pattern(:log)
42
45
  end
43
46
  opt.on '-m message', '--message=MESSAGE', 'Colorize the given message' do |message|
44
47
  @message = message
@@ -60,6 +63,10 @@ end
60
63
  opt.on '--box', 'Wraps the given text in a box' do
61
64
  @box = true
62
65
  end
66
+ opt.on '-v', '--version' , 'Shows the yummi version' do
67
+ puts Yummi::VERSION
68
+ exit
69
+ end
63
70
  opt.on '-h', '--help', 'Display this help message' do
64
71
  puts opt
65
72
  exit 0
@@ -72,6 +79,8 @@ end
72
79
 
73
80
  opt.parse! ARGV
74
81
 
82
+ @colorizer.level = @level if @level
83
+
75
84
  def print_out message
76
85
  output_text = if @color
77
86
  Yummi::colorize message, @color
@@ -80,9 +89,11 @@ def print_out message
80
89
  else
81
90
  message
82
91
  end
83
- output_text = "#{@format}" % output_text if @format
84
- output_text = output_text.on_box if @box
85
- puts output_text
92
+ if output_text
93
+ output_text = "#{@format}" % output_text if @format
94
+ output_text = output_text.on_box if @box
95
+ puts output_text
96
+ end
86
97
  end
87
98
 
88
99
  if @message
data/lib/yummi.rb CHANGED
@@ -240,18 +240,13 @@ module Yummi
240
240
  module Helpers
241
241
 
242
242
  def self.load_resource name, params = {:from => ''}
243
- file = File.expand_path name.to_s
244
- if File.file? file
245
- return YAML::load_file(file)
246
- else
247
- from = params[:from].to_s
248
- [
249
- File.join(File.expand_path('~/.yummi'), from),
250
- File.join(File.dirname(__FILE__), 'yummi', from)
251
- ].each do |path|
252
- file = File.join(path, "#{name}.yaml")
253
- return YAML::load_file(file) if File.exist?(file)
254
- end
243
+ from = params[:from].to_s
244
+ [
245
+ File.join(File.expand_path('~/.yummi'), from),
246
+ File.join(File.dirname(__FILE__), 'yummi', from)
247
+ ].each do |path|
248
+ file = File.join(path, "#{name}.yaml")
249
+ return YAML::load_file(file) if File.exist?(file)
255
250
  end
256
251
  raise Exception::new("Unable to load #{name}")
257
252
  end
@@ -85,8 +85,10 @@ module Yummi
85
85
  end
86
86
 
87
87
  # Returns a new instance of #PatternColorizer
88
- def self.pattern mappings
89
- PatternColorizer::new mappings
88
+ def self.pattern mappings, level = nil
89
+ colorizer = PatternColorizer::new(mappings)
90
+ colorizer.level = level if level
91
+ colorizer
90
92
  end
91
93
 
92
94
  #
@@ -232,6 +234,8 @@ module Yummi
232
234
  class PatternColorizer
233
235
  include Yummi::Colorizer
234
236
 
237
+ attr_writer :level
238
+
235
239
  def initialize mappings = nil
236
240
  @patterns = []
237
241
  map mappings if mappings
@@ -263,7 +267,7 @@ module Yummi
263
267
  if params.is_a? Array
264
268
  params.each { |p| map p }
265
269
  elsif params.is_a? String or params.is_a? Symbol
266
- map Yummi::Helpers::load_resource params, :from => :patterns
270
+ map Yummi::Helpers::load_resource(params, :from => :patterns)
267
271
  else
268
272
  config params
269
273
  end
@@ -273,7 +277,10 @@ module Yummi
273
277
  ctx = Yummi::Context::new(ctx) unless ctx.is_a? Context
274
278
  text = ctx.value.to_s
275
279
  @patterns.each do |config|
280
+ level = -1
276
281
  config[:patterns].each do |regex, color|
282
+ level += 1
283
+ return if @level and level > @level and not @last_color
277
284
  if regex.match(text)
278
285
  return match(text, config)
279
286
  end
data/lib/yummi/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Yummi
24
- VERSION = "0.9.1"
24
+ VERSION = "0.9.2"
25
25
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yummi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
5
- prerelease:
4
+ version: 0.9.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ataxexe
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2014-03-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: term-ansicolor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.1'
30
27
  description: A tool to colorize your console application.
@@ -70,26 +67,25 @@ files:
70
67
  - yummi.ipr
71
68
  homepage: https://github.com/ataxexe/yummi
72
69
  licenses: []
70
+ metadata: {}
73
71
  post_install_message:
74
72
  rdoc_options: []
75
73
  require_paths:
76
74
  - lib
77
75
  required_ruby_version: !ruby/object:Gem::Requirement
78
- none: false
79
76
  requirements:
80
- - - ! '>='
77
+ - - '>='
81
78
  - !ruby/object:Gem::Version
82
79
  version: '0'
83
80
  required_rubygems_version: !ruby/object:Gem::Requirement
84
- none: false
85
81
  requirements:
86
- - - ! '>='
82
+ - - '>='
87
83
  - !ruby/object:Gem::Version
88
84
  version: '0'
89
85
  requirements: []
90
86
  rubyforge_project:
91
- rubygems_version: 1.8.25
87
+ rubygems_version: 2.1.9
92
88
  signing_key:
93
- specification_version: 3
89
+ specification_version: 4
94
90
  summary: A tool to colorize your console application.
95
91
  test_files: []