slideshow 1.1.0.beta4 → 1.1.0.beta5

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.
@@ -70,7 +70,7 @@ require 'slideshow/filters/slide_filter'
70
70
 
71
71
  module Slideshow
72
72
 
73
- VERSION = '1.1.0.beta4'
73
+ VERSION = '1.1.0.beta5'
74
74
 
75
75
  def self.root
76
76
  "#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
@@ -6,18 +6,13 @@ class Gen
6
6
  @logger = Logger.new(STDOUT)
7
7
  @logger.level = Logger::INFO
8
8
 
9
- @config = Config.new
10
- @opts = Opts.new( @config )
9
+ @config = Config.new
10
+ @opts = Opts.new
11
+ @headers = Headers.new( @config )
11
12
  end
12
13
 
13
- attr_reader :logger, :opts, :config
14
+ attr_reader :logger, :opts, :config, :headers
14
15
  attr_reader :session # give helpers/plugins a session-like hash
15
-
16
- def headers
17
- # give access to helpers to opts with a different name
18
- ### fix/todo: use a headers wrapper?? delegation to opts.header(key) lookup??
19
- @opts
20
- end
21
16
 
22
17
  attr_reader :markup_type # :textile, :markdown, :rest
23
18
 
@@ -58,7 +53,7 @@ class Gen
58
53
  end
59
54
 
60
55
 
61
- def wrap_markup( text )
56
+ def wrap_markup( text )
62
57
  if markup_type == :textile
63
58
  # saveguard with notextile wrapper etc./no further processing needed
64
59
  "<notextile>\n#{text}\n</notextile>"
@@ -66,24 +61,12 @@ class Gen
66
61
  text
67
62
  end
68
63
  end
69
-
70
- # todo/fix: move to Config class
64
+
65
+ # todo/fix: move to Config class
71
66
  def cache_dir
72
- RUBY_PLATFORM =~ /win32/ ? win32_cache_dir : File.join(File.expand_path("~"), ".slideshow")
67
+ File.join( Env.home, '.slideshow' )
73
68
  end
74
69
 
75
- # todo/fix: move to Config class
76
- def win32_cache_dir
77
- unless ENV['HOMEDRIVE'] && ENV['HOMEPATH'] && File.exists?(home = ENV['HOMEDRIVE'] + ENV['HOMEPATH'])
78
- puts "No HOMEDRIVE or HOMEPATH environment variable. Set one to save a" +
79
- "local cache of stylesheets for syntax highlighting and more."
80
- return false
81
- else
82
- return File.join(home, '.slideshow')
83
- end
84
- end
85
-
86
- # todo/fix: move to Config class
87
70
  def config_dir
88
71
  unless @config_dir # first time? calculate config_dir value to "cache"
89
72
 
@@ -346,8 +329,6 @@ class Gen
346
329
  @name = basename
347
330
  @extname = extname
348
331
 
349
- @headers = @opts # deprecate/remove: use headers method in template
350
-
351
332
  @session = {} # reset session hash for plugins/helpers
352
333
 
353
334
  inname = "#{dirname}/#{basename}#{extname}"
@@ -436,13 +417,13 @@ def run( args )
436
417
 
437
418
  cmd.banner = "Usage: slideshow [options] name"
438
419
 
439
- cmd.on( '-o', '--output PATH', 'Output Path' ) { |s| opts.put( 'output', s ) }
420
+ cmd.on( '-o', '--output PATH', 'Output Path' ) { |path| opts.output_path = path }
440
421
 
441
- cmd.on( '-g', '--generate', 'Generate Slide Show Templates (Using Built-In S6 Pack)' ) { opts.put( 'generate', true ) }
422
+ cmd.on( '-g', '--generate', 'Generate Slide Show Templates (Using Built-In S6 Pack)' ) { opts.generate = true }
442
423
 
443
424
  cmd.on( "-t", "--template MANIFEST", "Template Manifest" ) do |t|
444
425
  # todo: do some checks on passed in template argument
445
- opts.put( 'manifest', t )
426
+ opts.manifest = t
446
427
  end
447
428
 
448
429
  # ?? opts.on( "-s", "--style STYLE", "Select Stylesheet" ) { |s| $options[:style]=s }
@@ -450,15 +431,15 @@ def run( args )
450
431
 
451
432
  # ?? cmd.on( '-i', '--include PATH', 'Load Path' ) { |s| opts.put( 'include', s ) }
452
433
 
453
- cmd.on( '-f', '--fetch URI', 'Fetch Templates' ) do |u|
454
- opts.put( 'fetch_uri', u )
434
+ cmd.on( '-f', '--fetch URI', 'Fetch Templates' ) do |uri|
435
+ opts.fetch_uri = uri
455
436
  end
456
437
 
457
- cmd.on( '-c', '--config PATH', 'Configuration Path (default is ~/.slideshow)' ) do |p|
458
- opts.put( 'config_path', p )
438
+ cmd.on( '-c', '--config PATH', 'Configuration Path (default is ~/.slideshow)' ) do |path|
439
+ opts.config_path = path
459
440
  end
460
441
 
461
- cmd.on( '-l', '--list', 'List Installed Templates' ) { opts.put( 'list', true ) }
442
+ cmd.on( '-l', '--list', 'List Installed Templates' ) { opts.list = true }
462
443
 
463
444
  # todo: find different letter for debug trace switch (use v for version?)
464
445
  cmd.on( "-v", "--verbose", "Show debug trace" ) do
@@ -3,13 +3,13 @@ module Slideshow
3
3
  # todo: split (command line) options and headers?
4
4
  # e.g. share (command line) options between slide shows (but not headers?)
5
5
 
6
- class Opts
7
-
6
+ class Headers
7
+
8
8
  def initialize( config )
9
9
  @hash = {}
10
10
  @config = config
11
11
  end
12
-
12
+
13
13
  def put( key, value )
14
14
  key = normalize_key( key )
15
15
  setter = "#{key}=".to_sym
@@ -20,7 +20,7 @@ class Opts
20
20
  @hash[ key ] = value
21
21
  end
22
22
  end
23
-
23
+
24
24
  def gradient=( line )
25
25
  # split into theme (first value) and colors (everything else)
26
26
  # e.g. diagonal red black
@@ -49,43 +49,6 @@ class Opts
49
49
  value
50
50
  end
51
51
 
52
- def generate?
53
- get_boolean( 'generate', false )
54
- end
55
-
56
- def list?
57
- get_boolean( 'list', false )
58
- end
59
-
60
- def fetch?
61
- @hash.has_key?( :fetch_uri )
62
- end
63
-
64
- def fetch_uri
65
- get( 'fetch_uri', '-fetch uri required-' )
66
- end
67
-
68
- def has_includes?
69
- @hash.has_key?( :include )
70
- end
71
-
72
- def includes
73
- # fix: use os-agnostic delimiter (use : for Mac/Unix?)
74
- has_includes? ? @hash[ :include ].split( ';' ) : []
75
- end
76
-
77
- def manifest
78
- get( 'manifest', 's6.txt' )
79
- end
80
-
81
- def config_path
82
- get( 'config_path' )
83
- end
84
-
85
- def output_path
86
- get( 'output', '.' )
87
- end
88
-
89
52
  def code_engine
90
53
  get( 'code-engine' )
91
54
  end
@@ -107,6 +70,7 @@ class Opts
107
70
  :code_txmt => 'false', # Text Mate Hyperlink for Source?
108
71
  }
109
72
 
73
+ ## todo: rename get to fetch??
110
74
  def get( key, default=nil )
111
75
  key = normalize_key(key)
112
76
  value = @hash.fetch( key, DEFAULTS[ key ] )
@@ -132,7 +96,81 @@ private
132
96
  (value == true || value =~ /true|yes|on/i) ? true : false
133
97
  end
134
98
  end
99
+
100
+ end # class Headers
101
+
102
+
103
+ class Opts
104
+
105
+ def generate=(value)
106
+ @generate = value
107
+ end
108
+
109
+ def generate?
110
+ return false if @generate.nil? # default generate flag is false
111
+ @generate == true
112
+ end
113
+
114
+ def list=(value)
115
+ @list = value
116
+ end
117
+
118
+ def list?
119
+ return false if @list.nil? # default list flag is false
120
+ @list == true
121
+ end
122
+
123
+
124
+ def fetch_uri=(value)
125
+ @fetch_uri = value
126
+ end
127
+
128
+ def fetch_uri
129
+ @fetch_uri || '-fetch uri required-'
130
+ end
131
+
132
+ def fetch?
133
+ @fetch_uri.nil? ? false : true
134
+ end
135
+
136
+
137
+ def includes=(value)
138
+ @includes = value
139
+ end
140
+
141
+ def includes
142
+ # fix: use os-agnostic delimiter (use : for Mac/Unix?)
143
+ @includes.nil? ? [] : @includes.split( ';' )
144
+ end
145
+
146
+ def has_includes?
147
+ @includes.nil? ? false : true
148
+ end
149
+
150
+ def manifest=(value)
151
+ @manifest = value
152
+ end
153
+
154
+ def manifest
155
+ @manifest || 's6.txt'
156
+ end
157
+
158
+ def config_path=(value)
159
+ @config_path = value
160
+ end
161
+
162
+ def config_path
163
+ @config_path
164
+ end
165
+
166
+ def output_path=(value)
167
+ @output_path = value
168
+ end
169
+
170
+ def output_path
171
+ @output_path || '.'
172
+ end
135
173
 
136
174
  end # class Opts
137
175
 
138
- end # module Slideshow
176
+ end # module Slideshow
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow
3
3
  version: !ruby/object:Gem::Version
4
- hash: -829632114
4
+ hash: 689500001
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
9
  - 0
10
10
  - beta
11
- - 4
12
- version: 1.1.0.beta4
11
+ - 5
12
+ version: 1.1.0.beta5
13
13
  platform: ruby
14
14
  authors:
15
15
  - Gerald Bauer
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-06-10 00:00:00 Z
20
+ date: 2012-06-12 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: RedCloth