notorious 0.1.3 → 0.1.4

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.
data/README.md CHANGED
@@ -62,6 +62,13 @@ Or install it yourself as:
62
62
 
63
63
  ![Example Output](https://raw.github.com/zackrw/notorious/v1/spec/examples/example.png)
64
64
 
65
+ ###Opening Multiple Files
66
+ *If you specify multiple files to `build`, notorious will concatenate them and
67
+ make an output file called "multiple_files.html" in your current working
68
+ directory (unless you specify a -o)*
69
+
70
+ $ notorious build notes.md other_notes.md
71
+
65
72
  ###To run this example
66
73
 
67
74
  $ notorious example
@@ -36,6 +36,10 @@ def parse
36
36
  options[:verbose] = v
37
37
  end
38
38
 
39
+ opts.on("--version", "Print Version") do |v|
40
+ options[:version] = v
41
+ end
42
+
39
43
  end
40
44
  opts.parse!
41
45
  options
@@ -44,6 +48,11 @@ end
44
48
  # Parse options
45
49
  options = parse
46
50
 
51
+ if options[:version]
52
+ puts "Notorious: version #{Notorious::VERSION}"
53
+ exit
54
+ end
55
+
47
56
  # assign arguments
48
57
  unless ARGV[0]
49
58
  puts "Notorious. Run `notorious --help` for details"
@@ -55,22 +64,30 @@ end
55
64
 
56
65
  case ARGV[0]
57
66
  when 'build'
58
- options[:file_name] = ARGV[1] || raise(ArgumentError, "you must specify a file to build")
67
+ options[:file_names] = ARGV[1..-1]
68
+ raise(ArgumentError, "you must specify a file to build") if options[:file_names].length == 0
59
69
  when 'example'
60
- options[:file_name] = File.expand_path("../../spec/examples/example_notes.md", __FILE__)
70
+ options[:file_names] = [File.expand_path("../../spec/examples/example_notes.md", __FILE__)]
61
71
  else
62
72
  raise ArgumentError, "you have specified an invalid command"
63
73
  end
64
74
 
65
- # must be a markdown file
66
- Notorious.validate_extension(options[:file_name], ["md", "mdown", "markdown", "Markdown"])
75
+ # must be a markdown files
76
+ options[:file_names].each do |f|
77
+ Notorious.validate_extension(f, ["md", "mdown", "markdown", "Markdown"])
78
+ end
67
79
 
68
80
  options[:stylesheet] ||= File.expand_path("../../stylesheets/default.css", __FILE__)
69
81
 
70
82
  unless options[:output]
71
- split = options[:file_name].split('.')
72
- split.pop if split.length > 1
73
- options[:output] = split.push('html').join('.')
83
+ if options[:file_names].length == 1
84
+ file_name = options[:file_names][0]
85
+ split = file_name.split('.')
86
+ split.pop if split.length > 1
87
+ options[:output] = split.push('html').join('.')
88
+ else
89
+ options[:output] = 'multiple_files.html'
90
+ end
74
91
  end
75
92
 
76
93
 
@@ -6,7 +6,7 @@ require "redcarpet"
6
6
  module Notorious
7
7
 
8
8
  def self.build(opts)
9
- file_name = opts[:file_name]
9
+ file_names = opts[:file_names]
10
10
  stylesheet = opts[:stylesheet]
11
11
  title = opts[:title]
12
12
  output = opts[:output]
@@ -14,7 +14,7 @@ module Notorious
14
14
 
15
15
 
16
16
  # make the html
17
- html = self.render(file_name, title, stylesheet)
17
+ html = self.render(file_names, title, stylesheet)
18
18
 
19
19
  # write to the output file
20
20
  outfile = File.new(File.expand_path(output), 'w')
@@ -33,26 +33,30 @@ module Notorious
33
33
  end
34
34
  end
35
35
 
36
- def self.render(file_name, title, stylesheet)
36
+ def self.render(file_names, title, stylesheet)
37
37
  begin
38
38
  styles = File.new(stylesheet, 'r').read
39
39
  rescue
40
40
  raise RuntimeError, "Could not load the stylesheet. Make sure there is a file at #{stylesheet}"
41
41
  end
42
42
 
43
- # read in and convert the markdown file
44
- begin
45
- md_file = File.new(file_name, 'r')
46
- rescue
47
- raise ArgumentError, "Could not find the file you specified: #{file_name}"
43
+ body = ""
44
+
45
+ file_names.each do |f|
46
+ # read in and convert the markdown file
47
+ begin
48
+ md_file = File.new(f, 'r')
49
+ rescue
50
+ raise ArgumentError, "Could not find the file you specified: #{f}"
51
+ end
52
+
53
+ # convert markdown to HTML
54
+ md_contents = md_file.read
55
+ md = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
56
+ body += md.render(md_contents)
57
+ md_file.close
48
58
  end
49
59
 
50
- # convert markdown to HTML
51
- md_contents = md_file.read
52
- md = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
53
- body = md.render(md_contents)
54
- md_file.close
55
-
56
60
  self.html(styles, title, body)
57
61
  end
58
62
 
@@ -1,3 +1,3 @@
1
1
  module Notorious
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -111,7 +111,7 @@ body{font-size:16px;}
111
111
  }
112
112
 
113
113
  </style>
114
- <title>Tech Notes</title>
114
+ <title></title>
115
115
  </head>
116
116
  <body>
117
117
  <!-- notes.md -->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notorious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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: 2012-10-19 00:00:00.000000000 Z
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redcarpet