markdown 0.1.0 → 0.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ Hoe.spec 'markdown' do
14
14
  self.email = 'webslideshow@googlegroups.com'
15
15
 
16
16
  self.extra_deps = [
17
+ ['props','>= 0.1.0'],
17
18
  ['kramdown','>= 0.13.6']
18
19
  ]
19
20
 
@@ -13,6 +13,17 @@ require 'optparse'
13
13
  require 'fileutils'
14
14
 
15
15
 
16
+ # rubygems
17
+
18
+ require 'props' # manage properties/settings/env
19
+
20
+ class Env
21
+ def self.markdown_lib
22
+ ENV['MARKDOWN_LIB']
23
+ end
24
+ end # class Env
25
+
26
+
16
27
  # our own code
17
28
 
18
29
  require 'markdown/config'
@@ -28,7 +39,7 @@ require 'markdown/gen'
28
39
 
29
40
  module Markdown
30
41
 
31
- VERSION = '0.1.0'
42
+ VERSION = '0.2.0.beta1'
32
43
 
33
44
  # version string for generator meta tag (includes ruby version)
34
45
  def self.banner
@@ -1,67 +1,5 @@
1
1
  module Markdown
2
2
 
3
- class Env
4
- def self.home
5
- path = if( ENV['HOME'] || ENV['USERPROFILE'] )
6
- ENV['HOME'] || ENV['USERPROFILE']
7
- elsif( ENV['HOMEDRIVE'] && ENV['HOMEPATH'] )
8
- "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}"
9
- else
10
- begin
11
- File.expand_path('~')
12
- rescue
13
- if File::ALT_SEPARATOR
14
- 'C:/'
15
- else
16
- '/'
17
- end
18
- end
19
- end
20
-
21
- puts "env home=>#{path}<"
22
- path
23
- end
24
-
25
- def self.markdown_lib
26
- ENV['MARKDOWN_LIB']
27
- end
28
- end # class Env
29
-
30
- class Props
31
-
32
- attr_reader :path
33
- attr_reader :parent
34
-
35
- def initialize( hash, path, parent=nil)
36
- @hash = hash
37
- @path = path
38
- @parent = parent
39
- end
40
-
41
- def self.load_file( path, parent=nil )
42
- h = YAML.load_file( path )
43
- puts "dump of >#{path}<:"
44
- pp h # todo: add debug flag (turn off for default)
45
- Props.new( h, path, parent )
46
- end
47
-
48
- def [](key) get( key ); end
49
-
50
- def fetch(key, default)
51
- value = get( key )
52
- value.nil? ? default : value
53
- end
54
-
55
- private
56
- def get( key )
57
- value = @hash[ key.to_s ]
58
- # if not found try lookup in parent hash
59
- (value.nil? && parent) ? parent[key] : value
60
- end
61
-
62
- end # class props
63
-
64
-
65
3
  class Config
66
4
 
67
5
  # note: only kramdown is listed as a dependency in gem specs (because it's Ruby only and, thus, easy to install)
@@ -80,7 +18,20 @@ private
80
18
  # 'kramdown' ] }
81
19
 
82
20
  # note: make kramdown default engine
83
- DEFAULTS = { 'libs' => [ 'kramdown' ] }
21
+
22
+ DEFAULTS = { 'libs' => [
23
+ 'kramdown' ],
24
+ 'extnames' => [
25
+ '.markdown',
26
+ '.m',
27
+ '.mark',
28
+ '.mkdn',
29
+ '.md',
30
+ '.mdown',
31
+ '.markdn',
32
+ '.txt',
33
+ '.text' ] # todo: check - add .wiki??? ext
34
+ }
84
35
 
85
36
 
86
37
  def initialize
@@ -107,7 +58,11 @@ DEFAULTS = { 'libs' => [ 'kramdown' ] }
107
58
  @libs = []
108
59
  @mn = nil # markdown converter method name (mn) e.g. kramdown_to_html
109
60
 
110
- require_markdown_libs()
61
+ require_markdown_libs()
62
+ end
63
+
64
+ def markdown_extnames
65
+ @props.fetch( 'extnames', nil )
111
66
  end
112
67
 
113
68
  def known_markdown_libs
@@ -3,16 +3,12 @@ module Markdown
3
3
 
4
4
  class Opts
5
5
 
6
- def initialize
7
- @hash = {}
6
+ def output_path=(value)
7
+ @output_path = value
8
8
  end
9
-
10
- def put( key, value )
11
- @hash[ key.to_s ] = value
12
- end
13
9
 
14
10
  def output_path
15
- @hash.fetch( 'output', '.' )
11
+ @output_path ||= '.'
16
12
  end
17
13
 
18
14
  end # class Opts
@@ -30,18 +26,6 @@ module Markdown
30
26
  end
31
27
 
32
28
 
33
- ### fix/todo:
34
- # make configureable
35
- DEFAULT_MARKDOWN_EXTENSIONS = [
36
- '.markdown',
37
- '.m',
38
- '.mark',
39
- '.mkdn',
40
- '.md',
41
- '.txt',
42
- '.text' ]
43
-
44
-
45
29
  def with_output_path( dest, output_path )
46
30
  dest_full = File.expand_path( dest, output_path )
47
31
  logger.debug "dest_full=#{dest_full}"
@@ -113,7 +97,7 @@ module Markdown
113
97
 
114
98
  return false if extname.empty? # no extension
115
99
 
116
- DEFAULT_MARKDOWN_EXTENSIONS.include?( extname.downcase )
100
+ Markdown.extnames.include?( extname.downcase )
117
101
  end
118
102
 
119
103
  def find_file_with_markdown_extension( fn )
@@ -122,7 +106,7 @@ module Markdown
122
106
  extname = File.extname( fn )
123
107
  logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}"
124
108
 
125
- DEFAULT_MARKDOWN_EXTENSIONS.each do |e|
109
+ Markdown.extnames.each do |e|
126
110
  logger.debug "File.exists? #{dirname}/#{basename}#{e}"
127
111
  return "#{dirname}/#{basename}#{e}" if File.exists?( "#{dirname}/#{basename}#{e}" )
128
112
  end # each extension (e)
@@ -186,7 +170,7 @@ module Markdown
186
170
  else # check for existing file w/ missing extension
187
171
  file = find_file_with_markdown_extension( file_or_dir_or_pattern )
188
172
  if file.nil?
189
- puts " skipping missing file '#{file_or_dir_or_pattern}{#{DEFAULT_MARKDOWN_EXTENSIONS.join(',')}}'..."
173
+ puts " skipping missing file '#{file_or_dir_or_pattern}{#{Markdown.extnames.join(',')}}'..."
190
174
  else
191
175
  logger.debug " adding file '#{file}'..."
192
176
  filtered_files << file
@@ -202,7 +186,7 @@ module Markdown
202
186
 
203
187
  cmd.banner = "Usage: markdown [options] name"
204
188
 
205
- cmd.on( '-o', '--output PATH', 'Output Path' ) { |s| opts.put( 'output', s ) }
189
+ cmd.on( '-o', '--output PATH', 'Output Path' ) { |path| opts.output_path = path }
206
190
 
207
191
  # todo: find different letter for debug trace switch (use v for version?)
208
192
  cmd.on( "-v", "--verbose", "Show debug trace" ) do
@@ -210,22 +194,26 @@ module Markdown
210
194
  logger.level = Logger::DEBUG
211
195
  end
212
196
 
213
- ## todo: add #{Markdown.lib} to help message?? yes/no
214
197
 
198
+ usage =<<EOS
199
+
200
+ markdown - Lets you convert plain text documents (#{Markdown.extnames.join(', ')}) to hypertext (.html) with your Markdown engine of choice (#{Markdown.lib}).
201
+
202
+ #{cmd.help}
203
+
204
+ Examples:
205
+ markdown # Process all documents in working folder (that is, .)
206
+ markdown ruby_tut # Process document or folder using Markdown
207
+ markdown ruby_tut.text # Process document using Markdown
208
+ markdown -o site ruby_tut # Output documents to site folder
209
+
210
+ Further information:
211
+ http://geraldb.github.com/markdown
212
+
213
+ EOS
214
+
215
215
  cmd.on_tail( "-h", "--help", "Show this message" ) do
216
- puts
217
- puts "markdown - Lets you convert plain text documents (#{DEFAULT_MARKDOWN_EXTENSIONS.join(', ')}) to hypertext (.html) with your Markdown engine of choice."
218
- puts
219
- puts cmd.help
220
- puts
221
- puts "Examples:"
222
- puts " markdown # Process all documents in working folder (that is, .)"
223
- puts " markdown ruby_tut # Process document or folder using Markdown"
224
- puts " markdown ruby_tut.text # Process document using Markdown"
225
- puts " markdown -o site ruby_tut # Output documents to site folder"
226
- puts
227
- puts "Further information:"
228
- puts " http://geraldb.github.com/markdown"
216
+ puts usage
229
217
  exit
230
218
  end
231
219
  end
@@ -26,15 +26,22 @@ module Markdown
26
26
 
27
27
  @@config = nil
28
28
 
29
- def self.lib( value = nil )
30
- if value.nil?
31
- if @@config.nil?
32
- @@config = Config.new
33
- end
34
- @@config.markdown_lib
35
- else
36
- ## todo: lets you select your library
29
+ def self.lib=( value )
30
+ ## todo: lets you select your library
31
+ end
32
+
33
+ def self.lib
34
+ if @@config.nil?
35
+ @@config = Config.new
36
+ end
37
+ @@config.markdown_lib
38
+ end
39
+
40
+ def self.extnames
41
+ if @@config.nil?
42
+ @@config = Config.new
37
43
  end
44
+ @@config.markdown_extnames
38
45
  end
39
46
 
40
47
  def self.new( content, options={} )
@@ -18,7 +18,7 @@ require 'lib/markdown'
18
18
  class TestKramdown < Test::Unit::TestCase
19
19
 
20
20
  def setup
21
- Markdown.lib( 'kramdown' )
21
+ Markdown.lib = 'kramdown'
22
22
  end
23
23
 
24
24
  def test_lib
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
4
+ hash: 792793622
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ - beta
11
+ - 1
12
+ version: 0.2.0.beta1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Gerald Bauer
@@ -15,12 +17,28 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-06-02 00:00:00 Z
20
+ date: 2012-06-03 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
- name: kramdown
23
+ name: props
22
24
  prerelease: false
23
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 27
31
+ segments:
32
+ - 0
33
+ - 1
34
+ - 0
35
+ version: 0.1.0
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: kramdown
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
24
42
  none: false
25
43
  requirements:
26
44
  - - ">="
@@ -32,11 +50,11 @@ dependencies:
32
50
  - 6
33
51
  version: 0.13.6
34
52
  type: :runtime
35
- version_requirements: *id001
53
+ version_requirements: *id002
36
54
  - !ruby/object:Gem::Dependency
37
55
  name: rdoc
38
56
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
57
+ requirement: &id003 !ruby/object:Gem::Requirement
40
58
  none: false
41
59
  requirements:
42
60
  - - ~>
@@ -47,11 +65,11 @@ dependencies:
47
65
  - 10
48
66
  version: "3.10"
49
67
  type: :development
50
- version_requirements: *id002
68
+ version_requirements: *id003
51
69
  - !ruby/object:Gem::Dependency
52
70
  name: hoe
53
71
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
72
+ requirement: &id004 !ruby/object:Gem::Requirement
55
73
  none: false
56
74
  requirements:
57
75
  - - ~>
@@ -62,7 +80,7 @@ dependencies:
62
80
  - 0
63
81
  version: "3.0"
64
82
  type: :development
65
- version_requirements: *id003
83
+ version_requirements: *id004
66
84
  description: Markdown Engine Wrapper - Use Your Markdown Library of Choice
67
85
  email: webslideshow@googlegroups.com
68
86
  executables:
@@ -110,12 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
128
  required_rubygems_version: !ruby/object:Gem::Requirement
111
129
  none: false
112
130
  requirements:
113
- - - ">="
131
+ - - ">"
114
132
  - !ruby/object:Gem::Version
115
- hash: 3
133
+ hash: 25
116
134
  segments:
117
- - 0
118
- version: "0"
135
+ - 1
136
+ - 3
137
+ - 1
138
+ version: 1.3.1
119
139
  requirements: []
120
140
 
121
141
  rubyforge_project: markdown