index_html 0.2.2 → 0.2.3

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: a7b776cb63b00982e749761e9d52b4aed324408d
4
+ data.tar.gz: 31aa65091d74f4135ad13dcdf1023eb933a526a4
5
+ SHA512:
6
+ metadata.gz: 0092576780534fb541ce155c54fc05e32a19a9b43b0be1ab4d09d9480f232b4af4e139c02cbd58c19356d090547f8a4dacca3b86616843587ef103ed8b85b66c
7
+ data.tar.gz: cbc246c08491b6d7d1a44d7e982daa815edad89cfb4c96376e228311b6ed39c5f29ef91aa95927da012802af31349a59e3e443cec37b3169b4d265a100c4f725
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ### Changelogs
2
2
 
3
+ #### 0.2.3
4
+
5
+ - Make it possible to remove the last extension from the link for `vim_printer`
6
+ - Update some gem dependency to the most recent version
7
+
3
8
  #### 0.2.2
4
9
 
5
10
  - Lower required ruby version to 1.9.3+
data/index_html.gemspec CHANGED
@@ -30,12 +30,13 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency "thor", "~> 0.19.1"
31
31
 
32
32
  spec.add_development_dependency "awesome_print", "~> 1.2.0"
33
- spec.add_development_dependency "bundler", "~> 1.7.0"
33
+ spec.add_development_dependency "bundler", "~> 1.7.3"
34
34
  spec.add_development_dependency "coveralls", "~> 0.7.0"
35
35
  spec.add_development_dependency "fuubar", "~> 2.0.0"
36
36
  spec.add_development_dependency "guard-rspec", "~> 4.3.1"
37
37
  spec.add_development_dependency "pry", "~> 0.10.0"
38
+ spec.add_development_dependency "pry-byebug", "~> 2.0.0" if RUBY_VERSION >= "2.0.0"
38
39
  spec.add_development_dependency "rake", "~> 10.3.2"
39
40
  spec.add_development_dependency "rspec", "~> 3.0.0"
40
- spec.add_development_dependency "rubocop", "~> 0.24.1"
41
+ spec.add_development_dependency "rubocop", "~> 0.26.1"
41
42
  end
@@ -1,3 +1,3 @@
1
1
  module IndexHtml
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
data/lib/index_html.rb CHANGED
@@ -5,7 +5,10 @@ require_relative "./index_html/cli"
5
5
  module IndexHtml
6
6
  CustomError = Class.new(StandardError)
7
7
  class << self
8
- # Create html links to list of files
8
+ # Create html links for a given list of files
9
+ #
10
+ # @param [Array<String>] file_list list of input file
11
+ # @param [Hash<Synbol, Object>] args the argument hash
9
12
  def htmlify(file_list, args = {})
10
13
  header = <<-END.gsub(/^\s+\|/, "")
11
14
  |<html>
@@ -21,15 +24,16 @@ module IndexHtml
21
24
  |</html>
22
25
  END
23
26
 
24
- prefix = args.fetch(:prefix, ".")
25
27
  indent = args.fetch(:indent, 6)
26
28
  output = args.fetch(:output, "index.html")
27
29
 
28
- File.open(output, "w") do |f|
29
- f.write(header)
30
- links = make_links file_list, prefix: prefix, base_dir: args[:base_dir]
31
- links.each { |i| f.write("#{" " * indent}#{i}\n") }
32
- f.write(footer)
30
+ File.open(output, "w") do |file|
31
+ file.write(header)
32
+ links = make_links file_list, prefix: args.fetch(:prefix, ".") ,
33
+ base_dir: args[:base_dir],
34
+ drop_ext: args.fetch(:drop_ext, false)
35
+ links.each { |link| file.write("#{" " * indent}#{link}\n") }
36
+ file.write(footer)
33
37
  end
34
38
  end
35
39
 
@@ -58,19 +62,55 @@ module IndexHtml
58
62
  #
59
63
  # @return [Array<String>] the list of valid <li> tags
60
64
  def make_links(file_list, args)
61
- prefix = args.fetch(:prefix, ".")
65
+ prefix = args.fetch(:prefix, ".")
66
+ drop_ext = args.fetch(:drop_ext, false)
62
67
  result = []
63
-
64
- file_list.each do |i|
65
- path = File.absolute_path(i).gsub(Dir.pwd, "")
68
+ file_list.each do |file|
69
+ path = File.absolute_path(file).gsub(Dir.pwd, "")
66
70
  if prefix
67
- link = %Q(<li><a href="#{prefix}#{path}" target='_blank'>#{prefix}#{path}</li>)
71
+ # link = %Q(<li><a href="#{prefix}#{drop_ext ? drop_extension(path): path}" target='_blank'>#{prefix}#{path}</li>)
72
+ link = %Q(<li><a href="#{prefix}#{path}" target='_blank'>#{prefix}#{drop_last_ext(path, drop_ext)}</li>)
68
73
  else
69
- link = %Q(<li><a href=".#{path}" target='_blank'>#{path.gsub(/^\//, "")}</li>)
74
+ # add "." in front of the link and drop the last extension
75
+ # link = %Q(<li><a href=".#{drop_ext ? drop_extension(path) : path}" target='_blank'>#{path.gsub(/^\//, "")}</li>)
76
+ # at this point path always start with "/"
77
+ link = %Q(<li><a href=".#{path}" target='_blank'>#{drop_last_ext(path.gsub(/^\//, ""), drop_ext)}</li>)
70
78
  end
71
79
  result << link
72
80
  end
73
81
  result
74
82
  end
83
+
84
+ # Wrapper method to call the drop_extension if applicable
85
+ #
86
+ # @param [String] link the input link
87
+ # @param [Boolean] flag the boolean flag
88
+ # @return (see #drop_extension)
89
+ def drop_last_ext(link, flag = false)
90
+ if flag
91
+ drop_extension(link)
92
+ else
93
+ link
94
+ end
95
+ end
96
+
97
+ # Drop string after the last '.' dot string if any
98
+ #
99
+ # @param [String] link the input link
100
+ # @return [String] the new string with extension drop if any
101
+ # @example
102
+ # drop_extension("some_file") == "some_file"
103
+ # drop_extension("some_file.txt") == "some_file"
104
+ # drop_extension("/path/to/some_file") == "/path/to/some_file"
105
+ # drop_extension("/path/to/some_file.txt") == "/path/to/some_file"
106
+ # drop_extension("/path/to/some_file.txt.pdf") == "/path/to/some_file.txt"
107
+ def drop_extension(link)
108
+ dot_index = link.rindex(".")
109
+ if dot_index
110
+ link[0..(dot_index - 1)]
111
+ else
112
+ link
113
+ end
114
+ end
75
115
  end
76
116
  end
metadata CHANGED
@@ -1,208 +1,197 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: index_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Burin Choomnuan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2014-09-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: agile_utils
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.2.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.2.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: code_lister
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.2.2
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.2.2
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: thor
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.19.1
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.19.1
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: awesome_print
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: 1.2.0
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: 1.2.0
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: bundler
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
- version: 1.7.0
75
+ version: 1.7.3
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
- version: 1.7.0
82
+ version: 1.7.3
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: coveralls
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ~>
87
+ - - "~>"
100
88
  - !ruby/object:Gem::Version
101
89
  version: 0.7.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ~>
94
+ - - "~>"
108
95
  - !ruby/object:Gem::Version
109
96
  version: 0.7.0
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: fuubar
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
103
  version: 2.0.0
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - "~>"
124
109
  - !ruby/object:Gem::Version
125
110
  version: 2.0.0
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: guard-rspec
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ~>
115
+ - - "~>"
132
116
  - !ruby/object:Gem::Version
133
117
  version: 4.3.1
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ~>
122
+ - - "~>"
140
123
  - !ruby/object:Gem::Version
141
124
  version: 4.3.1
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: pry
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ~>
129
+ - - "~>"
148
130
  - !ruby/object:Gem::Version
149
131
  version: 0.10.0
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ~>
136
+ - - "~>"
156
137
  - !ruby/object:Gem::Version
157
138
  version: 0.10.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-byebug
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.0.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.0.0
158
153
  - !ruby/object:Gem::Dependency
159
154
  name: rake
160
155
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
156
  requirements:
163
- - - ~>
157
+ - - "~>"
164
158
  - !ruby/object:Gem::Version
165
159
  version: 10.3.2
166
160
  type: :development
167
161
  prerelease: false
168
162
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
163
  requirements:
171
- - - ~>
164
+ - - "~>"
172
165
  - !ruby/object:Gem::Version
173
166
  version: 10.3.2
174
167
  - !ruby/object:Gem::Dependency
175
168
  name: rspec
176
169
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
170
  requirements:
179
- - - ~>
171
+ - - "~>"
180
172
  - !ruby/object:Gem::Version
181
173
  version: 3.0.0
182
174
  type: :development
183
175
  prerelease: false
184
176
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
177
  requirements:
187
- - - ~>
178
+ - - "~>"
188
179
  - !ruby/object:Gem::Version
189
180
  version: 3.0.0
190
181
  - !ruby/object:Gem::Dependency
191
182
  name: rubocop
192
183
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
184
  requirements:
195
- - - ~>
185
+ - - "~>"
196
186
  - !ruby/object:Gem::Version
197
- version: 0.24.1
187
+ version: 0.26.1
198
188
  type: :development
199
189
  prerelease: false
200
190
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
191
  requirements:
203
- - - ~>
192
+ - - "~>"
204
193
  - !ruby/object:Gem::Version
205
- version: 0.24.1
194
+ version: 0.26.1
206
195
  description: Generate the index.html from list of files
207
196
  email:
208
197
  - agilecreativity@gmail.com
@@ -211,42 +200,41 @@ executables:
211
200
  extensions: []
212
201
  extra_rdoc_files: []
213
202
  files:
214
- - bin/index_html
215
- - lib/index_html/cli.rb
216
- - lib/index_html/version.rb
217
- - lib/index_html.rb
203
+ - ".gitignore"
204
+ - ".rubocop.yml"
205
+ - CHANGELOG.md
218
206
  - Gemfile
207
+ - LICENSE
208
+ - README.md
219
209
  - Rakefile
210
+ - bin/index_html
220
211
  - index_html.gemspec
221
- - README.md
222
- - CHANGELOG.md
223
- - LICENSE
224
- - .rubocop.yml
225
- - .gitignore
212
+ - lib/index_html.rb
213
+ - lib/index_html/cli.rb
214
+ - lib/index_html/version.rb
226
215
  homepage: https://github.com/agilecreativity/index_html
227
216
  licenses:
228
217
  - MIT
218
+ metadata: {}
229
219
  post_install_message:
230
220
  rdoc_options: []
231
221
  require_paths:
232
222
  - lib
233
223
  required_ruby_version: !ruby/object:Gem::Requirement
234
- none: false
235
224
  requirements:
236
- - - ! '>='
225
+ - - ">="
237
226
  - !ruby/object:Gem::Version
238
227
  version: 1.9.3
239
228
  required_rubygems_version: !ruby/object:Gem::Requirement
240
- none: false
241
229
  requirements:
242
- - - ! '>='
230
+ - - ">="
243
231
  - !ruby/object:Gem::Version
244
232
  version: '0'
245
233
  requirements: []
246
234
  rubyforge_project:
247
- rubygems_version: 1.8.23.2
235
+ rubygems_version: 2.2.2
248
236
  signing_key:
249
- specification_version: 3
237
+ specification_version: 4
250
238
  summary: Generate simple index.html from list of files based on your simple selection
251
239
  criteria
252
240
  test_files: []