legal_markdown 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,8 +17,9 @@ module LegalToMarkdown
17
17
  @content = get_file(@input_file)
18
18
  elsif @input_file == "-"
19
19
  @content = STDIN.read
20
- else
21
- raise "No input file or stdin specified. Please specify a file or \"-\" for stdin."
20
+ end
21
+ if @content == nil
22
+ puts "No input file or stdin specified. Please specify a file or \"-\" for stdin."
22
23
  exit 0
23
24
  end
24
25
  end
@@ -61,7 +62,7 @@ module LegalToMarkdown
61
62
 
62
63
  def get_file( file )
63
64
  begin
64
- f = File::read(file) if File::exists?(file) && File::readable?(file)
65
+ f = File::read(file)
65
66
  rescue => e
66
67
  puts "Sorry, I could not read the file #{file}: #{e.message}."
67
68
  exit 0
@@ -1,3 +1,3 @@
1
1
  module LegalMarkdown
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -42,7 +42,7 @@ class TestLegalMarkdownToMarkdown < Test::Unit::TestCase
42
42
  end
43
43
 
44
44
  def test_markdown_files
45
- puts "Testing lmd to markdown files.\n\n"
45
+ puts "\n\nTesting lmd to markdown files.\n\n"
46
46
  @lmdfiles.each do | lmd_file |
47
47
  puts "Testing => #{lmd_file}"
48
48
  temp_file = create_temp('.md')
@@ -82,4 +82,27 @@ class TestLegalMarkdownToMarkdown < Test::Unit::TestCase
82
82
  destroy_temp temp_file
83
83
  end
84
84
  end
85
+
86
+ def test_command_line
87
+ puts "\n\nTesting the command line caller.\n\n"
88
+ cmds = [ "--headers", "--to-markdown", "--to-json", '', '' ]
89
+ file = "00.load_write_no_action.lmd"
90
+ output = ['', create_temp('.md'), create_temp('.json'), create_temp('.md'), create_temp('.json')]
91
+ puts "Testing => cat 00.load_write_no_action.lmd | legal2md - -"
92
+ stdin_out_only = `cat 00.load_write_no_action.lmd | legal2md - -`
93
+ assert_equal(get_file(file), stdin_out_only)
94
+ cmds = cmds.each{|l| l << (" " + file) }.zip(output)
95
+ cmds.each do |cmd|
96
+ cmd = 'legal2md ' + cmd.join(' ')
97
+ puts "Testing => #{cmd}"
98
+ `#{cmd}`
99
+ assert_equal(get_file(file), get_file('00.load_write_no_action.md'))
100
+ end
101
+ end
102
+
103
+ def test_bad_filename
104
+ puts "Testing bad file name.\n\n"
105
+ cmd = `legal2md -m 12345.lmd 12345.md`
106
+ assert_equal( cmd, "Sorry, I could not read the file 12345.lmd: No such file or directory - 12345.lmd.\n" )
107
+ end
85
108
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legal_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-05 00:00:00.000000000 Z
12
+ date: 2013-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coveralls
@@ -198,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  segments:
200
200
  - 0
201
- hash: -4574451422924128598
201
+ hash: 510656448113333799
202
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  none: false
204
204
  requirements:
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  version: '0'
208
208
  segments:
209
209
  - 0
210
- hash: -4574451422924128598
210
+ hash: 510656448113333799
211
211
  requirements: []
212
212
  rubyforge_project:
213
213
  rubygems_version: 1.8.25