sarnesjo-twhere 0.0.10 → 0.0.11

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.
Files changed (4) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/twhere.rb +1 -1
  3. data/spec/hashtag_spec.rb +22 -10
  4. metadata +2 -2
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 0
3
- :patch: 10
3
+ :patch: 11
4
4
  :major: 0
data/lib/twhere.rb CHANGED
@@ -4,7 +4,7 @@ require 'twitter'
4
4
 
5
5
  module TwhereHelperMethods
6
6
  def hashtag(str)
7
- md = str.match(/#([^#\s]+)/) and md[1]
7
+ md = str.match(/#([A-Za-z0-9]+)/) and md[1]
8
8
  end
9
9
  end
10
10
 
data/spec/hashtag_spec.rb CHANGED
@@ -4,40 +4,52 @@ require 'spec_helper'
4
4
  describe 'hashtag method' do
5
5
  include TwhereHelperMethods
6
6
 
7
- it 'should find hashtags' do
8
- # no hashtags
7
+ it 'should return nil when there are no hashtags' do
9
8
  hashtag('').should == nil
10
9
  hashtag('a').should == nil
11
10
  hashtag('#').should == nil
12
11
  hashtag('##').should == nil
12
+ end
13
13
 
14
- # lowercase
14
+ it 'should find hashtags containing only lowercase letters' do
15
15
  hashtag('#a').should == 'a'
16
16
  hashtag('#aa').should == 'aa'
17
+ end
17
18
 
18
- # uppercase
19
+ it 'should find hashtags containing only uppercase letters' do
19
20
  hashtag('#A').should == 'A'
20
21
  hashtag('#AA').should == 'AA'
22
+ end
21
23
 
22
- # digits
24
+ it 'should find hashtags containing only digits' do
23
25
  hashtag('#1').should == '1'
24
26
  hashtag('#11').should == '11'
27
+ end
25
28
 
26
- # TODO: unicode?
27
-
28
- # mixed character classes
29
+ it 'should find hashtags containing mixed character classes' do
29
30
  hashtag('#aA').should == 'aA'
30
31
  hashtag('#Aa').should == 'Aa'
31
32
  hashtag('#a1').should == 'a1'
32
33
  hashtag('#1a').should == '1a'
33
34
  hashtag('#A1').should == 'A1'
34
35
  hashtag('#1A').should == '1A'
36
+ end
35
37
 
36
- # in text
38
+ it 'should find hashtags in text' do
37
39
  hashtag('a #b').should == 'b'
38
40
  hashtag('#a b').should == 'a'
41
+ end
39
42
 
40
- # multiple hashtags, use first
43
+ it 'should return the first hashtag found' do
41
44
  hashtag('#a #b').should == 'a'
42
45
  end
46
+
47
+ it 'should not include punctuation in hashtags' do
48
+ hashtag('#a.').should == 'a'
49
+ hashtag('#a,').should == 'a'
50
+ hashtag('#a:').should == 'a'
51
+ hashtag('#a;').should == 'a'
52
+ hashtag('#a!').should == 'a'
53
+ hashtag('#a?').should == 'a'
54
+ end
43
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sarnesjo-twhere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Jesper S\xC3\xA4rnesj\xC3\xB6"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-30 00:00:00 -07:00
12
+ date: 2009-05-04 00:00:00 -07:00
13
13
  default_executable: twhere
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency