string_master 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a82692a09cefda620a2fc88697bcbc7382abfc33
4
- data.tar.gz: 3541faa9f5b5c657d618722af5e8c646873d4857
3
+ metadata.gz: a6eb20322a22a9deea5805d592055c2665125861
4
+ data.tar.gz: 8155230d47972e417a0493f88f0af7a07bfc9d3f
5
5
  SHA512:
6
- metadata.gz: 7fa14aa940a227d4aa6cb89895bf761a5ed89f0b6fd403ea8f7e48900bde7f60737ec0550969854ade40585eb5b34fda10efc8315546d6e03ca1d819c72bcf54
7
- data.tar.gz: e563f83012a7ef46869f565dd17d8165f78e265ba6145ac042800396405bc7c5086c5c6ef0d52d69bdd10a49e1b7157b0679bb8dc7983840d123f67446197d87
6
+ metadata.gz: c040bc7898f29bfa65e9a16ec0dd92846e0b772de01a2ac06f12ad3a3c3991c260c32c2f5cadd4341509bca40737631f7ae79d76c70da0e06763300107588e03
7
+ data.tar.gz: 68222ac8ebc89779e6ed45d4f87eb34e79e359a1d1ce27201d2e4aeeefe387fbcf7385ccd28c24b4c7c4b8ae959ba6e9124cb9e0a9ed1ca940778f66e54bcb36
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.10
1
+ 0.3.11
@@ -51,8 +51,8 @@ class StringMaster
51
51
  wrap_with = options[:wrap_with] || ['','']
52
52
  html_options = options[:html_options] || ''
53
53
  @modified_string.gsub!(
54
- /(\s|^|\A|\n|\t|\r)(http:\/\/.*?\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF))([,.])?(\s|$|\n|\Z|\t|\r)/,
55
- "#{wrap_with[0]}<img src=\"\\2\" alt=\"\" #{html_options}/>\\5#{wrap_with[1]}"
54
+ /(\s|^|\A|\n|\t|\r)((http|https):\/\/.*?\.(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF))([,.])?(\s|$|\n|\Z|\t|\r)/,
55
+ "#{wrap_with[0]}<img src=\"\\2\" alt=\"\" #{html_options}/>\\6#{wrap_with[1]}"
56
56
  )
57
57
  self
58
58
  end
@@ -64,8 +64,8 @@ class StringMaster
64
64
  wrap_with = options[:wrap_with] || ['','']
65
65
  html_options = options[:html_options] || ''
66
66
  @modified_string.gsub!(
67
- /(\s|^|\A|\n|\t|\r)(http:\/\/.*?)([,.])?(\s|$|\n|\Z|\t|\r|<)/,
68
- '\1<a href="\2" ' + html_options + '>\2</a>\3\4'
67
+ /(\s|^|\A|\n|\t|\r)((http|https):\/\/.*?)([,.])?(\s|$|\n|\Z|\t|\r|<)/,
68
+ '\1<a href="\2" ' + html_options + '>\2</a>\4\5'
69
69
  )
70
70
  self
71
71
  end
@@ -14,12 +14,19 @@ describe StringMaster do
14
14
  parser.html_escape(:except => %w(b)).to_s.should == '&lt;i&gt;hello&lt;/i&gt; <b>world</b>'
15
15
  parser = StringMaster.new('<a href="http://google.com">hello</a> <b>world</b>')
16
16
  parser.html_escape(:except => %w(a)).to_s.should == '<a href="http://google.com">hello</a> &lt;b&gt;world&lt;/b&gt;'
17
+ parser = StringMaster.new('<a href="https://google.com">hello</a> <b>world</b>')
18
+ parser.html_escape(:except => %w(a)).to_s.should == '<a href="https://google.com">hello</a> &lt;b&gt;world&lt;/b&gt;'
17
19
  end
18
20
 
19
21
  it "makes images of urls that end with .jpg and other image extensions" do
20
22
  parser = StringMaster.new('Hello, this is my photo http://image.com/image.jpg, yeah baby')
21
23
  parser.urls_to_images(:wrap_with => ['<p>', '</p>'], :html_options => 'class="ico"').string.should ==
22
24
  'Hello, this is my photo<p><img src="http://image.com/image.jpg" alt="" class="ico"/> </p>yeah baby'
25
+
26
+ # use https
27
+ parser = StringMaster.new('Hello, this is my photo https://image.com/image.jpg, yeah baby')
28
+ parser.urls_to_images(:wrap_with => ['<p>', '</p>'], :html_options => 'class="ico"').string.should ==
29
+ 'Hello, this is my photo<p><img src="https://image.com/image.jpg" alt="" class="ico"/> </p>yeah baby'
23
30
  end
24
31
 
25
32
  it "makes links of urls" do
@@ -36,6 +43,10 @@ describe StringMaster do
36
43
  # example 3
37
44
  parser = StringMaster.new('http://gyazo.com/a4c16e7a6009f40f29248ad4fed41bd3.png<br>')
38
45
  parser.urls_to_links.string.should == '<a href="http://gyazo.com/a4c16e7a6009f40f29248ad4fed41bd3.png" >http://gyazo.com/a4c16e7a6009f40f29248ad4fed41bd3.png</a><br>'
46
+
47
+ # example 4, with https
48
+ parser = StringMaster.new('https://gyazo.com/a4c16e7a6009f40f29248ad4fed41bd3.png<br>')
49
+ parser.urls_to_links.string.should == '<a href="https://gyazo.com/a4c16e7a6009f40f29248ad4fed41bd3.png" >https://gyazo.com/a4c16e7a6009f40f29248ad4fed41bd3.png</a><br>'
39
50
  end
40
51
 
41
52
  it "wraps code in <code> tags" do
@@ -113,6 +124,12 @@ WRAPPED_CODE
113
124
  end
114
125
  parser.string.should ==
115
126
  "<img src=\"http://images.com/image.jpg\" alt=\"\" /> <b>Hello <a href=\"http://url.com\" target=\"_blank\">http://url.com</a> </b>"
127
+
128
+ parser = StringMaster.new('https://images.com/image.jpg <b>Hello https://url.com </b>') do |p|
129
+ p.urls_to_images.urls_to_links(:html_options => 'target="_blank"')
130
+ end
131
+ parser.string.should ==
132
+ "<img src=\"https://images.com/image.jpg\" alt=\"\" /> <b>Hello <a href=\"https://url.com\" target=\"_blank\">https://url.com</a> </b>"
116
133
  end
117
134
 
118
135
  it "replaces newline characters with <br/> tags" do
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: string_master 0.3.10 ruby lib
5
+ # stub: string_master 0.3.11 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "string_master"
9
- s.version = "0.3.10"
9
+ s.version = "0.3.11"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Roman Snitko"]
14
- s.date = "2015-08-13"
14
+ s.date = "2015-08-18"
15
15
  s.description = "Because every time I create a new webapp, I think about how I should process user-generated content. Should convert urls to links and images? Should I allow certain tags? Should I convert all new lines to *br* tags? Well, now all that is as simple as calling a single method."
16
16
  s.email = "roman.snitko@gmail.com"
17
17
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Snitko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-13 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack