miniyard 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,15 +2,33 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'miniyard'
5
- require 'haml'
5
+ require 'miniyard/copy'
6
+
7
+ options = {
8
+ root: Dir.pwd,
9
+ doc: nil,
10
+ cov: nil,
11
+ name: nil
12
+ }
6
13
 
7
- docroot = Dir.pwd
8
14
  OptionParser.new do |opts|
9
- opts.banner = "Usage: miniyard [options] app_file.rb"
10
- opts.on("-d PATH", "--docroot=PATH", "The root path to the hosted docs") do |v|
11
- docroot = v
15
+ opts.banner = "Usage: miniyard [options] [command]"
16
+ opts.on("-r PATH", "--root=PATH", "The root path to the hosted docs") do |v|
17
+ options[:root] = v
18
+ end
19
+ opts.on("-d SOURCE_DOCS""--doc=SOURCE_DOCS", "Docs folder to copy (requires --name option)") do |v|
20
+ options[:doc] = v
21
+ end
22
+ opts.on("-c SOURCE_COVERAGE", "--cov=SOURCE_COVERAGE", "Coverage folder to copy (requires --name option)") do |v|
23
+ options[:cov] = v
24
+ end
25
+ opts.on("-n NAME", "--name=NAME", "The name of the application folder in root. (Only applies to --cpdoc or --cpcov flags)") do |v|
26
+ options[:name] = v
12
27
  end
13
28
  end.parse!
14
29
 
15
- $stdout.puts('Generating docs at '+docroot)
16
- MiniYard::Generate.new(docroot).run
30
+ if options[:doc] || options[:cov]
31
+ MiniYard::Copy.new(options).run
32
+ end
33
+
34
+ MiniYard::Generate.new(options[:root]).run
@@ -1,5 +1,6 @@
1
1
  require "miniyard/version"
2
2
  require 'fileutils'
3
+ require 'haml'
3
4
 
4
5
  module MiniYard
5
6
  class Generate
@@ -10,6 +11,7 @@ module MiniYard
10
11
  end
11
12
 
12
13
  def run
14
+ $stdout.puts('Generating miniyard at '+@root)
13
15
  FileUtils.rm(index_file) if index_exists?
14
16
  output = haml_render(index_template)
15
17
  write_file(index_file, output)
@@ -0,0 +1,57 @@
1
+ module MiniYard
2
+ class Copy
3
+
4
+ def initialize(options)
5
+ verify_opts(options)
6
+ @options = options
7
+ end
8
+
9
+ def run
10
+ FileUtils.mkdir_p(folder_path) unless File.directory?(folder_path)
11
+
12
+ if @options[:doc]
13
+ $stdout.puts('Copying docs from %s to %s' % [doc_source_path, doc_dest_path])
14
+ FileUtils.rm_rf(doc_dest_path) if File.directory?(doc_dest_path)
15
+ FileUtils.cp_r(doc_source_path, doc_dest_path)
16
+ end
17
+
18
+ if @options[:cov]
19
+ $stdout.puts('Copying coverage from %s to %s' % [cov_source_path, cov_dest_path])
20
+ FileUtils.rm_rf(cov_dest_path) if File.directory?(doc_dest_path)
21
+ FileUtils.cp_r(cov_source_path, cov_dest_path)
22
+ end
23
+ end
24
+
25
+ def verify_opts(options)
26
+ raise 'Root directory %s does not exist' % options[:root] unless File.directory?(options[:root])
27
+ raise 'Doc source directory %s does not exist' % doc_source_path if options[:doc] && !File.directory?(options[:doc])
28
+ raise 'Coverage source directory %s does not exist' % cov_source_path if options[:cov] && !File.directory?(options[:cov])
29
+ raise 'Name must be present' % options[:name] unless options[:name]
30
+ end
31
+
32
+ def doc_source_path
33
+ File.expand_path(@options[:doc])
34
+ end
35
+
36
+ def cov_source_path
37
+ File.expand_path(@options[:cov])
38
+ end
39
+
40
+ def doc_dest_path
41
+ File.join(folder_path, 'doc')
42
+ end
43
+
44
+ def cov_dest_path
45
+ File.join(folder_path, 'cov')
46
+ end
47
+
48
+ def folder_path
49
+ File.join(root_path, @options[:name])
50
+ end
51
+
52
+ def root_path
53
+ File.expand_path(@options[:root])
54
+ end
55
+
56
+ end
57
+ end
@@ -1,3 +1,3 @@
1
1
  module MiniYard
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -5,10 +5,10 @@
5
5
  %link{rel: 'stylesheet', type: 'text/css', href: './bootstrap.1.4.0.min.css'}
6
6
  :javascript
7
7
  function selectFolder(anchor, folder) {
8
- document.getElementById('index-frame-link').href = './'+folder+'/index.html';
9
- document.getElementById('frames-frame-link').href = './'+folder+'/frames.html';
8
+ document.getElementById('doc-frame-link').href = './'+folder+'/doc/index.html';
9
+ document.getElementById('cov-frame-link').href = './'+folder+'/cov/index.html';
10
10
  setActive(anchor);
11
- setActive(document.getElementById('index-frame-link'));
11
+ setActive(document.getElementById('doc-frame-link'));
12
12
  }
13
13
  function setActive(anchor) {
14
14
  var ul = anchor.parentElement.parentElement;
@@ -38,15 +38,15 @@
38
38
  %ul
39
39
  - folders.each do |folder|
40
40
  %li
41
- %a{id: "#{folder}-link", href: "./#{folder}/index.html", target: 'frame', onclick: "javascript: selectFolder(this, '#{folder}')"}
41
+ %a{id: "#{folder}-link", href: "./#{folder}/doc/index.html", target: 'frame', onclick: "javascript: selectFolder(this, '#{folder}')"}
42
42
  = folder
43
43
 
44
44
  .content
45
45
  %ul#pill-nav.pills{"data-pills" => "pills"}
46
46
  %li
47
- %a{id: "index-frame-link", href: '#', target: "frame", onclick: "javascript: setActive(this)"} No Frames
47
+ %a{id: "doc-frame-link", href: 'javascript: void(0);', target: "frame", onclick: "javascript: setActive(this)"} Documentation
48
48
  %li
49
- %a{id: "frames-frame-link", href: '#', target: "frame", onclick: "javascript: setActive(this)"} Frames
49
+ %a{id: "cov-frame-link", href: 'javascript: void(0);', target: "frame", onclick: "javascript: setActive(this)"} Coverage
50
50
  %iframe#frame{name: 'frame', frameborder: '0'}
51
51
  %h3.title
52
52
  %span.bracket [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miniyard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml
16
- requirement: &2152046380 !ruby/object:Gem::Requirement
16
+ requirement: &2153365140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152046380
24
+ version_requirements: *2153365140
25
25
  description: A static html framebuilder to host multiple documentation folders
26
26
  email:
27
27
  - bj.neilsen@gmail.com
@@ -35,6 +35,7 @@ files:
35
35
  - Rakefile
36
36
  - bin/miniyard
37
37
  - lib/miniyard.rb
38
+ - lib/miniyard/copy.rb
38
39
  - lib/miniyard/version.rb
39
40
  - lib/templates/bootstrap.1.4.0.min.css
40
41
  - lib/templates/index.haml