ubbparser 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/ubbparser.rb +11 -7
  3. metadata +7 -8
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTRmMmJhM2U0ZDdhZDZjNDExM2JiODkxNTg2NTVmYWRkZTQzZDVkZg==
5
+ data.tar.gz: !binary |-
6
+ YzJmZmZiNjAxNTYzMGNiNDY5ZDc5OTg5NzNiMWE1ZmM4YzU3MmQ5NA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODhjZWUyMjE0OGIyOTA5Nzk0NTgwZDliZmY5ZTJiOGVlZDNiZWU2MjVjM2U0
10
+ MGI1MGEwOWY3MDJkMjk3N2ExZjlkNzUwMGM5MTk1YTBhNWExZmViNjAxNmQ5
11
+ NDZiMzFhZGU1NjhlZmU3MGY0YmVlNDhkODYzZWQ0M2YwNjI3MGM=
12
+ data.tar.gz: !binary |-
13
+ ODBhY2U4MjE3YjJmZjRiM2NmZDE0OGM1MmI3MTZjMmMyYWQ1ZTY2ZGU4NDhj
14
+ MTY3ZDY1NzY0ODZjNjlmYjY2YTAzMThhMjZmYzI3ZGUzYzM0YjI4OWViMTUx
15
+ NDA5YjFhOTJlZTIwMGYwMWJiNWI3OTllNzM1NGMwY2UzMDQxYmU=
data/lib/ubbparser.rb CHANGED
@@ -199,11 +199,15 @@ module UBBParser
199
199
  # :category: Render methods
200
200
  def self.render_csv(inner_text, attributes = {}, parse_options = {})
201
201
  head_cells = body_cells = ""
202
- cell_tag = (attributes[:has_header] || true) ? "th" : "td"
203
- lines = inner_text.split(/\n/)
204
- csv_pattern = /(\"[^\"]*\"|\'[^\']*\'|[^\n\r,]+)[,\n]?/
202
+ cell_tag = (attributes[:has_header] || false) ? "th" : "td"
203
+ lines = inner_text.gsub(/(^\n|\n*$)/, '').split(/\n/)
204
+ sep_char = (attributes[:sepchar] || ',')
205
+ csv_pattern = /(\"[^\"]*\"|\'[^\']*\'|[^\n\r#{sep_char}]+)[#{sep_char}\n]?/
205
206
  lines.each { | line |
206
- cells = attrib_str.scan(csv_pattern) { | item | "<#{cell_tag}>#{item}</#{cell_tag}>" }
207
+ cells = ""
208
+ line.scan(csv_pattern) { | item |
209
+ cells += "<#{cell_tag}>#{item[0]}</#{cell_tag}>"
210
+ }
207
211
  cells = "<tr>#{cells}</tr>"
208
212
  if (cell_tag == "th")
209
213
  head_cells += cells
@@ -215,9 +219,9 @@ module UBBParser
215
219
  result = ""
216
220
  if (!head_cells.empty? || !body_cells.empty?)
217
221
  result = "<table class='#{parse_options[:class_csv].to_s.strip}'>"
218
- result += "<thead>#{head_cells}</thead>" if (!head_cells.empty?)
222
+ result += "<thead>#{head_cells}</thead>" unless head_cells.empty?
219
223
  result += "<tbody>#{body_cells}</tbody>"
220
- result = "</table>"
224
+ result += "</table>"
221
225
  end
222
226
  return result
223
227
  end
@@ -420,7 +424,7 @@ module UBBParser
420
424
  url = (attributes[:default] || inner_text)
421
425
  url = "http://" + url if (url.match(/^www\./))
422
426
  url = @@file_url_convert_method.call(url) unless @@file_url_convert_method.nil?
423
- url.gsub!(/\\|'/) { |c| "\\#{c}" }
427
+ url.to_s.gsub!(/\\|'/) { |c| "\\#{c}" }
424
428
  return "<a href='#{url}' class='#{parse_options[:class_url].to_s.strip}'>#{inner_text}</a>"
425
429
  end
426
430
 
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ubbparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Taco Jan Osinga
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-04 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A simple and flexibel ubb parser.
15
14
  email: info@osingasoftware.nl
@@ -19,27 +18,27 @@ extra_rdoc_files: []
19
18
  files:
20
19
  - lib/ubbparser.rb
21
20
  homepage: https://github.com/tjosinga/UBBParser
22
- licenses: []
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
23
24
  post_install_message:
24
25
  rdoc_options: []
25
26
  require_paths:
26
27
  - lib
27
28
  required_ruby_version: !ruby/object:Gem::Requirement
28
- none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0'
33
33
  required_rubygems_version: !ruby/object:Gem::Requirement
34
- none: false
35
34
  requirements:
36
35
  - - ! '>='
37
36
  - !ruby/object:Gem::Version
38
37
  version: '0'
39
38
  requirements: []
40
39
  rubyforge_project:
41
- rubygems_version: 1.8.25
40
+ rubygems_version: 2.0.7
42
41
  signing_key:
43
- specification_version: 3
42
+ specification_version: 4
44
43
  summary: UBB Parser
45
44
  test_files: []