any2html 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. data/any2html.gemspec +1 -1
  2. data/bin/any2html +32 -28
  3. metadata +1 -1
data/any2html.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'any2html'
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "any2html"
8
- s.version = '0.0.2'
8
+ s.version = '0.0.3'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.required_ruby_version = '>= 1.9.0'
11
11
 
data/bin/any2html CHANGED
@@ -2,40 +2,44 @@
2
2
  require 'bluecloth'
3
3
  require 'RedCloth'
4
4
  require 'sinatra'
5
+ require 'haml'
6
+
7
+
5
8
 
6
- map1 = {
7
- BlueCloth => %w(md markdown),
8
- RedCloth => %w(textile)
9
- }
10
- map2 = map1.invert.inject ({}) {|m, (k,v)| k.each{|k1| m[k1] = v};m}
11
-
12
-
13
- rootdir = ARGV[0] || '.'
14
- # TODO dry this up
15
- files = `find #{rootdir} -name '*.md' -o -name '*.markdown' -o -name '*.textile' `.split(/\n/)
16
- $sources = files.inject({}) do |m,file|
17
- ext = File.extname(file)[1..-1]
18
- if (formatter = map2[ext])
19
- m[file] = {
20
- file: file,
21
- formatter: formatter
22
- }
9
+ class Any2html < Sinatra::Application
10
+ map1 = {
11
+ BlueCloth => %w(md markdown),
12
+ RedCloth => %w(textile)
13
+ }
14
+ map2 = map1.invert.inject ({}) {|m, (k,v)| k.each{|k1| m[k1] = v};m}
15
+ rootdir = ARGV[0] || '.'
16
+ # TODO dry this up
17
+ files = `find #{rootdir} -name '*.md' -o -name '*.markdown' -o -name '*.textile' `.split(/\n/)
18
+ $sources = files.inject({}) do |m,file|
19
+ ext = File.extname(file)[1..-1]
20
+ if (formatter = map2[ext])
21
+ m[file.sub(/^\./,'')] = {
22
+ filepath: file,
23
+ formatter: formatter
24
+ }
25
+ end
26
+ m
23
27
  end
24
- m
25
- end
26
28
 
27
- require 'haml'
29
+ get '/' do
30
+ haml :index
31
+ end
28
32
 
29
- get '/' do
30
- haml :index
31
- end
33
+ get '*' do
34
+ file = params[:splat][0]
35
+ x = $sources[file]
36
+ x[:html] ||= x[:formatter].new(File.read(x[:filepath])).to_html
37
+ end
32
38
 
33
- get '*' do
34
- file = params[:splat][0]
35
- $sources[file][:html] ||= $sources[file][:formatter].new(File.read(file)).to_html
36
- end
39
+ fork { system('open http://localhost:4567') }
40
+ run!
37
41
 
38
- fork { system('open http://localhost:4567') }
42
+ end
39
43
  __END__
40
44
 
41
45
  @@index
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: any2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: