rundown 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .DS_Store
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - ruby-head
6
+ # - jruby-head
7
+ # - 1.8.7
8
+ # - ree
9
+ # - jruby-18mode
10
+ # - jruby-19mode
11
+ # - rbx-2.1.1
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ Rundown
2
+ =======
3
+
4
+ [![Build Status](https://travis-ci.org/modsognir/rundown.png)](https://travis-ci.org/modsognir/rundown)
5
+
6
+ ###Known Issues
7
+
8
+ * Phone numbers need country code
9
+
10
+ ###Licence
11
+
12
+ Project released under an MIT license.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/lib/rundown.rb ADDED
@@ -0,0 +1,16 @@
1
+ require 'csv'
2
+ require 'delegate'
3
+ require 'phony'
4
+ require 'nickel'
5
+ require 'sentiment_parser'
6
+
7
+ require 'rundown/processor'
8
+ require 'rundown/words'
9
+ require 'rundown/email_processor'
10
+ require 'rundown/date_processor'
11
+ require 'rundown/phone_processor'
12
+ require 'rundown/sentiment_processor'
13
+
14
+ module Rundown
15
+ module_function
16
+ end
@@ -0,0 +1,15 @@
1
+ module Rundown
2
+ class DateProcessor < Processor
3
+ attr_accessor :text, :parser
4
+
5
+ def initialize(words, parser=Nickel)
6
+ @text = words.join(' ')
7
+ @parser = parser
8
+ end
9
+
10
+ def process
11
+ parser.parse(text).occurrences
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module Rundown
2
+ class EmailProcessor < Processor
3
+ REGEX = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
4
+
5
+ def cleanup_words
6
+ words = @words.map { |word|
7
+ word.gsub!(/\(|\)/, "")
8
+ }
9
+ end
10
+
11
+ def process
12
+ cleanup_words
13
+ words.select { |word|
14
+ Array(word.match(REGEX))[0]
15
+ }.reject(&:empty?).map {|word|
16
+ word.split('@')
17
+ }.reject { |words|
18
+ words.size < 2
19
+ }.select { |words|
20
+ x = Array(words.last).last.to_s.split('.').last
21
+ x.length <= 4 && !x.match(/\d+/)
22
+ }.map { |words|
23
+ words.join("@")
24
+ }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ module Rundown
2
+ class PhoneProcessor < Processor
3
+ attr_accessor :validator, :text
4
+
5
+ def initialize(words, validator=Phony)
6
+ @text = words.join(' ')
7
+ @validator = validator
8
+ end
9
+
10
+ def plausible?(number)
11
+ validator.plausible?(number)
12
+ end
13
+
14
+ def process
15
+ text.scan(/(\+?(\(|\)|[0-9]|\s|-|\.){4,20})/).select {|e| plausible?(e) }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module Rundown
2
+ class Processor
3
+ attr_accessor :words
4
+
5
+ def initialize(words)
6
+ @words = Array(words)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Rundown
2
+ class SentimentProcessor < Processor
3
+ attr_accessor :parser
4
+
5
+ def initialize(words, parser=SentimentParser)
6
+ @parser = parser
7
+ super(words)
8
+ end
9
+
10
+ def process
11
+ parser.parse(words.join(' '))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Rundown
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,10 @@
1
+ module Rundown
2
+ class Words < SimpleDelegator
3
+ attr_accessor :text
4
+
5
+ def initialize(text)
6
+ @text = text
7
+ __setobj__(text.split(" "))
8
+ end
9
+ end
10
+ end
data/rundown.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rundown/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rundown"
8
+ spec.version = Rundown::VERSION
9
+ spec.authors = ["Jared Fraser"]
10
+ spec.email = ["dev@jsf.io"]
11
+ spec.description = %q{knows things}
12
+ spec.summary = %q{knows things}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_dependency 'nickel'
22
+ spec.add_dependency 'phony'
23
+ spec.add_dependency 'sentiment_parser'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rundown do
4
+ subject {
5
+ "I'm sorry, I'm extremely busy right now. I just looked at the clock, and it's 12:54 AM, I've still got a lot of work to do. Don't worry about the event tomorrow, it's been moved ahead a week, the 28th of december. Remember though, you've got to call to get a ticket soon, their # is 1-212-323-1239. Their website says it costs $23 per person.
6
+ If you've got enough time, they have some more information on their website, http://theevent.com.
7
+ Regards,
8
+ David (david32@gmail.com)".split(/\s/)
9
+ }
10
+
11
+ describe 'emails' do
12
+ it { expect(Rundown::EmailProcessor.new(subject).process).to eql ["david32@gmail.com"]}
13
+ end
14
+
15
+ describe 'dates' do
16
+ # FIXME: remove dependence on start date knowledge
17
+ it { expect(Rundown::DateProcessor.new(subject).process.map(&:start_date).map(&:date)).to include "20131228"}
18
+ end
19
+
20
+ describe 'phones' do
21
+ it { pending; expect(Rundown::PhoneProcessor.new(subject).process).to eql ["212-323-1239"]}
22
+ end
23
+
24
+ describe 'sentiment' do
25
+ it { expect(Rundown::SentimentProcessor.new(subject).process.floor).to eql(2) }
26
+ end
27
+
28
+ end
@@ -0,0 +1,18 @@
1
+ require 'rundown'
2
+ # This file was generated by the `rspec --init` command. Conventionally, all
3
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4
+ # Require this file using `require "spec_helper"` to ensure that it is only
5
+ # loaded once.
6
+ #
7
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ # Run specs in random order to surface order dependencies. If you find an
14
+ # order dependency and want to debug it, you can fix the order by providing
15
+ # the seed, which is printed after each run.
16
+ # --seed 1234
17
+ config.order = 'random'
18
+ end
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rundown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jared Fraser
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nickel
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: phony
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: sentiment_parser
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.3'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.3'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: knows things
111
+ email:
112
+ - dev@jsf.io
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - .rspec
119
+ - .travis.yml
120
+ - Gemfile
121
+ - README.md
122
+ - Rakefile
123
+ - lib/rundown.rb
124
+ - lib/rundown/date_processor.rb
125
+ - lib/rundown/email_processor.rb
126
+ - lib/rundown/phone_processor.rb
127
+ - lib/rundown/processor.rb
128
+ - lib/rundown/sentiment_processor.rb
129
+ - lib/rundown/version.rb
130
+ - lib/rundown/words.rb
131
+ - rundown.gemspec
132
+ - spec/rundown_spec.rb
133
+ - spec/spec_helper.rb
134
+ homepage: ''
135
+ licenses:
136
+ - MIT
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: -2506835466625535810
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ segments:
157
+ - 0
158
+ hash: -2506835466625535810
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 1.8.25
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: knows things
165
+ test_files:
166
+ - spec/rundown_spec.rb
167
+ - spec/spec_helper.rb