index_html 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/README.md +25 -18
- data/lib/index_html/cli.rb +1 -1
- data/lib/index_html/main.rb +1 -0
- data/lib/index_html/version.rb +1 -1
- data/lib/index_html.rb +13 -19
- data/spec/index_html/index_html_spec.rb +46 -23
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b45984b36cf42d542ec7d1b4bb2eab064402ddce
|
4
|
+
data.tar.gz: 0a0488a4927fb09a53347b5bd08dca7950f03e43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adf048c23932143d768bf64ca1ad1b4391c0088c227d12ea3d4ea63f30efc4f35ba47658fde588bb8de46b679be432a3985b31023c50f2620e7235e8d895df9a
|
7
|
+
data.tar.gz: 400502befa090eb221d227dcaca0e52f80043a747a640d771429e3f55d5bcec057afd9e75c5437c5176b711dbe1f02f923233e7f82db20bffca5752c13269c33
|
data/README.md
CHANGED
@@ -70,7 +70,7 @@ This will generate the file `index.html` that you can open from your favourite b
|
|
70
70
|
- Sample list of files from a given directory
|
71
71
|
|
72
72
|
```shell
|
73
|
-
$
|
73
|
+
$index_html generate --base-dir=spec/fixtures --exts=rb java --recursive
|
74
74
|
```
|
75
75
|
The output file `index.html` should be generated with something like
|
76
76
|
|
@@ -80,14 +80,14 @@ The output file `index.html` should be generated with something like
|
|
80
80
|
<header>File List</header>
|
81
81
|
<body>
|
82
82
|
<ol>
|
83
|
-
<li><a href="demo1.xxx.java" target="_blank"
|
84
|
-
<li><a href="demo1.xxx.rb" target="_blank"
|
85
|
-
<li><a href="demo2.xxx.java" target="_blank"
|
86
|
-
<li><a href="demo2.xxx.rb" target="_blank"
|
87
|
-
<li><a href="sub-dir/demo3.yyy.java" target="_blank"
|
88
|
-
<li><a href="sub-dir/demo3.yyy.rb" target="_blank"
|
89
|
-
<li><a href="sub-dir/demo4.yyy.java" target="_blank"
|
90
|
-
<li><a href="sub-dir/demo4.yyy.rb" target="_blank"
|
83
|
+
<li><a href="./spec/fixtures/demo1.xxx.java" target="_blank">./spec/fixtures/demo1.xxx.java</li>
|
84
|
+
<li><a href="./spec/fixtures/demo1.xxx.rb" target="_blank">./spec/fixtures/demo1.xxx.rb</li>
|
85
|
+
<li><a href="./spec/fixtures/demo2.xxx.java" target="_blank">./spec/fixtures/demo2.xxx.java</li>
|
86
|
+
<li><a href="./spec/fixtures/demo2.xxx.rb" target="_blank">./spec/fixtures/demo2.xxx.rb</li>
|
87
|
+
<li><a href="./spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">./spec/fixtures/sub-dir/demo3.yyy.java</li>
|
88
|
+
<li><a href="./spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">./spec/fixtures/sub-dir/demo3.yyy.rb</li>
|
89
|
+
<li><a href="./spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">./spec/fixtures/sub-dir/demo4.yyy.java</li>
|
90
|
+
<li><a href="./spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">./spec/fixtures/sub-dir/demo4.yyy.rb</li>
|
91
91
|
</ol>
|
92
92
|
</body>
|
93
93
|
</html>
|
@@ -95,7 +95,7 @@ The output file `index.html` should be generated with something like
|
|
95
95
|
- Run with simple prefix option
|
96
96
|
|
97
97
|
```shell
|
98
|
-
|
98
|
+
index_html generate --base-dir spec/fixtures --exts rb java --recursive --prefix http://localhost/
|
99
99
|
```
|
100
100
|
|
101
101
|
The output file `index.html` should be something like
|
@@ -106,21 +106,28 @@ The output file `index.html` should be something like
|
|
106
106
|
<header>File List</header>
|
107
107
|
<body>
|
108
108
|
<ol>
|
109
|
-
<li><a href="http://localhost/demo1.xxx.java" target="_blank">http://localhost/demo1.xxx.java</li>
|
110
|
-
<li><a href="http://localhost/demo1.xxx.rb" target="_blank">http://localhost/demo1.xxx.rb</li>
|
111
|
-
<li><a href="http://localhost/demo2.xxx.java" target="_blank">http://localhost/demo2.xxx.java</li>
|
112
|
-
<li><a href="http://localhost/demo2.xxx.rb" target="_blank"http://localhost
|
113
|
-
<li><a href="http://localhost/sub-dir/demo3.yyy.java" target="_blank">http://localhost/sub-dir/demo3.yyy.java</li>
|
114
|
-
<li><a href="http://localhost/sub-dir/demo3.yyy.rb" target="_blank">http://localhost/sub-dir/demo3.yyy.rb</li>
|
115
|
-
<li><a href="http://localhost/sub-dir/demo4.yyy.java" target="_blank">http://localhost/sub-dir/demo4.yyy.java</li>
|
116
|
-
<li><a href="http://localhost/sub-dir/demo4.yyy.rb" target="_blank">http://localhost/sub-dir/demo4.yyy.rb</li>
|
109
|
+
<li><a href="http://localhost//spec/fixtures/demo1.xxx.java" target="_blank">http://localhost//spec/fixtures/demo1.xxx.java</li>
|
110
|
+
<li><a href="http://localhost//spec/fixtures/demo1.xxx.rb" target="_blank">http://localhost//spec/fixtures/demo1.xxx.rb</li>
|
111
|
+
<li><a href="http://localhost//spec/fixtures/demo2.xxx.java" target="_blank">http://localhost//spec/fixtures/demo2.xxx.java</li>
|
112
|
+
<li><a href="http://localhost//spec/fixtures/demo2.xxx.rb" target="_blank">http://localhost//spec/fixtures/demo2.xxx.rb</li>
|
113
|
+
<li><a href="http://localhost//spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">http://localhost//spec/fixtures/sub-dir/demo3.yyy.java</li>
|
114
|
+
<li><a href="http://localhost//spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">http://localhost//spec/fixtures/sub-dir/demo3.yyy.rb</li>
|
115
|
+
<li><a href="http://localhost//spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">http://localhost//spec/fixtures/sub-dir/demo4.yyy.java</li>
|
116
|
+
<li><a href="http://localhost//spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">http://localhost//spec/fixtures/sub-dir/demo4.yyy.rb</li>
|
117
117
|
</ol>
|
118
118
|
</body>
|
119
119
|
</html>
|
120
120
|
```
|
121
|
+
### Known Issues
|
122
|
+
|
123
|
+
- Will be listed here if any
|
121
124
|
|
122
125
|
### Changelogs
|
123
126
|
|
127
|
+
#### 0.0.7
|
128
|
+
|
129
|
+
- Fix the bug in 'make_links' logic to make it generate the link properly
|
130
|
+
|
124
131
|
#### 0.0.6
|
125
132
|
|
126
133
|
- Fix the Rakefile to include the correct library
|
data/lib/index_html/cli.rb
CHANGED
data/lib/index_html/main.rb
CHANGED
data/lib/index_html/version.rb
CHANGED
data/lib/index_html.rb
CHANGED
@@ -29,7 +29,7 @@ module IndexHtml
|
|
29
29
|
|</html>
|
30
30
|
END
|
31
31
|
|
32
|
-
prefix = args.fetch(:prefix, "")
|
32
|
+
prefix = args.fetch(:prefix, ".")
|
33
33
|
indent = args.fetch(:indent, 6)
|
34
34
|
output = args.fetch(:output, "index.html")
|
35
35
|
|
@@ -67,28 +67,22 @@ module IndexHtml
|
|
67
67
|
# @return [Array<String>] the list of valid <li> tags
|
68
68
|
def make_links(file_list, args)
|
69
69
|
|
70
|
-
|
70
|
+
prefix = args.fetch(:prefix, ".")
|
71
|
+
base_dir = args[:base_dir]
|
72
|
+
result = []
|
71
73
|
|
72
|
-
|
73
|
-
# escape_uris!(file_list, args)
|
74
|
-
# file_list = basenames!(file_list, args)
|
74
|
+
file_list.each do |i|
|
75
75
|
|
76
|
-
|
77
|
-
base_dir = args[:base_dir]
|
76
|
+
path = File.absolute_path(i).gsub(Dir.pwd, "")
|
78
77
|
|
79
|
-
|
78
|
+
if prefix
|
79
|
+
link = %Q{<li><a href="#{prefix}#{path}" target="_blank">#{prefix}#{path}</li>}
|
80
|
+
else
|
81
|
+
#TODO: may be we never get this condition?
|
82
|
+
link = %Q{<li><a href=".#{path}" target="_blank">#{path.gsub(/^\//,"")}</li>}
|
83
|
+
end
|
80
84
|
|
81
|
-
|
82
|
-
# original_links.zip(file_list).each do |i,j|
|
83
|
-
# uri = j.gsub(base_dir,"")
|
84
|
-
# target = i.gsub(base_dir,"")
|
85
|
-
# result << %Q{<li><a href="#{prefix}#{uri}" target="_blank">#{target}</li>}
|
86
|
-
# end
|
87
|
-
|
88
|
-
original_links.each do |i|
|
89
|
-
uri = i.gsub(base_dir,"")
|
90
|
-
uri.gsub!(/^\//,"") # remove the '/' if we have one
|
91
|
-
result << %Q{<li><a href="#{prefix}#{uri}" target="_blank">#{prefix}#{uri}</li>}
|
85
|
+
result << link
|
92
86
|
end
|
93
87
|
|
94
88
|
result
|
@@ -49,14 +49,14 @@ describe IndexHtml do
|
|
49
49
|
<header>File List</header>
|
50
50
|
<body>
|
51
51
|
<ol>
|
52
|
-
<li><a href="demo1.xxx.java" target="_blank"
|
53
|
-
<li><a href="demo1.xxx.rb" target="_blank"
|
54
|
-
<li><a href="demo2.xxx.java" target="_blank"
|
55
|
-
<li><a href="demo2.xxx.rb" target="_blank"
|
56
|
-
<li><a href="sub-dir/demo3.yyy.java" target="_blank"
|
57
|
-
<li><a href="sub-dir/demo3.yyy.rb" target="_blank"
|
58
|
-
<li><a href="sub-dir/demo4.yyy.java" target="_blank"
|
59
|
-
<li><a href="sub-dir/demo4.yyy.rb" target="_blank"
|
52
|
+
<li><a href="./spec/fixtures/demo1.xxx.java" target="_blank">./spec/fixtures/demo1.xxx.java</li>
|
53
|
+
<li><a href="./spec/fixtures/demo1.xxx.rb" target="_blank">./spec/fixtures/demo1.xxx.rb</li>
|
54
|
+
<li><a href="./spec/fixtures/demo2.xxx.java" target="_blank">./spec/fixtures/demo2.xxx.java</li>
|
55
|
+
<li><a href="./spec/fixtures/demo2.xxx.rb" target="_blank">./spec/fixtures/demo2.xxx.rb</li>
|
56
|
+
<li><a href="./spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">./spec/fixtures/sub-dir/demo3.yyy.java</li>
|
57
|
+
<li><a href="./spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">./spec/fixtures/sub-dir/demo3.yyy.rb</li>
|
58
|
+
<li><a href="./spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">./spec/fixtures/sub-dir/demo4.yyy.java</li>
|
59
|
+
<li><a href="./spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">./spec/fixtures/sub-dir/demo4.yyy.rb</li>
|
60
60
|
</ol>
|
61
61
|
</body>
|
62
62
|
</html>
|
@@ -68,7 +68,7 @@ describe IndexHtml do
|
|
68
68
|
IndexHtml.htmlify files,
|
69
69
|
indent: 6,
|
70
70
|
output: 'index.html',
|
71
|
-
prefix: 'http://agilecreativity.com/public
|
71
|
+
prefix: 'http://agilecreativity.com/public',
|
72
72
|
base_dir: 'spec/fixtures' # Note: must not puts the '/' at the end!
|
73
73
|
expect(capture(:stdout) { system('cat index.html') }).to eq \
|
74
74
|
<<-EOT
|
@@ -77,14 +77,14 @@ describe IndexHtml do
|
|
77
77
|
<header>File List</header>
|
78
78
|
<body>
|
79
79
|
<ol>
|
80
|
-
<li><a href="http://agilecreativity.com/public/demo1.xxx.java" target="_blank">http://agilecreativity.com/public/demo1.xxx.java</li>
|
81
|
-
<li><a href="http://agilecreativity.com/public/demo1.xxx.rb" target="_blank">http://agilecreativity.com/public/demo1.xxx.rb</li>
|
82
|
-
<li><a href="http://agilecreativity.com/public/demo2.xxx.java" target="_blank">http://agilecreativity.com/public/demo2.xxx.java</li>
|
83
|
-
<li><a href="http://agilecreativity.com/public/demo2.xxx.rb" target="_blank">http://agilecreativity.com/public/demo2.xxx.rb</li>
|
84
|
-
<li><a href="http://agilecreativity.com/public/sub-dir/demo3.yyy.java" target="_blank">http://agilecreativity.com/public/sub-dir/demo3.yyy.java</li>
|
85
|
-
<li><a href="http://agilecreativity.com/public/sub-dir/demo3.yyy.rb" target="_blank">http://agilecreativity.com/public/sub-dir/demo3.yyy.rb</li>
|
86
|
-
<li><a href="http://agilecreativity.com/public/sub-dir/demo4.yyy.java" target="_blank">http://agilecreativity.com/public/sub-dir/demo4.yyy.java</li>
|
87
|
-
<li><a href="http://agilecreativity.com/public/sub-dir/demo4.yyy.rb" target="_blank">http://agilecreativity.com/public/sub-dir/demo4.yyy.rb</li>
|
80
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/demo1.xxx.java" target="_blank">http://agilecreativity.com/public/spec/fixtures/demo1.xxx.java</li>
|
81
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/demo1.xxx.rb" target="_blank">http://agilecreativity.com/public/spec/fixtures/demo1.xxx.rb</li>
|
82
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/demo2.xxx.java" target="_blank">http://agilecreativity.com/public/spec/fixtures/demo2.xxx.java</li>
|
83
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/demo2.xxx.rb" target="_blank">http://agilecreativity.com/public/spec/fixtures/demo2.xxx.rb</li>
|
84
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/sub-dir/demo3.yyy.java" target="_blank">http://agilecreativity.com/public/spec/fixtures/sub-dir/demo3.yyy.java</li>
|
85
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/sub-dir/demo3.yyy.rb" target="_blank">http://agilecreativity.com/public/spec/fixtures/sub-dir/demo3.yyy.rb</li>
|
86
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/sub-dir/demo4.yyy.java" target="_blank">http://agilecreativity.com/public/spec/fixtures/sub-dir/demo4.yyy.java</li>
|
87
|
+
<li><a href="http://agilecreativity.com/public/spec/fixtures/sub-dir/demo4.yyy.rb" target="_blank">http://agilecreativity.com/public/spec/fixtures/sub-dir/demo4.yyy.rb</li>
|
88
88
|
</ol>
|
89
89
|
</body>
|
90
90
|
</html>
|
@@ -94,21 +94,44 @@ describe IndexHtml do
|
|
94
94
|
|
95
95
|
context '#make_links' do
|
96
96
|
it 'works with prefix' do
|
97
|
-
result = IndexHtml.make_links files, base_dir: "spec/fixtures",
|
98
|
-
prefix: 'public/'
|
97
|
+
result = IndexHtml.make_links files, base_dir: "spec/fixtures", prefix: 'public'
|
99
98
|
expect(capture(:stdout) { puts result }).to eq \
|
100
99
|
<<-EOT
|
101
|
-
<li><a href="public/demo1.xxx.rb" target="_blank">public/demo1.xxx.rb</li>
|
102
|
-
<li><a href="public/demo2.xxx.rb" target="_blank">public/demo2.xxx.rb</li>
|
100
|
+
<li><a href="public/spec/fixtures/demo1.xxx.rb" target="_blank">public/spec/fixtures/demo1.xxx.rb</li>
|
101
|
+
<li><a href="public/spec/fixtures/demo2.xxx.rb" target="_blank">public/spec/fixtures/demo2.xxx.rb</li>
|
103
102
|
EOT
|
104
103
|
end
|
104
|
+
|
105
105
|
it 'works without prefix' do
|
106
106
|
result = IndexHtml.make_links(files, base_dir: "spec/fixtures")
|
107
107
|
expect(capture(:stdout) { puts result }).to eq \
|
108
108
|
<<-EOT
|
109
|
-
<li><a href="demo1.xxx.rb" target="_blank"
|
110
|
-
<li><a href="demo2.xxx.rb" target="_blank"
|
109
|
+
<li><a href="./spec/fixtures/demo1.xxx.rb" target="_blank">./spec/fixtures/demo1.xxx.rb</li>
|
110
|
+
<li><a href="./spec/fixtures/demo2.xxx.rb" target="_blank">./spec/fixtures/demo2.xxx.rb</li>
|
111
|
+
EOT
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'works with base_dir starting with dot' do
|
115
|
+
files = CodeLister.files base_dir: './spec/fixtures',
|
116
|
+
exts: %w(xxx.rb), recursive: true
|
117
|
+
result = IndexHtml.make_links(files, base_dir: "./spec/fixtures/")
|
118
|
+
expect(capture(:stdout) { puts result }).to eq \
|
119
|
+
<<-EOT
|
120
|
+
<li><a href="./spec/fixtures/demo1.xxx.rb" target="_blank">./spec/fixtures/demo1.xxx.rb</li>
|
121
|
+
<li><a href="./spec/fixtures/demo2.xxx.rb" target="_blank">./spec/fixtures/demo2.xxx.rb</li>
|
111
122
|
EOT
|
112
123
|
end
|
124
|
+
|
125
|
+
it 'works with base_dir not starting with dot' do
|
126
|
+
files = CodeLister.files base_dir: 'spec/fixtures',
|
127
|
+
exts: %w(xxx.rb), recursive: true
|
128
|
+
result = IndexHtml.make_links(files, base_dir: "spec/fixtures/")
|
129
|
+
expect(capture(:stdout) { puts result }).to eq \
|
130
|
+
<<-EOT
|
131
|
+
<li><a href="./spec/fixtures/demo1.xxx.rb" target="_blank">./spec/fixtures/demo1.xxx.rb</li>
|
132
|
+
<li><a href="./spec/fixtures/demo2.xxx.rb" target="_blank">./spec/fixtures/demo2.xxx.rb</li>
|
133
|
+
EOT
|
134
|
+
end
|
135
|
+
|
113
136
|
end
|
114
137
|
end
|