rivendell-db 0.0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2139,7 +2139,7 @@ CREATE TABLE `RDAIRPLAY` (
2139
2139
  `LOG2_NEXT_CART` int(10) unsigned DEFAULT '0',
2140
2140
  PRIMARY KEY (`ID`),
2141
2141
  KEY `STATION_IDX` (`STATION`,`INSTANCE`)
2142
- ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
2142
+ ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
2143
2143
  /*!40101 SET character_set_client = @saved_cs_client */;
2144
2144
 
2145
2145
  --
@@ -2833,7 +2833,7 @@ CREATE TABLE `SERVICES` (
2833
2833
  `CLOCK166` char(64) DEFAULT NULL,
2834
2834
  `CLOCK167` char(64) DEFAULT NULL,
2835
2835
  PRIMARY KEY (`NAME`)
2836
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
2836
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
2837
2837
  /*!40101 SET character_set_client = @saved_cs_client */;
2838
2838
 
2839
2839
  --
@@ -2,8 +2,44 @@ class Rivendell::DB::Cut
2
2
  include DataMapper::Resource
3
3
  storage_names[:default] = 'CUTS'
4
4
 
5
+ belongs_to :cart, :child_key => [ :cart_number ], :parent_key => [ :number ]
6
+
5
7
  property :cut_name, String, :key => true
6
8
  property :last_play_datetime, Time
7
9
 
8
- belongs_to :cart, :child_key => [ :cart_number ], :parent_key => [ :number ]
10
+ property :start_datetime, Time
11
+ property :end_datetime, Time
12
+
13
+ property :start_daypart, String
14
+ property :end_daypart, String
15
+
16
+ @@days = %w{sun mon tue wed thu fri sat}.freeze
17
+ def self.days
18
+ @@days
19
+ end
20
+
21
+ days.each do |day|
22
+ property day, Enum['N','Y'], :default => 'Y'
23
+ end
24
+
25
+ def enable_on?(day)
26
+ send(day) == 'Y'
27
+ end
28
+
29
+ def enable_on(day, enabled = true)
30
+ send("#{day}=", enabled ? 'Y' : 'N')
31
+ end
32
+
33
+ def days
34
+ self.class.days.select do |day|
35
+ enable_on? day
36
+ end
37
+ end
38
+
39
+ def days=(days)
40
+ self.class.days.each do |day|
41
+ enable_on day, days.include?(day)
42
+ end
43
+ end
44
+
9
45
  end
@@ -1,5 +1,5 @@
1
1
  module Rivendell
2
2
  module DB
3
- VERSION = "0.0.1"
3
+ VERSION = "0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rivendell::DB::Cut do
4
+
5
+ ALL_DAYS = %w{sun mon tue wed thu fri sat}.freeze
6
+
7
+ describe ".days" do
8
+ described_class.days.should == ALL_DAYS
9
+ end
10
+
11
+ describe "enable_on?" do
12
+ ALL_DAYS.each do |day|
13
+ it "should be true when #{day} is Y" do
14
+ subject.send "#{day}=", 'Y'
15
+ subject.should be_enable_on(day)
16
+ end
17
+
18
+ it "should be false when #{day} is N" do
19
+ subject.send "#{day}=", 'N'
20
+ subject.should_not be_enable_on(day)
21
+ end
22
+ end
23
+ end
24
+
25
+ describe "#days" do
26
+ ALL_DAYS.each do |day|
27
+ it "should contain #{day} when enabled on this day" do
28
+ subject.enable_on(day)
29
+ subject.days.should include(day)
30
+ end
31
+
32
+ it "should not contain #{day} when disabled on this day" do
33
+ subject.enable_on(day, false)
34
+ subject.days.should_not include(day)
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#days=" do
40
+ ALL_DAYS.each do |day|
41
+ it "should enable #{day} when present in given days" do
42
+ subject.days = [ day ]
43
+ subject.should be_enable_on(day)
44
+ end
45
+
46
+ it "should not contain #{day} when disabled on this day" do
47
+ subject.days = ALL_DAYS - [day]
48
+ subject.should_not be_enable_on(day)
49
+ end
50
+ end
51
+ end
52
+
53
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rivendell-db
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
8
+ - 2
9
+ version: "0.2"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Alban Peignier
@@ -16,11 +15,10 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2013-03-16 00:00:00 Z
18
+ date: 2013-12-12 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- version_requirements: &id001 !ruby/object:Gem::Requirement
21
+ requirement: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
26
24
  - - ">="
@@ -29,12 +27,12 @@ dependencies:
29
27
  segments:
30
28
  - 0
31
29
  version: "0"
32
- requirement: *id001
33
- type: :runtime
30
+ prerelease: false
34
31
  name: dm-core
32
+ type: :runtime
33
+ version_requirements: *id001
35
34
  - !ruby/object:Gem::Dependency
36
- prerelease: false
37
- version_requirements: &id002 !ruby/object:Gem::Requirement
35
+ requirement: &id002 !ruby/object:Gem::Requirement
38
36
  none: false
39
37
  requirements:
40
38
  - - ">="
@@ -43,12 +41,12 @@ dependencies:
43
41
  segments:
44
42
  - 0
45
43
  version: "0"
46
- requirement: *id002
47
- type: :runtime
44
+ prerelease: false
48
45
  name: dm-mysql-adapter
46
+ type: :runtime
47
+ version_requirements: *id002
49
48
  - !ruby/object:Gem::Dependency
50
- prerelease: false
51
- version_requirements: &id003 !ruby/object:Gem::Requirement
49
+ requirement: &id003 !ruby/object:Gem::Requirement
52
50
  none: false
53
51
  requirements:
54
52
  - - ">="
@@ -57,12 +55,12 @@ dependencies:
57
55
  segments:
58
56
  - 0
59
57
  version: "0"
60
- requirement: *id003
61
- type: :runtime
58
+ prerelease: false
62
59
  name: dm-serializer
60
+ type: :runtime
61
+ version_requirements: *id003
63
62
  - !ruby/object:Gem::Dependency
64
- prerelease: false
65
- version_requirements: &id004 !ruby/object:Gem::Requirement
63
+ requirement: &id004 !ruby/object:Gem::Requirement
66
64
  none: false
67
65
  requirements:
68
66
  - - ">="
@@ -71,12 +69,12 @@ dependencies:
71
69
  segments:
72
70
  - 0
73
71
  version: "0"
74
- requirement: *id004
75
- type: :runtime
72
+ prerelease: false
76
73
  name: dm-types
74
+ type: :runtime
75
+ version_requirements: *id004
77
76
  - !ruby/object:Gem::Dependency
78
- prerelease: false
79
- version_requirements: &id005 !ruby/object:Gem::Requirement
77
+ requirement: &id005 !ruby/object:Gem::Requirement
80
78
  none: false
81
79
  requirements:
82
80
  - - ">="
@@ -85,12 +83,12 @@ dependencies:
85
83
  segments:
86
84
  - 0
87
85
  version: "0"
88
- requirement: *id005
89
- type: :runtime
86
+ prerelease: false
90
87
  name: dm-validations
88
+ type: :runtime
89
+ version_requirements: *id005
91
90
  - !ruby/object:Gem::Dependency
92
- prerelease: false
93
- version_requirements: &id006 !ruby/object:Gem::Requirement
91
+ requirement: &id006 !ruby/object:Gem::Requirement
94
92
  none: false
95
93
  requirements:
96
94
  - - ">="
@@ -99,12 +97,12 @@ dependencies:
99
97
  segments:
100
98
  - 0
101
99
  version: "0"
102
- requirement: *id006
103
- type: :development
100
+ prerelease: false
104
101
  name: simplecov
102
+ type: :development
103
+ version_requirements: *id006
105
104
  - !ruby/object:Gem::Dependency
106
- prerelease: false
107
- version_requirements: &id007 !ruby/object:Gem::Requirement
105
+ requirement: &id007 !ruby/object:Gem::Requirement
108
106
  none: false
109
107
  requirements:
110
108
  - - ">="
@@ -113,12 +111,12 @@ dependencies:
113
111
  segments:
114
112
  - 0
115
113
  version: "0"
116
- requirement: *id007
117
- type: :development
114
+ prerelease: false
118
115
  name: rspec
116
+ type: :development
117
+ version_requirements: *id007
119
118
  - !ruby/object:Gem::Dependency
120
- prerelease: false
121
- version_requirements: &id008 !ruby/object:Gem::Requirement
119
+ requirement: &id008 !ruby/object:Gem::Requirement
122
120
  none: false
123
121
  requirements:
124
122
  - - ">="
@@ -127,12 +125,12 @@ dependencies:
127
125
  segments:
128
126
  - 0
129
127
  version: "0"
130
- requirement: *id008
131
- type: :development
128
+ prerelease: false
132
129
  name: guard
130
+ type: :development
131
+ version_requirements: *id008
133
132
  - !ruby/object:Gem::Dependency
134
- prerelease: false
135
- version_requirements: &id009 !ruby/object:Gem::Requirement
133
+ requirement: &id009 !ruby/object:Gem::Requirement
136
134
  none: false
137
135
  requirements:
138
136
  - - ">="
@@ -141,12 +139,12 @@ dependencies:
141
139
  segments:
142
140
  - 0
143
141
  version: "0"
144
- requirement: *id009
145
- type: :development
142
+ prerelease: false
146
143
  name: guard-rspec
144
+ type: :development
145
+ version_requirements: *id009
147
146
  - !ruby/object:Gem::Dependency
148
- prerelease: false
149
- version_requirements: &id010 !ruby/object:Gem::Requirement
147
+ requirement: &id010 !ruby/object:Gem::Requirement
150
148
  none: false
151
149
  requirements:
152
150
  - - ">="
@@ -155,12 +153,12 @@ dependencies:
155
153
  segments:
156
154
  - 0
157
155
  version: "0"
158
- requirement: *id010
159
- type: :development
156
+ prerelease: false
160
157
  name: rake
158
+ type: :development
159
+ version_requirements: *id010
161
160
  - !ruby/object:Gem::Dependency
162
- prerelease: false
163
- version_requirements: &id011 !ruby/object:Gem::Requirement
161
+ requirement: &id011 !ruby/object:Gem::Requirement
164
162
  none: false
165
163
  requirements:
166
164
  - - ">="
@@ -169,12 +167,12 @@ dependencies:
169
167
  segments:
170
168
  - 0
171
169
  version: "0"
172
- requirement: *id011
173
- type: :development
170
+ prerelease: false
174
171
  name: dm-transactions
172
+ type: :development
173
+ version_requirements: *id011
175
174
  - !ruby/object:Gem::Dependency
176
- prerelease: false
177
- version_requirements: &id012 !ruby/object:Gem::Requirement
175
+ requirement: &id012 !ruby/object:Gem::Requirement
178
176
  none: false
179
177
  requirements:
180
178
  - - ">="
@@ -183,9 +181,10 @@ dependencies:
183
181
  segments:
184
182
  - 0
185
183
  version: "0"
186
- requirement: *id012
187
- type: :development
184
+ prerelease: false
188
185
  name: rdoc
186
+ type: :development
187
+ version_requirements: *id012
189
188
  description: Rivendell database mapping
190
189
  email:
191
190
  - alban@tryphon.eu
@@ -213,6 +212,7 @@ files:
213
212
  - lib/rivendell/db/version.rb
214
213
  - rivendell-db.gemspec
215
214
  - spec/rivendell/db/cart_spec.rb
215
+ - spec/rivendell/db/cut_spec.rb
216
216
  - spec/rivendell/db/group_spec.rb
217
217
  - spec/spec_helper.rb
218
218
  - spec/support/db.rb
@@ -254,6 +254,7 @@ specification_version: 3
254
254
  summary: Access to Rivendell database
255
255
  test_files:
256
256
  - spec/rivendell/db/cart_spec.rb
257
+ - spec/rivendell/db/cut_spec.rb
257
258
  - spec/rivendell/db/group_spec.rb
258
259
  - spec/spec_helper.rb
259
260
  - spec/support/db.rb