shortee 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shortee.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,112 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
25
+
26
+ guard 'rspec' do
27
+ watch(%r{^spec/.+_spec\.rb$})
28
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
29
+ watch('spec/spec_helper.rb') { "spec" }
30
+
31
+ # Rails example
32
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
33
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
34
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
35
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
36
+ watch('config/routes.rb') { "spec/routing" }
37
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
38
+
39
+ # Capybara features specs
40
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
41
+
42
+ # Turnip features and steps
43
+ watch(%r{^spec/acceptance/(.+)\.feature$})
44
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
45
+ end
46
+
47
+
48
+ guard 'rspec' do
49
+ watch(%r{^spec/.+_spec\.rb$})
50
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
51
+ watch('spec/spec_helper.rb') { "spec" }
52
+
53
+ # Rails example
54
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
55
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
56
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
57
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
58
+ watch('config/routes.rb') { "spec/routing" }
59
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
63
+
64
+ # Turnip features and steps
65
+ watch(%r{^spec/acceptance/(.+)\.feature$})
66
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
67
+ end
68
+
69
+
70
+ guard 'rspec' do
71
+ watch(%r{^spec/.+_spec\.rb$})
72
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
73
+ watch('spec/spec_helper.rb') { "spec" }
74
+
75
+ # Rails example
76
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
77
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
78
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
79
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
80
+ watch('config/routes.rb') { "spec/routing" }
81
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
82
+
83
+ # Capybara features specs
84
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
85
+
86
+ # Turnip features and steps
87
+ watch(%r{^spec/acceptance/(.+)\.feature$})
88
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
89
+ end
90
+
91
+
92
+ guard 'rspec' do
93
+ watch(%r{^spec/.+_spec\.rb$})
94
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
95
+ watch('spec/spec_helper.rb') { "spec" }
96
+
97
+ # Rails example
98
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
99
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
100
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
101
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
102
+ watch('config/routes.rb') { "spec/routing" }
103
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
104
+
105
+ # Capybara features specs
106
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
107
+
108
+ # Turnip features and steps
109
+ watch(%r{^spec/acceptance/(.+)\.feature$})
110
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
111
+ end
112
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012-2013 Jeremy Nevill
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Shortee
2
+
3
+ Shortee is a gem for parsing small messages called Shorts, which use the Shortee Syntax.
4
+
5
+ The Shortee Syntax enables a user to record events that they wish to track, examples being business mileage, calories eaten, miles cycled, etc.
6
+
7
+ The specification for a Shortee Syntax can be found at https://github.com/JeremyNevill/shortee/blob/master/Shortee_specification.md
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'shortee'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install shortee
23
+
24
+ ## Usage
25
+
26
+ This gem is in initial development, usage instructions will be added shortly.
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,151 @@
1
+ # Shortee Specification
2
+
3
+ *Shortee* is a simple syntax for tracking events,
4
+ you can see it in action over at http://www.shortee.org
5
+
6
+ If you wish to parse Shortee messages for your application then you can use the Shortee gem at https://github.com/JeremyNevill/shortee
7
+
8
+ If runnerboy had just run 3 miles then a shortee message for that could be:
9
+
10
+ @runnerboy ran 5miles 01/jan/2012
11
+
12
+ The design aims for the Shortee syntax are:
13
+
14
+ * *Readable* by a human
15
+ * *Parseable* by a computer
16
+ * *Memorable* by it's simplicity
17
+ * *Concise* enough to work everywhere (email, sms, twitter, on a postit)
18
+ * *Fast* enough to create on a mobile device one handed
19
+
20
+
21
+ ## Examples
22
+
23
+ Shortee was bourne out of my need to record stuff on the go that I would later want to recall and review.
24
+
25
+ This could include my business mileage, what my dog had eaten, when I had paid tax etc.
26
+
27
+ For example, to record that you have driven 200 miles on New Year's Day 2012:
28
+
29
+ @JeremyNevill drove 100miles 01/jan/2012
30
+
31
+ Or if you have just paid your road tax:
32
+
33
+ @JeremyNevill paidcartax 249ukp 03/sep/2010
34
+
35
+ Or fed the dog:
36
+
37
+ @master fed @fido 1bowl 01/oct/2012
38
+
39
+ Or if you website has registered had a new user:
40
+
41
+ @shortee.org newuser 05/nov/2012
42
+
43
+
44
+ ## Syntax
45
+
46
+ The original condensed syntax is as follows:
47
+
48
+ @mainactor action 999units dd/mmm/yyyy
49
+
50
+ e.g. @JeremyNevill coded 50lines 26/oct/2012
51
+
52
+ ### Where...
53
+
54
+ #### @mainactor
55
+ is the main actor of the shortee message, usually a person or a system.
56
+ e.g. @fredflintstone, @hyperlite - as we are using the Twitter convention for referring to the main actor you can take advantage of this also linking to your Twitter identity.
57
+
58
+ #### action
59
+ is for logging a verb in past tense. e.g. coded.
60
+ You are at liberty to invent any action, using your own language, poor spelling or combinations, it's your message after all.
61
+ Note: If you wish to create a message showing intent to do something use a future tense e.g. needstobuy
62
+
63
+
64
+ #### 999
65
+ is the number of things you have acted on. e.g. 100
66
+
67
+
68
+ #### units
69
+ is the units that go with the number of things to log. e.g. lines
70
+
71
+
72
+ #### dd/mmm/yyy
73
+ is the date that you wish to store the action as occuring.
74
+
75
+
76
+ ### Extending
77
+
78
+ This syntax is expected to be expanded upon.
79
+ Feel free to fork, modify for your own use and get in touch if you want to add something new using a pull request.
80
+
81
+ ## Software
82
+
83
+ As shortee is a technology independent syntax your free to use it with anything that can store a string, see the list of systems
84
+ you can use to store messages below. As you will notice the @user string is insipired by the way twitter users reference each
85
+ other, if you use your twitter id for the actor field you can tie your messages to your online id.
86
+
87
+ ### Email Friendly
88
+
89
+ I use shortee comprehensively with my email account.. I email myself a shortee message using the subject field.
90
+ To recall and view my messages I simply search for what I want... e.g. every shortee message involving me is a search for '@JeremyNevill'
91
+
92
+ ### Storing Messages
93
+
94
+ * Any system that can record a single string should be able to store a Shortee message:
95
+ * Email (inlcuding gmail, hotmail, outlook, etc)
96
+ * SMS
97
+ * Twitter
98
+ * Notepad
99
+ * iMessage
100
+ * Postit notes or other bits of paper
101
+
102
+ ### Searching Messages
103
+
104
+ Searching for messages are easy in most applications that can store them.
105
+
106
+ For example if you store your shortee messages in gmail, you could search for all your messages with '@JeremyNevill drove' in them.
107
+
108
+ ### Shortee App?
109
+
110
+ An online home for your Shortees has recently been launched and is located at http://www.shortee.org , this site allows the storing, browsing and searching of
111
+ Shortee messages in a mobile and desktop friendly way.
112
+
113
+ Remember you can store your Shortees wherever you can store a line of text, e.g. in email, on twitter, as a Facebook update etc so you don't need a Shortee specific app for your messages.
114
+
115
+ ## Common Uses
116
+
117
+ As shortee allows you to invent your own actors and actions you can create a way to log almost anything,
118
+ from geeky authentication system stuff to real world coffee drinking habits... here are some common uses:
119
+
120
+ * Logging things that you need to recall in the future - e.g. your business mileage over a month
121
+ * Reviewing things that you have done - e.g. when were my last three runs?
122
+ * Extracting trends on things that you have done - e.g. has the dog got his appetite back?
123
+ * Logging actions a system has done - e.g. how many people registered on the website today?
124
+
125
+ ## License
126
+
127
+ Copyright (c) 2012-2013, Jeremy Nevill
128
+ All rights reserved.
129
+
130
+ Redistribution and use in source and binary forms, with or without
131
+ modification, are permitted provided that the following conditions are met:
132
+
133
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
134
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
135
+ * Neither the name of the Shortee nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
136
+
137
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
138
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
139
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
140
+ DISCLAIMED. IN NO EVENT SHALL JEREMY NEVILL BE LIABLE FOR ANY
141
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
142
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
143
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
144
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
145
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
146
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147
+
148
+
149
+
150
+
151
+
@@ -0,0 +1,73 @@
1
+ require "parslet"
2
+
3
+ module Shortee
4
+
5
+ class Shortee::Parser < Parslet::Parser
6
+
7
+ # A space and many spaces
8
+ rule(:space) { match('\s').repeat(1) }
9
+ rule(:space?) { space.maybe }
10
+
11
+ # Other rules
12
+ rule(:dash?) { match['_-'].maybe }
13
+ rule(:at) { str('@') | (dash? >> (str('at') | str('AT')) >> dash?) }
14
+ rule(:dot) { str('.') | (dash? >> (str('dot') | str('DOT')) >> dash?) }
15
+
16
+ rule(:forwardslash) { match['/'] }
17
+
18
+ rule(:integer) { match('[0-9]').repeat(1)>> space? }
19
+ rule(:word) { match('[a-zA-Z0-9]').repeat(1).as(:word) >> space? }
20
+ rule(:separator) { dot.as(:dot) >> space? | space }
21
+ rule(:words) { word >> (separator >> word).repeat }
22
+
23
+ # Shortee rules
24
+ rule(:actor) { match('[a-zA-Z0-9]').repeat(1).as(:actor) >> space? }
25
+ rule(:actee) { match('[a-zA-Z0-9]').repeat(1).as(:actee) >> space? }
26
+ rule(:action) { match('[a-zA-Z]').repeat(1).as(:action) >> space? }
27
+ rule(:amountnum) { match('[0-9.]').repeat(1).as(:amountnum) }
28
+ rule(:amountunits) { match('[a-zA-Z]').repeat(1).as(:amountunits) >> space? }
29
+
30
+ rule(:day) { match('[0-9]').repeat(1).as(:day) }
31
+ rule(:month) { match('[a-zA-Z]').repeat(1).as(:month) }
32
+ rule(:year) { match('[0-9]').repeat(1).as(:year) }
33
+ rule(:ukmonth) { match('[0-9]').repeat(1).as(:ukmonth) }
34
+
35
+ rule(:shorteeshort) {
36
+ (space? >> at >> actor.as(:mainactor) >>
37
+ action >>
38
+ amountnum >> amountunits >>
39
+ day >> forwardslash >>
40
+ month >> forwardslash >> year).as(:shortee)
41
+ }
42
+
43
+ rule(:shorteeukshort) {
44
+ (space? >> at >> actor.as(:mainactor) >>
45
+ action >>
46
+ amountnum >> amountunits >>
47
+ day >> forwardslash >>
48
+ ukmonth >> forwardslash >> year).as(:shortee)
49
+ }
50
+
51
+ rule(:shorteelong) {
52
+ (space? >> at >> actor.as(:mainactor) >>
53
+ action >>
54
+ at >> actee.as(:actee) >>
55
+ amountnum >> amountunits >>
56
+ day >> forwardslash >>
57
+ month >> forwardslash >> year).as(:shortee)
58
+ }
59
+
60
+ rule(:shorteeuklong) {
61
+ (space? >> at >> actor.as(:mainactor) >>
62
+ action >>
63
+ at >> actee.as(:actee) >>
64
+ amountnum >> amountunits >>
65
+ day >> forwardslash >>
66
+ ukmonth >> forwardslash >> year).as(:shortee)
67
+ }
68
+
69
+ rule(:allshorts) { shorteeshort | shorteeukshort | shorteelong | shorteeuklong }
70
+
71
+ root(:allshorts)
72
+ end
73
+ end
@@ -0,0 +1,3 @@
1
+ module Shortee
2
+ VERSION = "0.0.2"
3
+ end
data/lib/shortee.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "shortee/version"
2
+ require "shortee/parser"
3
+
4
+ module Shortee
5
+
6
+
7
+ end
8
+
9
+
10
+
11
+
data/shortee.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shortee/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "shortee"
8
+ gem.version = Shortee::VERSION
9
+ gem.authors = ["Jeremy Nevill"]
10
+ gem.email = ["jeremy@nevill.net"]
11
+ gem.description = %q{Shortee message parser and specification for tracking events.}
12
+ gem.summary = %q{Shortee gem contains a message parser and specification for easy and fast event tracking using single line messages.}
13
+ gem.homepage = "https://github.com/JeremyNevill/shortee"
14
+
15
+ gem.add_development_dependency "parslet"
16
+ gem.add_development_dependency "rspec"
17
+ gem.add_development_dependency "rake"
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,76 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+ require 'shortee'
4
+
5
+ describe Shortee::Parser do
6
+
7
+ it "should parse an actee" do
8
+ test_message="@actor didto @actee 1something 01/12/2012"
9
+ parser = Shortee::Parser.new
10
+ parsed_message = parser.parse(test_message)
11
+ parsed_message[:shortee][:actee][:actee].to_s.should eq("actee")
12
+ end
13
+
14
+ it "should parse another actee" do
15
+ test_message="@actor didto @jimboWilliams 1something 01/jan/2012"
16
+ parser = Shortee::Parser.new
17
+ parsed_message = parser.parse(test_message)
18
+ parsed_message[:shortee][:actee][:actee].to_s.should eq("jimboWilliams")
19
+ end
20
+
21
+ it "should parse a valid actee" do
22
+ test_message="@actor gave @frank 2cheeses 01/jan/2012"
23
+ parser = Shortee::Parser.new
24
+ parsed_message = parser.parse(test_message)
25
+ parsed_message[:shortee][:actee][:actee].to_s.should eq("frank")
26
+ end
27
+
28
+ it "should parse a valid mainactor" do
29
+ test_message="@somebody did 1thing 01/jan/2012"
30
+ parser = Shortee::Parser.new
31
+ parsed_message = parser.parse(test_message)
32
+ parsed_message[:shortee][:mainactor][:actor].to_s.should eq("somebody")
33
+ end
34
+
35
+ it "should parse a valid action" do
36
+ test_message="@somebody did 1thing 01/jan/2012"
37
+ parser = Shortee::Parser.new
38
+ parsed_message = parser.parse(test_message)
39
+ parsed_message[:shortee][:action].to_s.should eq("did")
40
+ end
41
+
42
+ it "should parse a valid amount" do
43
+ test_message="@somebody did 1thing 01/jan/2012"
44
+ parser = Shortee::Parser.new
45
+ parsed_message = parser.parse(test_message)
46
+ parsed_message[:shortee][:amountnum].should eq("1")
47
+ end
48
+
49
+ it "should parse a valid full date" do
50
+ test_message="@somebody did 1thing 01/jan/2012"
51
+ parser = Shortee::Parser.new
52
+ parsed_message = parser.parse(test_message)
53
+ parsed_message[:shortee][:day].should eq("01")
54
+ parsed_message[:shortee][:month].should eq("jan")
55
+ parsed_message[:shortee][:year].should eq("2012")
56
+ end
57
+
58
+ it "should parse a valid UK date" do
59
+ test_message="@somebody did 1thing 01/12/2012"
60
+ parser = Shortee::Parser.new
61
+ parsed_message = parser.parse(test_message)
62
+ parsed_message[:shortee][:day].should eq("01")
63
+ parsed_message[:shortee][:ukmonth].should eq("12")
64
+ parsed_message[:shortee][:year].should eq("2012")
65
+ end
66
+
67
+ it "should parse another valid UK date" do
68
+ test_message="@frankee ate 2cheeses 13/01/2012"
69
+ parser = Shortee::Parser.new
70
+ parsed_message = parser.parse(test_message)
71
+ parsed_message[:shortee][:day].should eq("13")
72
+ parsed_message[:shortee][:ukmonth].should eq("01")
73
+ parsed_message[:shortee][:year].should eq("2012")
74
+ end
75
+
76
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shortee
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeremy Nevill
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: parslet
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
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: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
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: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
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
+ description: Shortee message parser and specification for tracking events.
63
+ email:
64
+ - jeremy@nevill.net
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rspec
71
+ - Gemfile
72
+ - Guardfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - Shortee_specification.md
77
+ - lib/shortee.rb
78
+ - lib/shortee/parser.rb
79
+ - lib/shortee/version.rb
80
+ - shortee.gemspec
81
+ - spec/parser_spec.rb
82
+ - spec/spec_helper.rb
83
+ homepage: https://github.com/JeremyNevill/shortee
84
+ licenses: []
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ segments:
96
+ - 0
97
+ hash: 2187104680392310245
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ segments:
105
+ - 0
106
+ hash: 2187104680392310245
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 1.8.24
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: Shortee gem contains a message parser and specification for easy and fast
113
+ event tracking using single line messages.
114
+ test_files:
115
+ - spec/parser_spec.rb
116
+ - spec/spec_helper.rb