index_html 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 916801ae83c983bb1101121453c449621b0231c7
4
+ data.tar.gz: 8c09a497ccdfe218f9a01589ed61556acf276d89
5
+ SHA512:
6
+ metadata.gz: 794d5981e35fcaa1d625fb716536c28582ee979868df9666d660ed9fa5ed4dde9dfccae04d872868df82a9b1af925051c9390d276f4c9a1f2d2892c082a1b388
7
+ data.tar.gz: 47e8277361427c2d549f70a55e7a453864b9101c4d26f86d67fd191460f9b0701f6220e91d5086c60faaa90afbfaa09d474ca3032ddde09d791d1cb69ec614b8
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ # custom generated files
20
+ index.html
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in file_indexer.gemspec
4
+ gemspec
5
+
6
+ gem 'code_lister', "~> 0.0.4"
7
+ gem 'gem-ctags'
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+ guard :rspec do
4
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Burin Choomnuan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # IndexHtml
2
+
3
+ Quickly generate the index.html files based on your select criteria.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'index_html'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install index_html
18
+
19
+ ## Usage
20
+
21
+ Say you have lots of ebook files (pdf, epub, or mobi) and you have properly named them
22
+ with something like [ebook_renamer](https://rubygems.org/gems/ebook_renamer).
23
+
24
+ Now that you have the good inputs, if you like to create a quick index to all of the files
25
+ that have the specific word 'Android' in the title you could perhap try something like the following:
26
+
27
+ ```sh
28
+ gem install index_html
29
+ cd ~/Dropbox/ebooks/
30
+ index_html generate --base-dir . \
31
+ --exts epub pdf mobi \
32
+ --inc-words android
33
+ ```
34
+ ## Help/Usage:
35
+ Just type `index_html` without any options to see the list of help
36
+
37
+ ```
38
+ Usage:
39
+ index_html generate [OPTIONS]
40
+
41
+ Options:
42
+ -b, [--base-dir=BASE_DIR] # Base directory
43
+ # Default: . (current directory)
44
+ -e, [--exts=one two three] # List of extensions to search for
45
+ -n, [--inc-words=one two three] # List of words to be included in the result if any
46
+ -x, [--exc-words=one two three] # List of words to be excluded from the result if any
47
+ -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
48
+ # Default: true
49
+ -r, [--recursive], [--no-recursive] # Search for files recursively
50
+ # Default: true
51
+ -p, [--prefix=PREFIX] # Prefix string to the URL
52
+ d, [--indent=N] # Indentation to each list item in the output
53
+ # Default: 6
54
+ -o, [--output=OUTPUT] # Output file name
55
+ # Default: index.html
56
+ -v, [--version], [--no-version] # Display version information
57
+
58
+ Generate the index.html base on simple criteria
59
+ ```
60
+
61
+ This will generate the file `index.html` that you can open from your favourite browser.
62
+
63
+ ## Sample output
64
+
65
+ - Sample list of files from a given directory
66
+
67
+ ```shell
68
+ $html_index generate --base-dir=spec/fixtures --exts=rb java --recursive
69
+ ```
70
+ The output file `index.html` should be generated with something like
71
+
72
+ ```html
73
+ <html>
74
+ <title>File Listing</title>
75
+ <header>File List</header>
76
+ <body>
77
+ <ol>
78
+ <li><a href="spec/fixtures/demo1.xxx.java" target="_blank">spec/fixtures/demo1.xxx.java</li>
79
+ <li><a href="spec/fixtures/demo1.xxx.rb" target="_blank">spec/fixtures/demo1.xxx.rb</li>
80
+ <li><a href="spec/fixtures/demo2.xxx.java" target="_blank">spec/fixtures/demo2.xxx.java</li>
81
+ <li><a href="spec/fixtures/demo2.xxx.rb" target="_blank">spec/fixtures/demo2.xxx.rb</li>
82
+ <li><a href="spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">spec/fixtures/sub-dir/demo3.yyy.java</li>
83
+ <li><a href="spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo3.yyy.rb</li>
84
+ <li><a href="spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">spec/fixtures/sub-dir/demo4.yyy.java</li>
85
+ <li><a href="spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo4.yyy.rb</li>
86
+ </ol>
87
+ </body>
88
+ </html>
89
+ ```
90
+ - Run with simple prefix option
91
+
92
+ ```shell
93
+ html_index generate --base-dir=spec/fixtures --exts=rb java --recursive --prefix=http://localhost/
94
+ ```
95
+
96
+ The output file `index.html` should be something like
97
+
98
+ ```html
99
+ <html>
100
+ <title>File Listing</title>
101
+ <header>File List</header>
102
+ <body>
103
+ <ol>
104
+ <li><a href="http://localhost/spec/fixtures/demo1.xxx.java" target="_blank">spec/fixtures/demo1.xxx.java</li>
105
+ <li><a href="http://localhost/spec/fixtures/demo1.xxx.rb" target="_blank">spec/fixtures/demo1.xxx.rb</li>
106
+ <li><a href="http://localhost/spec/fixtures/demo2.xxx.java" target="_blank">spec/fixtures/demo2.xxx.java</li>
107
+ <li><a href="http://localhost/spec/fixtures/demo2.xxx.rb" target="_blank">spec/fixtures/demo2.xxx.rb</li>
108
+ <li><a href="http://localhost/spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">spec/fixtures/sub-dir/demo3.yyy.java</li>
109
+ <li><a href="http://localhost/spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo3.yyy.rb</li>
110
+ <li><a href="http://localhost/spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">spec/fixtures/sub-dir/demo4.yyy.java</li>
111
+ <li><a href="http://localhost/spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo4.yyy.rb</li>
112
+ </ol>
113
+ </body>
114
+ </html>
115
+ ```
116
+
117
+ ## Contributing
118
+
119
+ 1. Fork it
120
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
121
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
122
+ 4. Push to the branch (`git push origin my-new-feature`)
123
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ require "bundler/gem_tasks"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :default => :spec
7
+
8
+ task :irb do
9
+ require 'irb'
10
+ require 'awesome_print'
11
+ require 'irb/completion'
12
+ require 'index_html'
13
+ include FileIndexer
14
+ ARGV.clear
15
+ IRB.start
16
+ end
17
+
18
+ task :pry do
19
+ require 'pry'
20
+ require 'awesome_print'
21
+ require 'index_html'
22
+ include FileIndexer
23
+ ARGV.clear
24
+ Pry.start
25
+ end
data/bin/index_html ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'code_lister'
3
+ require_relative '../lib/index_html'
4
+ include IndexHtml
5
+ IndexHtml::CLI.start(ARGV)
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'index_html/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "index_html"
8
+ spec.version = IndexHtml::VERSION
9
+ spec.authors = ["Burin Choomnuan"]
10
+ spec.email = ["agilecreativity@gmail.com"]
11
+ spec.description = %q{Generate the index.html from list of files}
12
+ spec.summary = %q{Generate simple index.html from list of files}
13
+ spec.homepage = "https://github.com/agilecreativity/file_indexer"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "code_lister", "~> 0.0.4"
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", "~> 2.14"
25
+ spec.add_development_dependency "guard-rspec", "~> 4.2"
26
+ spec.add_development_dependency "awesome_print", "~> 1.2"
27
+ spec.add_development_dependency "pry", "~> 0.9"
28
+ spec.add_development_dependency "fuubar", "~> 1.3"
29
+
30
+ end
@@ -0,0 +1,35 @@
1
+ class Hash
2
+
3
+ # File activesupport/lib/active_support/core_ext/hash/keys.rb
4
+ #
5
+ # hash = { name: 'Rob', age: '28' }
6
+ # hash.transform_keys{ |key| key.to_s.upcase }
7
+ # => { "NAME" => "Rob", "AGE" => "28" }
8
+ def transform_keys
9
+ result = {}
10
+ each_key do |key|
11
+ result[yield(key)] = self[key]
12
+ end
13
+ result
14
+ end
15
+
16
+ def transform_keys!(&block)
17
+ keys.each do |key|
18
+ value = delete(key)
19
+ self[yield(key)] = value.is_a?(Hash) ? value.transform_keys!(&block) : value
20
+ end
21
+ self
22
+ end
23
+
24
+ # hash = { 'name' => 'Rob', 'age' => '28' }
25
+ # hash.symbolize_keys
26
+ # => { name: "Rob", age: "28" }
27
+ def symbolize_keys
28
+ transform_keys{ |key| key.to_sym rescue key }
29
+ end
30
+
31
+ # File activesupport/lib/active_support/core_ext/hash/keys.rb, line 135
32
+ def symbolize_keys!
33
+ transform_keys!{ |key| key.to_sym rescue key }
34
+ end
35
+ end
@@ -0,0 +1,36 @@
1
+ require 'tempfile'
2
+ module Kernel
3
+ # From: 'activesupport-4.1.0/lib/active_support/core_ext/kernel/reporting.rb
4
+ #
5
+ # Captures the given stream and returns it:
6
+ #
7
+ # stream = capture(:stdout) { puts 'notice' }
8
+ # stream # => "notice\n"
9
+ #
10
+ # stream = capture(:stderr) { warn 'error' }
11
+ # stream # => "error\n"
12
+ #
13
+ # even for subprocesses:
14
+ #
15
+ # stream = capture(:stdout) { system('echo notice') }
16
+ # stream # => "notice\n"
17
+ #
18
+ # stream = capture(:stderr) { system('echo error 1>&2') }
19
+ # stream # => "error\n"
20
+ def capture(stream)
21
+ stream = stream.to_s
22
+ captured_stream = Tempfile.new(stream)
23
+ stream_io = eval("$#{stream}")
24
+ origin_stream = stream_io.dup
25
+ stream_io.reopen(captured_stream)
26
+
27
+ yield
28
+
29
+ stream_io.rewind
30
+ return captured_stream.read
31
+ ensure
32
+ captured_stream.close
33
+ captured_stream.unlink
34
+ stream_io.reopen(origin_stream)
35
+ end
36
+ end
@@ -0,0 +1,109 @@
1
+ require 'thor'
2
+ require_relative '../index_html'
3
+
4
+ module IndexHtml
5
+ #TODO: this should be re-use from the 'CodeLister' module
6
+ class BaseCLI < Thor
7
+ def self.shared_options
8
+
9
+ method_option :base_dir,
10
+ aliases: "-b",
11
+ desc: "Base directory",
12
+ default: Dir.pwd
13
+
14
+ method_option :exts,
15
+ aliases: "-e",
16
+ desc: "List of extensions to search for",
17
+ type: :array,
18
+ default: []
19
+
20
+ method_option :inc_words,
21
+ aliases: "-n",
22
+ desc: "List of words to be included in the result if any",
23
+ type: :array,
24
+ default: []
25
+
26
+ method_option :exc_words,
27
+ aliases: "-x",
28
+ desc: "List of words to be excluded from the result if any",
29
+ type: :array,
30
+ default: []
31
+
32
+ method_option :ignore_case,
33
+ aliases: "-i",
34
+ desc: "Match case insensitively",
35
+ type: :boolean,
36
+ default: true
37
+
38
+ method_option :recursive,
39
+ aliases: "-r",
40
+ desc: "Search for files recursively",
41
+ type: :boolean,
42
+ default: true
43
+ end
44
+ end
45
+
46
+ class CLI < IndexHtml::BaseCLI
47
+ desc 'generate', 'Generate the index.html base on simple criteria'
48
+ shared_options
49
+
50
+ method_option :prefix,
51
+ aliases: "-p",
52
+ desc: "Prefix string to the URL",
53
+ default: "" # empty string
54
+
55
+ method_option :indent,
56
+ aliases: "d",
57
+ desc: "Indentation to each list item in the output",
58
+ type: :numeric,
59
+ default: 6
60
+
61
+ method_option :output,
62
+ aliases: "-o",
63
+ desc: "Output file name",
64
+ type: :string,
65
+ default: "index.html"
66
+
67
+ method_option :version,
68
+ aliases: "-v",
69
+ desc: "Display version information",
70
+ type: :boolean,
71
+ default: false
72
+
73
+ def generate
74
+ if options[:version]
75
+ puts "You are using IndexHtml Version #{IndexHtml::VERSION}"
76
+ exit
77
+ end
78
+ IndexHtml::Main.run(options.symbolize_keys)
79
+ end
80
+
81
+ desc "usage", "Display help screen"
82
+ def usage
83
+ puts <<-EOS
84
+ Usage:
85
+ cli.rb generate
86
+
87
+ Options:
88
+ -b, [--base-dir=BASE_DIR] # Base directory
89
+ # Default: . (current directory)
90
+ -e, [--exts=one two three] # List of extensions to search for
91
+ -n, [--inc-words=one two three] # List of words to be included in the result if any
92
+ -x, [--exc-words=one two three] # List of words to be excluded from the result if any
93
+ -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
94
+ # Default: true
95
+ -r, [--recursive], [--no-recursive] # Search for files recursively
96
+ # Default: true
97
+ -p, [--prefix=PREFIX] # Prefix string to the URL
98
+ d, [--indent=N] # Indentation to each list item in the output
99
+ # Default: 6
100
+ -o, [--output=OUTPUT] # Output file name
101
+ # Default: index.html
102
+ -v, [--version], [--no-version] # Display version information
103
+
104
+ Generate the index.html base on simple criteria
105
+ EOS
106
+ end
107
+ default_task :usage
108
+ end
109
+ end
@@ -0,0 +1,15 @@
1
+ module IndexHtml
2
+ class Main
3
+ class << self
4
+ def run(options = {})
5
+ files = CodeLister.files options || []
6
+ unless files.empty?
7
+ IndexHtml.htmlify files, options
8
+ puts "FYI: your result is in #{options[:output]}"
9
+ else
10
+ puts "No match found for your options :#{options}"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module IndexHtml
2
+ VERSION = "0.0.1"
3
+ end
data/lib/index_html.rb ADDED
@@ -0,0 +1,80 @@
1
+ require 'uri'
2
+ require_relative "./index_html/version"
3
+ require_relative "./index_html/cli"
4
+ require_relative "./index_html/main"
5
+ require_relative "./active_support/core_ext/hash/hash"
6
+ require_relative "./active_support/core_ext/kernel/reporting"
7
+
8
+ module IndexHtml
9
+
10
+ CustomError = Class.new(StandardError)
11
+
12
+ class << self
13
+
14
+ # Create html links to list of files
15
+ def htmlify(file_list, args = {})
16
+
17
+ header = <<-END.gsub(/^\s+\|/, '')
18
+ |<html>
19
+ |<title>File Listing</title>
20
+ |<header>File List</header>
21
+ | <body>
22
+ | <ol>
23
+ END
24
+
25
+ footer = <<-END.gsub(/^\s+\|/, '')
26
+ | </ol>
27
+ | </body>
28
+ |</html>
29
+ END
30
+
31
+ # our options
32
+ prefix = args.fetch(:prefix, "")
33
+ indent = args.fetch(:indent, 6)
34
+ output = args.fetch(:output, "index.html")
35
+
36
+ # write the output to files
37
+ File.open(output, "w") do |f|
38
+ f.write(header)
39
+ make_links(file_list, prefix: prefix).each { |i| f.write("#{' ' * indent}#{i}\n") }
40
+ f.write(footer)
41
+ end
42
+ end
43
+
44
+ # Transform the list of full path to list of base name
45
+ #
46
+ # @param [Array<String>] file_list if of file path
47
+ # @param [Hash<Symbol, Object>] args list of options
48
+ #
49
+ # @return [Array<String>] list of basename of a given input file
50
+ def basenames!(file_list, args = {})
51
+ file_list.map!{ |file| File.basename(file) } if args.fetch(:basename, false)
52
+ file_list
53
+ end
54
+
55
+ def escape_uris!(file_list, args = {})
56
+ if args.fetch(:encoded, false)
57
+ file_list.map!{ |file| URI.escape(file, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) }
58
+ end
59
+ file_list
60
+ end
61
+
62
+ # Make links using <li> tags
63
+ #
64
+ # @return [Array] the list of valid <li> tags
65
+ def make_links(file_list, args = {})
66
+ original_links = file_list
67
+ escape_uris!(file_list, args)
68
+ file_list = basenames!(file_list, args)
69
+
70
+ prefix = args.fetch(:prefix, "")
71
+
72
+ result = []
73
+ original_links.zip(file_list).each do |i,j|
74
+ result << %Q{<li><a href="#{prefix}#{j}" target="_blank">#{i}</li>}
75
+ end
76
+ result
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1 @@
1
+ #file: spec/fixtures/demo1.xxx.rb
@@ -0,0 +1 @@
1
+ #file: spec/fixtures/demo1.xxx.rb
@@ -0,0 +1 @@
1
+ #file: spec/fixtures/demo2.xxx.rb
@@ -0,0 +1 @@
1
+ #file: spec/fixtures/demo2.xxx.rb
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/sub-dir/demo3.yyy.java
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/sub-dir/demo3.yyy.java
File without changes
File without changes
@@ -0,0 +1,90 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe IndexHtml do
4
+
5
+ let(:files) {
6
+ CodeLister.files base_dir: 'spec/fixtures',
7
+ exts: %w(xxx.rb), recursive: true
8
+ }
9
+
10
+ context '#basenames!' do
11
+ it 'excludes full path of the files' do
12
+ expect(IndexHtml.basenames!(files, basename: true)).to eq ["demo1.xxx.rb",
13
+ "demo2.xxx.rb"]
14
+ end
15
+
16
+ it 'includes full path of the files' do
17
+ expect(IndexHtml.basenames!(files)).to eq ["spec/fixtures/demo1.xxx.rb",
18
+ "spec/fixtures/demo2.xxx.rb"]
19
+ expect(IndexHtml.basenames!(files, basename: false)).to eq ["spec/fixtures/demo1.xxx.rb",
20
+ "spec/fixtures/demo2.xxx.rb"]
21
+ end
22
+ end
23
+
24
+ context '#escape_uris!' do
25
+ it 'works correctly with full path' do
26
+ expect(IndexHtml.escape_uris!(files, encoded: true)).to eq ["spec%2Ffixtures%2Fdemo1.xxx.rb",
27
+ "spec%2Ffixtures%2Fdemo2.xxx.rb"]
28
+ end
29
+ end
30
+
31
+ #TODO: add proper test here
32
+ context '#htmlify' do
33
+ let :files do
34
+ CodeLister.files base_dir: 'spec/fixtures',
35
+ exts: %w(rb java),
36
+ recursive: true
37
+ end
38
+
39
+ it 'generates simple index file' do
40
+ IndexHtml.htmlify files,
41
+ indent: 6,
42
+ output: 'index.html'
43
+ expect(capture(:stdout) { system('cat index.html') }).to eq \
44
+ <<-EOT
45
+ <html>
46
+ <title>File Listing</title>
47
+ <header>File List</header>
48
+ <body>
49
+ <ol>
50
+ <li><a href="spec/fixtures/demo1.xxx.java" target="_blank">spec/fixtures/demo1.xxx.java</li>
51
+ <li><a href="spec/fixtures/demo1.xxx.rb" target="_blank">spec/fixtures/demo1.xxx.rb</li>
52
+ <li><a href="spec/fixtures/demo2.xxx.java" target="_blank">spec/fixtures/demo2.xxx.java</li>
53
+ <li><a href="spec/fixtures/demo2.xxx.rb" target="_blank">spec/fixtures/demo2.xxx.rb</li>
54
+ <li><a href="spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">spec/fixtures/sub-dir/demo3.yyy.java</li>
55
+ <li><a href="spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo3.yyy.rb</li>
56
+ <li><a href="spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">spec/fixtures/sub-dir/demo4.yyy.java</li>
57
+ <li><a href="spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo4.yyy.rb</li>
58
+ </ol>
59
+ </body>
60
+ </html>
61
+ EOT
62
+ end
63
+
64
+ it 'generates simple index file with prefix' do
65
+ IndexHtml.htmlify files,
66
+ indent: 6,
67
+ output: 'index.html',
68
+ prefix: 'http://agilecreativity.com/'
69
+ expect(capture(:stdout) { system('cat index.html') }).to eq \
70
+ <<-EOT
71
+ <html>
72
+ <title>File Listing</title>
73
+ <header>File List</header>
74
+ <body>
75
+ <ol>
76
+ <li><a href="http://agilecreativity.com/spec/fixtures/demo1.xxx.java" target="_blank">spec/fixtures/demo1.xxx.java</li>
77
+ <li><a href="http://agilecreativity.com/spec/fixtures/demo1.xxx.rb" target="_blank">spec/fixtures/demo1.xxx.rb</li>
78
+ <li><a href="http://agilecreativity.com/spec/fixtures/demo2.xxx.java" target="_blank">spec/fixtures/demo2.xxx.java</li>
79
+ <li><a href="http://agilecreativity.com/spec/fixtures/demo2.xxx.rb" target="_blank">spec/fixtures/demo2.xxx.rb</li>
80
+ <li><a href="http://agilecreativity.com/spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">spec/fixtures/sub-dir/demo3.yyy.java</li>
81
+ <li><a href="http://agilecreativity.com/spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo3.yyy.rb</li>
82
+ <li><a href="http://agilecreativity.com/spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">spec/fixtures/sub-dir/demo4.yyy.java</li>
83
+ <li><a href="http://agilecreativity.com/spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">spec/fixtures/sub-dir/demo4.yyy.rb</li>
84
+ </ol>
85
+ </body>
86
+ </html>
87
+ EOT
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,24 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
18
+
19
+ require_relative '../lib/index_html'
20
+ require_relative '../lib/active_support/core_ext/kernel/reporting'
21
+ require 'code_lister'
22
+
23
+ include CodeLister
24
+ include IndexHtml
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: index_html
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Burin Choomnuan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: code_lister
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.2'
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.9'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.9'
111
+ - !ruby/object:Gem::Dependency
112
+ name: fuubar
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.3'
125
+ description: Generate the index.html from list of files
126
+ email:
127
+ - agilecreativity@gmail.com
128
+ executables:
129
+ - index_html
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".ruby-version"
135
+ - Gemfile
136
+ - Guardfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/index_html
141
+ - index_html.gemspec
142
+ - lib/active_support/core_ext/hash/hash.rb
143
+ - lib/active_support/core_ext/kernel/reporting.rb
144
+ - lib/index_html.rb
145
+ - lib/index_html/cli.rb
146
+ - lib/index_html/main.rb
147
+ - lib/index_html/version.rb
148
+ - spec/fixtures/demo1.xxx.java
149
+ - spec/fixtures/demo1.xxx.rb
150
+ - spec/fixtures/demo2.xxx.java
151
+ - spec/fixtures/demo2.xxx.rb
152
+ - spec/fixtures/sub-dir/demo3.yyy.java
153
+ - spec/fixtures/sub-dir/demo3.yyy.rb
154
+ - spec/fixtures/sub-dir/demo4.yyy.java
155
+ - spec/fixtures/sub-dir/demo4.yyy.rb
156
+ - spec/index_html/index_html_spec.rb
157
+ - spec/spec_helper.rb
158
+ homepage: https://github.com/agilecreativity/file_indexer
159
+ licenses:
160
+ - MIT
161
+ metadata: {}
162
+ post_install_message:
163
+ rdoc_options: []
164
+ require_paths:
165
+ - lib
166
+ required_ruby_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ required_rubygems_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ requirements: []
177
+ rubyforge_project:
178
+ rubygems_version: 2.2.2
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: Generate simple index.html from list of files
182
+ test_files:
183
+ - spec/fixtures/demo1.xxx.java
184
+ - spec/fixtures/demo1.xxx.rb
185
+ - spec/fixtures/demo2.xxx.java
186
+ - spec/fixtures/demo2.xxx.rb
187
+ - spec/fixtures/sub-dir/demo3.yyy.java
188
+ - spec/fixtures/sub-dir/demo3.yyy.rb
189
+ - spec/fixtures/sub-dir/demo4.yyy.java
190
+ - spec/fixtures/sub-dir/demo4.yyy.rb
191
+ - spec/index_html/index_html_spec.rb
192
+ - spec/spec_helper.rb
193
+ has_rdoc: