hashtag_finder 0.0.3
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +19 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +12 -0
- data/Rakefile +7 -0
- data/hashtag_finder.gemspec +26 -0
- data/lib/hashtag_finder.rb +28 -0
- data/lib/version.rb +0 -0
- data/spec/hashtag_finder_spec.rb +41 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2ba0456566fc1b97f7d60c4bf8d0ffeafd871590
|
4
|
+
data.tar.gz: 8c8efa2e771beebc92bf63d29024ab7ce9ade5bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 19ad254df55be83ede855d846305e14d3a47b831b65715d8da20b772d55aa3c12bb23470c7f7042499e945380bd136725c5631068650bd203cf7600f0380ed8a
|
7
|
+
data.tar.gz: e34e81b6aad9d0026367d9b0d90d7a57ee975a9254a6094c8c55c481ee83ae1b6dc5553e8cb07f18c6a5c1ec30361828608d80ca0996f52c480e73d7e3a4c8db
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
4
|
+
rvm:
|
5
|
+
- 2.1.2
|
6
|
+
- 2.0.0
|
7
|
+
- 1.9.3
|
8
|
+
|
9
|
+
script: 'bundle exec rake test'
|
10
|
+
|
11
|
+
notifications:
|
12
|
+
email:
|
13
|
+
recipients:
|
14
|
+
- apagano@wawand.co
|
15
|
+
on_failure: change
|
16
|
+
on_success: never
|
17
|
+
addons:
|
18
|
+
code_climate:
|
19
|
+
repo_token: c55d85a239cccfc962610effd319b2bc1e831a59c36fc1b267297d00d988bd09
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Antonio Pagano and Wawandco, SAS.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# hashtag_finder
|
2
|
+
|
3
|
+
Simple Hash-Tag recognition explorations using the #scan method on the String class.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
HashtagRecognition class has a method called `find_on` that receives a string and returns the *hashtags* it contains.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
tags = HashtagFinder.find_on("#some #test sample") // returns ["some", "test"]
|
11
|
+
tags = HashtagFinder.find_on("some test sample") // returns []
|
12
|
+
tags = HashtagFinder.find_on("#duplicated #duplicated sample") // returns ["duplicated"]
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hashtag_finder'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hashtag_finder"
|
8
|
+
spec.version = HashtagFinder::VERSION
|
9
|
+
spec.authors = ["Antonio Pagano"]
|
10
|
+
spec.email = ["ap@wawand.co"]
|
11
|
+
spec.summary = %q{ Simple Hashtag recognition for strings}
|
12
|
+
spec.description = %q{ Simple Hashtag recognition for strings }
|
13
|
+
spec.homepage = "https://github.com/apaganobeleno/hashtag_finder"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.5"
|
24
|
+
spec.add_development_dependency "minitest-matchers", "1.4"
|
25
|
+
spec.add_development_dependency "codeclimate-test-reporter", '~> 0'
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class HashtagFinder
|
2
|
+
VERSION = "0.0.3"
|
3
|
+
|
4
|
+
def self.find_on( subject )
|
5
|
+
result = []
|
6
|
+
|
7
|
+
unless !subject || subject.empty?
|
8
|
+
expression = /#(\S*)/
|
9
|
+
matches = subject.scan(expression)
|
10
|
+
result = clean(matches)
|
11
|
+
|
12
|
+
return result
|
13
|
+
else
|
14
|
+
return result
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.clean( matches )
|
19
|
+
result = matches.flatten.collect do |el|
|
20
|
+
el.gsub('#', '').downcase if el.size > 0
|
21
|
+
end
|
22
|
+
|
23
|
+
result.compact!
|
24
|
+
result.uniq!
|
25
|
+
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
end
|
data/lib/version.rb
ADDED
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'hashtag_finder'
|
4
|
+
|
5
|
+
describe HashtagFinder do
|
6
|
+
it "returns hashtags from a string" do
|
7
|
+
HashtagFinder.find_on( "#some #string to test" ).must_equal ["some", "string"]
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns non 0 length hashtags from a string" do
|
11
|
+
HashtagFinder.find_on( "# #some #string to test" ).must_equal ["some", "string"]
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns double hash hashtags with only one" do
|
15
|
+
HashtagFinder.find_on( "##some #string ###to test" ).must_equal ["some", "string", "to"]
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns double hash hashtags with only one" do
|
19
|
+
HashtagFinder.find_on( "some #string ###to test#" ).must_equal [ "string", "to"]
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns only one of the repeated tags" do
|
23
|
+
HashtagFinder.find_on( "#some #string #string to tes" ).must_equal ["some", "string"]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "counts case-variations as the same" do
|
27
|
+
HashtagFinder.find_on( "#some #StRing #string to tes" ).must_equal ["some", "string"]
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns empty array if no hashtags" do
|
31
|
+
HashtagFinder.find_on( "some string to test" ).must_equal []
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns empty array if nil passed" do
|
35
|
+
HashtagFinder.find_on( nil ).must_equal []
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns empty array if empty passed" do
|
39
|
+
HashtagFinder.find_on("").must_equal []
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hashtag_finder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Antonio Pagano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-matchers
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codeclimate-test-reporter
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: " Simple Hashtag recognition for strings "
|
84
|
+
email:
|
85
|
+
- ap@wawand.co
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- hashtag_finder.gemspec
|
97
|
+
- lib/hashtag_finder.rb
|
98
|
+
- lib/version.rb
|
99
|
+
- spec/hashtag_finder_spec.rb
|
100
|
+
homepage: https://github.com/apaganobeleno/hashtag_finder
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.4.1
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Simple Hashtag recognition for strings
|
124
|
+
test_files:
|
125
|
+
- spec/hashtag_finder_spec.rb
|