markview 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/markview CHANGED
File without changes
File without changes
File without changes
data/lib/markview.rb CHANGED
@@ -4,24 +4,21 @@ require 'sinatra'
4
4
  require 'rdiscount'
5
5
 
6
6
  module Markview
7
- class Application < Sinatra::Base
7
+ class Application < Sinatra::Base
8
+ dir = File.dirname(File.expand_path(__FILE__))
8
9
 
9
- set :views, File.expand_path(File.dirname(__FILE__)) + '/views'
10
- set :public, File.expand_path(File.dirname(__FILE__)) + '/static'
10
+ set :views, "#{dir}/markview/views"
11
+ set :public, "#{dir}/markview/public"
12
+ set :static, true
11
13
 
14
+ # Renders the html using RDiscount
12
15
  def self.markdown_me
13
- ARGV[0] ||= Dir.glob("*.{md,markdown}")[0]; mdown=""
16
+ ARGV[0] ||= Dir.glob("*.{md,markdown}")[0];
14
17
  begin
15
- File.open("#{ARGV[0]}", "r") { |f|
16
- f.each_line do |line|
17
- mdown += line
18
- end
19
- }
18
+ RDiscount.new( File.open("#{ARGV[0]}", 'r').read ).to_html
20
19
  rescue Errno::ENOENT
21
- raise "Failed to load README. Please specify a file."
22
- exit
20
+ raise LoadError, "Failed open document. Please specify a file."; exit
23
21
  end
24
- RDiscount.new(mdown).to_html
25
22
  end
26
23
 
27
24
  get '/' do
data/test/render_test.rb CHANGED
@@ -14,6 +14,13 @@ class RenderTest < Test::Unit::TestCase
14
14
  assert_equal RDiscount.new(File.read(ARGV[0])).to_html, Markview::Application.markdown_me
15
15
  end
16
16
 
17
+ test "no markdown file given or found raises error" do
18
+ ARGV[0] = "bad_file_name"
19
+ assert_raises LoadError do
20
+ Markview::Application.markdown_me
21
+ end
22
+ end
23
+
17
24
  test "Vegas runs application" do
18
25
  pid = fork { Vegas::Runner.new(Markview::Application, 'markview', :foreground => true, :skip_launch => true, :debug => true) }
19
26
  sleep(1)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Sands
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-26 00:00:00 -06:00
12
+ date: 2010-02-27 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,7 +62,7 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: 0.7.0
64
64
  version:
65
- description: A markdown viewer that renders on the fly.
65
+ description: Conveniently launches markdown formatted files in a browser, rendering on the fly.
66
66
  email: marksands07@gmail.com
67
67
  executables:
68
68
  - markview
@@ -73,8 +73,8 @@ extra_rdoc_files: []
73
73
  files:
74
74
  - bin/markview
75
75
  - lib/markview.rb
76
- - lib/static/style.css
77
- - lib/views/base.erb
76
+ - lib/markview/public/style.css
77
+ - lib/markview/views/base.erb
78
78
  - README.md
79
79
  - test/render_test.rb
80
80
  has_rdoc: true