nickel 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ if ENV['TRAVIS'] && ENV['COVERALLS'] && RUBY_ENGINE == 'ruby'
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ end
5
+
6
+ RSpec.configure do |config|
7
+ config.order = 'random'
8
+ config.expect_with(:rspec){ |c| c.syntax = :expect }
9
+ config.mock_with(:rspec){ |c| c.syntax = :expect }
10
+ config.filter_run_excluding broken: true
11
+
12
+ # make sure warnings are not shown when testing deprecated methods
13
+ config.around(:each, :deprecated) do |example|
14
+ original_verbose = $VERBOSE
15
+ begin
16
+ $VERBOSE = nil
17
+ example.run
18
+ ensure
19
+ $VERBOSE = original_verbose
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,73 +1,162 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nickel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lou Zell
8
+ - Iain Beeston
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-20 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2014-03-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 3.0.0.beta2
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 3.0.0.beta2
56
+ - !ruby/object:Gem::Dependency
57
+ name: coveralls
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: yard
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: kramdown
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
14
98
  description: Extracts date, time, and message information from naturally worded text.
15
- email: lzell11@gmail.com
99
+ email:
16
100
  executables: []
17
101
  extensions: []
18
- extra_rdoc_files:
19
- - README.rdoc
102
+ extra_rdoc_files: []
20
103
  files:
21
- - History.txt
104
+ - .gitignore
105
+ - .travis.yml
106
+ - .yardopts
107
+ - CHANGELOG.md
108
+ - Gemfile
22
109
  - License.txt
23
- - README.rdoc
110
+ - README.md
24
111
  - Rakefile
25
- - nickel.gemspec
112
+ - bin/run_specs.sh
26
113
  - lib/nickel.rb
27
114
  - lib/nickel/construct.rb
28
115
  - lib/nickel/construct_finder.rb
29
116
  - lib/nickel/construct_interpreter.rb
30
- - lib/nickel/instance_from_hash.rb
31
117
  - lib/nickel/nlp.rb
118
+ - lib/nickel/nlp_query.rb
119
+ - lib/nickel/nlp_query_constants.rb
32
120
  - lib/nickel/occurrence.rb
33
- - lib/nickel/query.rb
34
- - lib/nickel/query_constants.rb
121
+ - lib/nickel/version.rb
35
122
  - lib/nickel/zdate.rb
36
123
  - lib/nickel/ztime.rb
37
- - lib/nickel/ruby_ext/calling_method.rb
38
- - lib/nickel/ruby_ext/to_s2.rb
39
- - test/compare.rb
40
- - test/nlp_test.rb
41
- - test/nlp_tests_helper.rb
42
- - test/zdate_test.rb
43
- - test/ztime_test.rb
44
- - spec/nickel_spec.rb
45
- homepage: http://github.com/lzell/nickel
46
- licenses: []
124
+ - nickel.gemspec
125
+ - spec/lib/nickel/nlp_spec.rb
126
+ - spec/lib/nickel/occurrence_spec.rb
127
+ - spec/lib/nickel/zdate_spec.rb
128
+ - spec/lib/nickel/ztime_spec.rb
129
+ - spec/lib/nickel_spec.rb
130
+ - spec/spec_helper.rb
131
+ homepage: http://github.com/iainbeeston/nickel
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
47
135
  post_install_message:
48
- rdoc_options:
49
- - --main
50
- - README.rdoc
51
- - --title
52
- - Nickel
136
+ rdoc_options: []
53
137
  require_paths:
54
138
  - lib
55
139
  required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
140
  requirements:
58
- - - ! '>='
141
+ - - '>='
59
142
  - !ruby/object:Gem::Version
60
143
  version: '0'
61
144
  required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
145
  requirements:
64
- - - ! '>='
146
+ - - '>='
65
147
  - !ruby/object:Gem::Version
66
148
  version: '0'
67
149
  requirements: []
68
150
  rubyforge_project:
69
- rubygems_version: 1.8.23
151
+ rubygems_version: 2.1.11
70
152
  signing_key:
71
- specification_version: 3
153
+ specification_version: 4
72
154
  summary: Natural language date, time, and message parsing.
73
- test_files: []
155
+ test_files:
156
+ - spec/lib/nickel/nlp_spec.rb
157
+ - spec/lib/nickel/occurrence_spec.rb
158
+ - spec/lib/nickel/zdate_spec.rb
159
+ - spec/lib/nickel/ztime_spec.rb
160
+ - spec/lib/nickel_spec.rb
161
+ - spec/spec_helper.rb
162
+ has_rdoc: true
data/History.txt DELETED
@@ -1,11 +0,0 @@
1
- == 0.0.1 2009-03-22
2
-
3
- Initial release!
4
-
5
- == 0.0.2 2009-03-30
6
-
7
- No www in request
8
-
9
- == 0.0.3 2010-04-02
10
-
11
- Able to set current time for query
data/README.rdoc DELETED
@@ -1,69 +0,0 @@
1
- === Nickel extracts date, time, and message information from naturally worded text.
2
-
3
- === Install
4
-
5
- gem install nickel
6
-
7
- === Usage
8
-
9
- ==== A single occurrence
10
- n = Nickel.parse("use the force on july 1st at 9am", Time.now)
11
- n.message #=> "use the force"
12
- n.occurrences.first.start_date #=> "20110701"
13
-
14
- ==== A daily occurrence
15
- n = Nickel.parse "wake up everyday at 11am"
16
- n.message # => wake up
17
- n.occurrences[0].type # => daily
18
- n.occurrences[0].start_time # => 11:00:00
19
-
20
- ==== A weekly occurrence
21
- n = Nickel.parse "guitar lessons every tuesday at 5pm"
22
- n.message # => guitar lessons
23
- n.occurrences[0].type # => weekly
24
- n.occurrences[0].day_of_week # => tue
25
- n.occurrences[0].interval # => 1
26
- n.occurrences[0].start_time # => 17:00:00
27
-
28
- ==== A day monthly occurrence
29
- n = Nickel.parse "drink specials on the second thursday of every month"
30
- n.message # => drink specials
31
- n.occurrences[0].type # => daymonthly
32
- n.occurrences[0].day_of_week # => thu
33
- n.occurrences[0].week_of_month # => 2
34
- n.occurrences[0].interval # => 1
35
-
36
- ==== A date monthly occurrence
37
- n = Nickel.parse "pay credit card every month on the 22nd"
38
- n.message # => pay credit card
39
- n.occurrences[0].type # => datemonthly
40
- n.occurrences[0].date_of_month # => 22
41
- n.occurrences[0].interval # => 1
42
-
43
- ==== Multiple occurrences
44
- n = Nickel.parse "band meeting every monday and wednesday at 2pm"
45
- n.message # => band meeting
46
- n.occurrences[0].type # => weekly
47
- n.occurrences[0].day_of_week # => mon
48
- n.occurrences[0].start_time # => 14:00:00
49
- n.occurrences[1].type # => weekly
50
- n.occurrences[1].day_of_week # => wed
51
- n.occurrences[1].start_time # => 14:00:00
52
-
53
- ==== Setting current time
54
-
55
- n = Nickel.parse "lunch 3 days from now", DateTime.new(2010,3,31)
56
- n.message # => lunch
57
- n.occurrences[0].start_date # => 20100403
58
-
59
-
60
- Running Tests
61
- =======
62
- $ rake test
63
-
64
- If you do not have RUBYOPT set:
65
- $ RUBYOPT='rubygems' rake test
66
-
67
-
68
- Copyright (c) 2008-2011 Lou Zell, released under the MIT license
69
-
@@ -1,13 +0,0 @@
1
- # Ruby Nickel Library
2
- # Copyright (c) 2008-2011 Lou Zell, lzell11@gmail.com, http://hazelmade.com
3
- # MIT License [http://www.opensource.org/licenses/mit-license.php]
4
-
5
- module InstanceFromHash
6
-
7
- def initialize(h)
8
- h.each do |k,v|
9
- instance_variable_set("@#{k}", v)
10
- end
11
- super()
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- module Kernel
2
- private
3
- def method_name
4
- caller[0] =~ /`([^']*)'/ and $1
5
- end
6
- def calling_method
7
- md = caller[1].match(/(\d+):in `([^']*)'/)
8
- md && "#{md[2]}:#{md[1]}"
9
- end
10
- end
@@ -1,12 +0,0 @@
1
- class Fixnum
2
- def to_s2
3
- str = self.to_s
4
- str.sub(/^(\d)$/,'0\1')
5
- end
6
- end
7
-
8
- class String
9
- def to_s2
10
- sub(/^(\d)$/,'0\1')
11
- end
12
- end
data/spec/nickel_spec.rb DELETED
@@ -1,165 +0,0 @@
1
- # Run with:
2
- # ~/dev/nickel(master)$ rspec test/nickel_spec.rb
3
- require File.expand_path(File.dirname(__FILE__) + "/../lib/nickel")
4
-
5
-
6
- describe "A single date" do
7
- before(:all) { @n = Nickel.query "oct 15 09" }
8
-
9
- it "should have an empty message" do
10
- @n.message.should be_empty
11
- end
12
-
13
- it "should have a start date" do
14
- @n.occurrences.size.should == 1
15
- @n.occurrences.first.start_date.should == "20091015"
16
- end
17
- end
18
-
19
- describe "A daily occurrence" do
20
- before(:all) do
21
- @n = Nickel.query "wake up everyday at 11am"
22
- @occurs = @n.occurrences.first
23
- end
24
-
25
- it "should have a message" do
26
- @n.message.should == "wake up"
27
- end
28
-
29
- it "should be daily" do
30
- @occurs.type.should == "daily"
31
- end
32
-
33
- it "should have a start time" do
34
- @occurs.start_time.should == "11:00:00"
35
- end
36
- end
37
-
38
-
39
- describe "A weekly occurrence" do
40
- before(:all) do
41
- @n = Nickel.query "guitar lessons every tuesday at 5pm"
42
- @occurs = @n.occurrences.first
43
- end
44
-
45
- it "should have a message" do
46
- @n.message.should == "guitar lessons"
47
- end
48
-
49
- it "should be weekly" do
50
- @occurs.type.should == "weekly"
51
- end
52
-
53
-
54
- it "should occur on tuesdays" do
55
- @occurs.day_of_week.should == "tue"
56
- end
57
-
58
- it "should occur once per week" do
59
- @occurs.interval.should == 1
60
- end
61
-
62
- it "should start at 5pm" do
63
- @occurs.start_time.should == "17:00:00"
64
- end
65
-
66
- it "should have a start date" do
67
- @occurs.start_date.should_not be_nil
68
- end
69
-
70
- it "should not have an end date" do
71
- @occurs.end_date.should be_nil
72
- end
73
- end
74
-
75
-
76
- describe "A day monthly occurrence" do
77
- before(:all) do
78
- @n = Nickel.query "drink specials on the second thursday of every month"
79
- @occurs = @n.occurrences.first
80
- end
81
-
82
- it "should have a message" do
83
- @n.message.should == "drink specials"
84
- end
85
-
86
- it "should be day monthly" do
87
- @occurs.type.should == "daymonthly"
88
- end
89
-
90
- it "should occur on second thursday of every month" do
91
- @occurs.week_of_month.should == 2
92
- @occurs.day_of_week.should == "thu"
93
- end
94
-
95
- it "should occur once per month" do
96
- @occurs.interval.should == 1
97
- end
98
- end
99
-
100
-
101
-
102
- describe "A date monthly occurrence" do
103
- before(:all) do
104
- @n = Nickel.query "pay credit card every month on the 22nd"
105
- @occurs = @n.occurrences.first
106
- end
107
-
108
- it "should have a message" do
109
- @n.message.should == "pay credit card"
110
- end
111
-
112
- it "should be date monthly" do
113
- @occurs.type.should == "datemonthly"
114
- end
115
-
116
- it "should occur on the 22nd of every month" do
117
- @occurs.date_of_month.should == 22
118
- end
119
-
120
- it "should occur once per month" do
121
- @occurs.interval.should == 1
122
- end
123
- end
124
-
125
-
126
- describe "Multiple occurrences" do
127
- before(:all) do
128
- @n = Nickel.query "band meeting every monday and wednesday at 2pm"
129
- end
130
-
131
- it "should have a message" do
132
- @n.message.should == "band meeting"
133
- end
134
-
135
- it "should have two occurrences" do
136
- @n.occurrences.size.should == 2
137
- end
138
-
139
- it "should occur on mondays and wednesdays" do
140
- days = @n.occurrences.collect {|occ| occ.day_of_week}
141
- days.include?("mon").should be_true
142
- days.include?("wed").should be_true
143
- days.size.should == 2
144
- end
145
-
146
- it "should occur at 2pm on both days" do
147
- @n.occurrences[0].start_time.should == "14:00:00"
148
- @n.occurrences[1].start_time.should == "14:00:00"
149
- end
150
- end
151
-
152
- describe "Setting current time" do
153
-
154
- it "should occur on a date relative to the current time passed in" do
155
- n = Nickel.query "lunch 3 days from now", DateTime.new(2009,05,28)
156
- n.occurrences.first.start_date.should == "20090531"
157
- end
158
-
159
- it "should raise an error if the current time argument is not a datetime or time object" do
160
- lambda{
161
- Nickel.query "lunch 3 days from now", Date.new(2009,05,28)
162
- }.should raise_error("You must pass in a ruby DateTime or Time class object")
163
- end
164
- end
165
-