smiley 0.1.0 → 0.1.1

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: 2e53eb3600742e6708e0987d6954b862148881b3
4
- data.tar.gz: b8d7c96b8f6f06bd42e27fc2da96fd7f436e2a59
3
+ metadata.gz: 4a3b0ab5e6f21a2564bf57e6fcd7f5c04818b043
4
+ data.tar.gz: 25d8dad4083dc276e89d2620140f1bfbaaef3044
5
5
  SHA512:
6
- metadata.gz: 54597c0a81fc9a507d34c775e95a794915599a6b7c32d0423ed98dd4331809220670a8e60866b72abc28608f02135e358ed29b2696bb6a63d5044111a9193e75
7
- data.tar.gz: 7cb39ed9a5dddb841ec5ed71ee6aaf14feca8ab9036dec878cd6ed9c3a5a4496dfa4a3dd7c7e899a839761cc90261717bca3cb96e0323aa4961be98e85690143
6
+ metadata.gz: f9df090c517b80ce7d02b26d537e17bcc15f1416a3e3bc62ed9deae4eb1da29f528ea78339b6b80a5b75114cfd11e4f2ab2311294085eed42ccffc1d9132e6bc
7
+ data.tar.gz: 2598b3b01fbaa9db3790f79878ea2a0899f911b72fe82be345aef7f2fa3e0642ddd44487986a8ec45ef609268fdfb5af7dec59e9b90072550c8a52c58c0a8ce6
@@ -6,16 +6,16 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.2.1)
10
- rake (10.0.4)
11
- rspec (2.13.0)
12
- rspec-core (~> 2.13.0)
13
- rspec-expectations (~> 2.13.0)
14
- rspec-mocks (~> 2.13.0)
15
- rspec-core (2.13.1)
16
- rspec-expectations (2.13.0)
9
+ diff-lcs (1.2.5)
10
+ rake (10.1.1)
11
+ rspec (2.14.1)
12
+ rspec-core (~> 2.14.0)
13
+ rspec-expectations (~> 2.14.0)
14
+ rspec-mocks (~> 2.14.0)
15
+ rspec-core (2.14.8)
16
+ rspec-expectations (2.14.5)
17
17
  diff-lcs (>= 1.1.3, < 2.0)
18
- rspec-mocks (2.13.0)
18
+ rspec-mocks (2.14.6)
19
19
 
20
20
  PLATFORMS
21
21
  java
@@ -23,5 +23,5 @@ PLATFORMS
23
23
 
24
24
  DEPENDENCIES
25
25
  rake (~> 10.0)
26
- rspec (~> 2.13.0)
26
+ rspec (~> 2.13)
27
27
  smiley!
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- [![Code Climate](https://codeclimate.com/github/iGEL/smiley.png)](https://codeclimate.com/github/iGEL/smiley)
2
- [![Build Status](https://travis-ci.org/iGEL/smiley.png?branch=master)](https://travis-ci.org/iGEL/smiley)
3
- (Tested: Ruby 2.0.0, 1.9.3, 1.9.2, 1.8.7, Rubinius, Jruby)
1
+ [![Code Climate](https://codeclimate.com/github/iGEL/smiley.png)](https://codeclimate.com/github/iGEL/smiley)
2
+ [![Build Status](https://travis-ci.org/iGEL/smiley.png?branch=master)](https://travis-ci.org/iGEL/smiley)
3
+ (Tested: Ruby 2.1.1, 2.0.0, 1.9.3, 1.9.2, Rubinius, Jruby)
4
4
 
5
5
  Smiley
6
6
  ======
@@ -12,7 +12,7 @@ image. This way, you can use [CSS sprites](http://css-tricks.com/css-sprites/) t
12
12
  Usage
13
13
  =====
14
14
 
15
- First, configure the smileys you want to have converted in a yml file. If you use this lib with Ruby on Rails, the
15
+ First, configure the smileys you want to have converted in a yml file. If you use this lib with Ruby on Rails, the
16
16
  default position for this file is in `config/smileys.yml`.
17
17
 
18
18
  ```yml
data/Rakefile CHANGED
@@ -2,4 +2,4 @@ require 'rspec/core/rake_task'
2
2
 
3
3
  RSpec::Core::RakeTask.new(:spec)
4
4
 
5
- task :default => :spec
5
+ task default: :spec
@@ -44,7 +44,7 @@ class Smiley
44
44
 
45
45
  def parse(text)
46
46
  text = h(text).gsub(self.class.regex) do
47
- %(#{$1}<em class="#{css_class(self.class.smileys[$2])}"></em>#{$3})
47
+ %(<em class="#{css_class(self.class.smileys[$1])}"></em>)
48
48
  end
49
49
 
50
50
  text.respond_to?(:html_safe) ? text.html_safe : text
@@ -95,8 +95,11 @@ class Smiley
95
95
  return @@regex if defined?(@@regex)
96
96
 
97
97
  before_and_after = "[.,;:!\\?\\(\\[\\{\\)\\]\\}\\-]|\\s"
98
- @@regex = Regexp.compile("(^|#{before_and_after})(" +
99
- smileys.keys.map { |token| Regexp.escape(token) }.join("|") +
100
- ")($|#{before_and_after})", Regexp::MULTILINE)
98
+ @@regex = Regexp.compile(
99
+ "(?<=^|#{before_and_after})" +
100
+ "(" + smileys.keys.map { |token| Regexp.escape(token) }.join("|") + ")" +
101
+ "(?=$|#{before_and_after})",
102
+ Regexp::MULTILINE
103
+ )
101
104
  end
102
105
  end
@@ -4,7 +4,6 @@ require 'smiley'
4
4
  describe Smiley do
5
5
  subject(:smiley) { described_class.new }
6
6
 
7
-
8
7
  after do
9
8
  described_class.class_eval do
10
9
  remove_class_variable :@@all_class if class_variable_defined?(:@@all_class)
@@ -56,7 +55,7 @@ describe Smiley do
56
55
  it 'return \#{Rails.root}/config/smileys.yml, if Rails.root is defined"' do
57
56
  rails = double('Rails')
58
57
  stub_const('Rails', rails)
59
- rails.stub(:root) { '/home/igel/dev/example.com/' }
58
+ allow(rails).to receive(:root).and_return('/home/igel/dev/example.com/')
60
59
 
61
60
  expect(described_class.smiley_file).to eq('/home/igel/dev/example.com/config/smileys.yml')
62
61
  end
@@ -97,6 +96,10 @@ describe Smiley do
97
96
  expect(smiley.parse("That's so funny! :P Will tell my grandma about that :rolleyes: ")).to eq(%(That's so funny! <em class="smiley smiley-razz"></em> Will tell my grandma about that <em class="smiley smiley-rolleyes"></em> ))
98
97
  end
99
98
 
99
+ it 'works with smileys directly one after the other' do
100
+ expect(smiley.parse("That's so funny! :-) ;-)")).to eq(%(That's so funny! <em class="smiley smiley-smile"></em> <em class="smiley smiley-wink"></em>))
101
+ end
102
+
100
103
  it 'parses smileys at the beginning and end of a string' do
101
104
  expect(smiley.parse(':D So funny! ;-)')).to eq(%(<em class="smiley smiley-grin"></em> So funny! <em class="smiley smiley-wink"></em>))
102
105
  end
@@ -144,13 +147,13 @@ describe Smiley do
144
147
  erb_utils = double('ERB::Utils')
145
148
  stub_const('ERB::Utils', erb_utils)
146
149
 
147
- erb_utils.should_receive(:html_escape).with('<script>alert("Hacked!")</script>').and_return('&lt;script&gt;alert(&quot;Hacked!&quot;)&lt;/script&gt;')
148
-
150
+ expect(erb_utils).to receive(:html_escape).with('<script>alert("Hacked!")</script>').and_return('&lt;script&gt;alert(&quot;Hacked!&quot;)&lt;/script&gt;')
151
+
149
152
  smiley.parse('<script>alert("Hacked!")</script>')
150
153
  end
151
154
 
152
155
  it 'marks the String as HTML safe, if that method is available' do
153
- String.any_instance.should_receive(:html_safe)
156
+ expect_any_instance_of(String).to receive(:html_safe)
154
157
 
155
158
  smiley.parse(':-)')
156
159
  end
@@ -4,4 +4,7 @@ RSpec.configure do |config|
4
4
  config.expect_with :rspec do |c|
5
5
  c.syntax = :expect
6
6
  end
7
+ config.mock_with :rspec do |c|
8
+ c.syntax = :expect
9
+ end
7
10
  end
metadata CHANGED
@@ -1,54 +1,54 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smiley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Barre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-30 00:00:00.000000000 Z
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '10.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.13.0
33
+ version: '2.13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.13.0
40
+ version: '2.13'
41
41
  description:
42
42
  email: igel@igels.net
43
43
  executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - README.md
48
- - MIT-LICENSE
49
- - Rakefile
50
47
  - Gemfile
51
48
  - Gemfile.lock
49
+ - MIT-LICENSE
50
+ - README.md
51
+ - Rakefile
52
52
  - lib/smiley.rb
53
53
  - spec/smiley_spec.rb
54
54
  - spec/spec_helper.rb
@@ -61,17 +61,17 @@ require_paths:
61
61
  - lib
62
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '>='
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: 1.3.6
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.0.0.rc.2
74
+ rubygems_version: 2.2.2
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: A small lib to parse smileys. Use CSS to display them!