monocle-print 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGVhMTAyZWIyYjRmMzdlMjJlNzkzNDM5MjdmYzExOWYxODA5YjFlMg==
4
+ YmQwZjE5MDc2Nzg1MWIxNWY3YmUwMTc1M2Y1NWU2Yjg5N2NlZGY1Ng==
5
5
  data.tar.gz: !binary |-
6
- OWFiZWYxNzUzYjgwZmFhZDU0OWI2ZDIyMzRmMDU4MWQ5MzgzMTFjNw==
6
+ ODM3ODlmMGNjYjc0MzVhYmU4M2Y1MjBmOWJhMjZlZjQ2YzZjOWM5OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjAyNzQzNDAxMmVhMTYxYmVmZjgwNzlkYmI2ZWU4OWZiMzE4MjQ3NjQ1YjIz
10
- ZTkxNDYyY2MzYjA0MDlkMDc4OGQ5ZjFhMjNjMjFkMTVmZWQxNjgxYzllNTRm
11
- MjQwNTQ1NTJjYzc4NDkxNWZlZWE2ZDFhNTg1ZTkzNGQyOTVlM2Q=
9
+ NzU1NzczZWY0YmIyMWNkYWViMDIxNGVmNjA0MTViYWNiODY5NjlkMTI1ZTUz
10
+ NTRmNWE4NDcxMTU1ZGU5NjM1NTg2NDUwMjljZWRmN2U0YjFiZDllY2UzZjIz
11
+ YjkwYTdmOGQyMDM0ZmNmOGExYjFmYmUxM2JiNWQ4MWQwODU4MTg=
12
12
  data.tar.gz: !binary |-
13
- MjIzZDUyODIzNGU1Yzc0ODc5ODkwMzQ4NTJlMjNjMmZmNGFiNTc3ZTdlMDE2
14
- ZGUxM2QwZDllZTFlNDFjMDk2NTExZTQzNzY4OTUyZWRmOTdiMDhjMDRhYjBl
15
- MTc5YmY3ZDA5NGFiMTEwMjMzMjRlYTA0ZmE3ZjFjMjdmMDhmODg=
13
+ YzhjNTE3YjRlMTkwMjE5MWY4NzEwNTgyY2U2NjliZWNhOWM4MzUyMjU1MDE1
14
+ MjFkYjEwYWNmZjgxODc1M2RkZjYwN2JmMjZkYzE1ODE1ZjBkZGI2ODNiNTA3
15
+ MmQ0MjQ3MWNjNmU4ZmJlNGJkNmUwNWIyZmQ2M2FmOGVmYmFkZGE=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ # gem "rails"
data/Manifest.txt CHANGED
@@ -1,3 +1,8 @@
1
+ Gemfile
2
+ History.txt
3
+ Manifest.txt
4
+ Rakefile
5
+ README.txt
1
6
  lib/monocle-print.rb
2
7
  lib/monocle-print/layout.rb
3
8
  lib/monocle-print/table/segments.rb
@@ -6,6 +11,7 @@ lib/monocle-print/table/column.rb
6
11
  lib/monocle-print/output-device.rb
7
12
  lib/monocle-print/graphics.rb
8
13
  lib/monocle-print/table.rb
14
+ lib/monocle-print/graphics/registry.rb
9
15
  lib/monocle-print/list.rb
10
16
  lib/monocle-print/progress.rb
11
17
  lib/monocle-print/presentation.rb
@@ -13,7 +19,3 @@ lib/monocle-print/utils.rb
13
19
  lib/monocle-print/terminal-escapes.rb
14
20
  lib/monocle-print/geometry.rb
15
21
  lib/monocle-print/atomic.rb
16
- History.txt
17
- Manifest.txt
18
- README.txt
19
- Rakefile
data/lib/monocle-print.rb CHANGED
@@ -11,7 +11,7 @@ require 'delegate'
11
11
  autoload :StringIO, 'stringio' unless defined?( StringIO )
12
12
 
13
13
  module MonoclePrint
14
- VERSION = '1.0.4'
14
+ VERSION = '1.0.5'
15
15
 
16
16
  def self.version
17
17
  VERSION
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/ruby
2
+ # encoding: utf-8
3
+ #
4
+ # author: Kyle Yetter
5
+ #
6
+
7
+ module MonoclePrint
8
+ module GraphicsRegistry
9
+ ENV_KEY = "MONOCLE_PRINT_STYLE"
10
+ FALLBACK_STYLE = "single_line"
11
+
12
+ attr_accessor :default_style
13
+
14
+ def named_styles
15
+ @named_styles ||= Hash.new { |h, k| h[ default_style ].dup }
16
+ end
17
+
18
+ def style?( name )
19
+ named_styles.key?( name.to_s )
20
+ end
21
+
22
+ def style( name )
23
+ named_styles[ name.to_s ]
24
+ end
25
+
26
+ def styles
27
+ named_styles.keys
28
+ end
29
+
30
+ def default_style
31
+ @default_style ||= detect_style_from_env
32
+ end
33
+
34
+ def default
35
+ style( default_style )
36
+ end
37
+
38
+ def define( name, *parts )
39
+ parts.map! { | p | Line( p ).freeze }
40
+ name = name.to_s
41
+ definition = new( *parts ).freeze
42
+ named_styles.store( name, definition )
43
+ define_singleton_method( name ) { style( name ) }
44
+ definition
45
+ end
46
+
47
+ private
48
+
49
+ def detect_style_from_env
50
+ default_style = ENV.fetch( ENV_KEY, FALLBACK_STYLE )
51
+ unless style?( default_style )
52
+ message = <<-END.gsub!( /^\s*\| ?/, '' ).strip!.gsub!( /\s+/, ' ' )
53
+ | cannot set MonoclePrint's default graphics style
54
+ | from the MONOCLE_PRINT_STYLE environment variable as `%s'
55
+ | is not a known style; defaulting to `%s'
56
+ END
57
+ warn( message % [ default_style, FALLBACK_STYLE ] )
58
+ default_style = FALLBACK_STYLE
59
+ end
60
+ default_style
61
+ end
62
+ end
63
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monocle-print
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - monocle-print
@@ -48,6 +48,11 @@ extra_rdoc_files:
48
48
  - Manifest.txt
49
49
  - README.txt
50
50
  files:
51
+ - Gemfile
52
+ - History.txt
53
+ - Manifest.txt
54
+ - Rakefile
55
+ - README.txt
51
56
  - lib/monocle-print.rb
52
57
  - lib/monocle-print/layout.rb
53
58
  - lib/monocle-print/table/segments.rb
@@ -56,6 +61,7 @@ files:
56
61
  - lib/monocle-print/output-device.rb
57
62
  - lib/monocle-print/graphics.rb
58
63
  - lib/monocle-print/table.rb
64
+ - lib/monocle-print/graphics/registry.rb
59
65
  - lib/monocle-print/list.rb
60
66
  - lib/monocle-print/progress.rb
61
67
  - lib/monocle-print/presentation.rb
@@ -63,10 +69,6 @@ files:
63
69
  - lib/monocle-print/terminal-escapes.rb
64
70
  - lib/monocle-print/geometry.rb
65
71
  - lib/monocle-print/atomic.rb
66
- - History.txt
67
- - Manifest.txt
68
- - README.txt
69
- - Rakefile
70
72
  - .gemtest
71
73
  homepage: http://ohboyohboyohboy.org
72
74
  licenses: