temporal_object 0.0.1.alpha1-x86-linux

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.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *~
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in temporal_object.gemspec
4
+
5
+ gemspec
6
+
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ Temporal Object
2
+ ===============
3
+
4
+ This is a first stab at creating a RubyGem to implement Martin Fowler's "Temporal Objects" paradigm.
5
+
6
+ So far there are time comparators. TemporalObject::RelativeTime just inherits from DateTime (for now).
7
+
8
+ IT IS NOT YET READY FOR PRIME TIME! Do not use.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ module TemporalObject
2
+ VERSION = "0.0.1.alpha1"
3
+ end
@@ -0,0 +1,93 @@
1
+ #require "temporal_object/version"
2
+
3
+ module TemporalObject
4
+
5
+ require 'date'
6
+
7
+ # write specs for this
8
+ class TimeSpanRelation
9
+
10
+ # for RrelativeTimeSpan objects a,b:
11
+
12
+ # a is before b (gap between)
13
+ # a is after b (gap between)
14
+
15
+ # a starting as b ending (before and touching))
16
+ # a ending as b starting (after and touching)
17
+
18
+ # a starting with but ending before b
19
+ # a starting with but ending after b
20
+
21
+ # a == b
22
+
23
+ # a starting after but ending before b
24
+ # a starting after but ending with b
25
+ # a starting after but ending after b
26
+
27
+ # a starting before but ending after b
28
+ # a starting after and ending before b
29
+
30
+ # a starting before b and ending before b
31
+ # a starting after and ending after b
32
+
33
+ # a starting after b but ending with b
34
+ # a starting before but ending with b
35
+
36
+
37
+ end
38
+
39
+
40
+ class RelativeTimeSpan
41
+
42
+ attr_accessor :starting, :ending # RelativeTime objects
43
+
44
+
45
+ def starting_before?(b) #+1
46
+ starting < b.starting
47
+ end
48
+
49
+ def starting_after?(b) #-2
50
+ starting > b.starting
51
+ end
52
+
53
+ def starting_with?(b) #-3
54
+ starting == b.starting
55
+ end
56
+
57
+ def ending_before?(b) #-5
58
+ ending < b.ending
59
+ end
60
+
61
+ def ending_after?(b) #-6
62
+ ending > b.ending
63
+ end
64
+
65
+ def ending_with?(b) #+4
66
+ ending == b.ending
67
+ end
68
+
69
+ def ending_before_other_starting?(b) #-7
70
+ ending < b.starting
71
+ end
72
+
73
+ def ending_as_other_starting?(b) #-8
74
+ ending == b.starting
75
+ end
76
+
77
+ def starting_after_other_ending?(b) #-9
78
+ starting > b.ending
79
+ end
80
+
81
+ def starting_as_other_ending?(b) #-10
82
+ starting == b.ending
83
+ end
84
+
85
+ end
86
+
87
+ # first implementation is just as DateTime; later add fuzzy time
88
+ class RelativeTime < DateTime
89
+ end
90
+
91
+
92
+
93
+ end
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'temporal_object'
6
+
7
+ require 'bundler/setup'
8
+ require 'rspec'
9
+ require 'rspec/autorun'
10
+
11
+
12
+
13
+
14
+ #RSpec.configure do |config|
15
+ #
16
+ #end
17
+
@@ -0,0 +1,83 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
2
+
3
+ describe "TemporalObject" do
4
+
5
+ context "RelativeTimeSpan" do
6
+
7
+ before (:each) do
8
+ @alpha = TemporalObject::RelativeTimeSpan.new
9
+ @alpha.starting = TemporalObject::RelativeTime.now - 1000
10
+ @alpha.ending = TemporalObject::RelativeTime.now
11
+ end
12
+
13
+ context "instance methods" do
14
+
15
+ context "comparators" do
16
+
17
+ context "same ending time, alpha starts before beta" do
18
+
19
+ before (:each) do
20
+ @beta = TemporalObject::RelativeTimeSpan.new
21
+ @beta.starting = @alpha.starting + 10
22
+ @beta.ending = @alpha.ending
23
+ end
24
+
25
+ context "alpha should be" do
26
+
27
+
28
+ it "starting before beta" do #+1
29
+ @alpha.should be_starting_before(@beta)
30
+ end
31
+
32
+
33
+ it "ending with beta" do #+4
34
+ @alpha.should be_ending_with(@beta)
35
+ end
36
+
37
+ end
38
+
39
+ context "alpha should not be" do
40
+
41
+ it "starting after beta" do
42
+ @alpha.should_not be_starting_after(@beta) #-2
43
+ end
44
+
45
+ it "starting with beta" do #-3
46
+ @alpha.should_not be_starting_with(@beta)
47
+ end
48
+
49
+ it "ending before beta" do #-5
50
+ @alpha.should_not be_ending_before(@beta)
51
+ end
52
+
53
+ it "ending after beta" do #-6
54
+ @alpha.should_not be_ending_after(@beta)
55
+ end
56
+
57
+ it "ending before beta is starting" do #-7
58
+ @alpha.should_not be_ending_before_other_starting(@beta)
59
+ end
60
+
61
+ it "ending as beta is starting" do #-8
62
+ @alpha.should_not be_ending_as_other_starting(@beta)
63
+ end
64
+
65
+ it "starting after beta ending" do #-9
66
+ @alpha.should_not be_starting_after_other_ending(@beta)
67
+ end
68
+
69
+ it "starting as beta is ending" do #-10
70
+ @alpha.should_not be_starting_as_other_ending(@beta)
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+
79
+ end
80
+
81
+ end
82
+
83
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "temporal_object/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "temporal_object"
7
+ s.platform = Gem::Platform::CURRENT
8
+ s.version = TemporalObject::VERSION
9
+ s.authors = ["Craig A. Cook"]
10
+ s.email = ["craig.a.cook@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Temporal Object Design Pattern}
13
+ s.description = %q{Martin Fowler's Temporal Object Pattern.}
14
+ s.license = 'MIT'
15
+
16
+ s.rubyforge_project = "temporal_object"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ # specify any dependencies here; for example:
24
+ s.add_development_dependency "rspec"
25
+ # s.add_runtime_dependency "rest-client"
26
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: temporal_object
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha1
5
+ prerelease: 6
6
+ platform: x86-linux
7
+ authors:
8
+ - Craig A. Cook
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &83180060 !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: *83180060
25
+ description: Martin Fowler's Temporal Object Pattern.
26
+ email:
27
+ - craig.a.cook@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.md
35
+ - Rakefile
36
+ - lib/temporal_object.rb
37
+ - lib/temporal_object/version.rb
38
+ - spec/spec_helper.rb
39
+ - spec/temporal_object/temporal_object_spec.rb
40
+ - temporal_object.gemspec
41
+ homepage: ''
42
+ licenses:
43
+ - MIT
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>'
58
+ - !ruby/object:Gem::Version
59
+ version: 1.3.1
60
+ requirements: []
61
+ rubyforge_project: temporal_object
62
+ rubygems_version: 1.8.12
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Temporal Object Design Pattern
66
+ test_files: []