rivendell-import 0.10 → 1.01

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rivendell-import (0.10)
4
+ rivendell-import (1.01)
5
5
  SyslogLogger (~> 2.0)
6
6
  activerecord (~> 3.2.8)
7
7
  activesupport (~> 3.2.8)
@@ -10,7 +10,7 @@ PATH
10
10
  httparty (= 0.11.0)
11
11
  listen (~> 1.3.1)
12
12
  mail
13
- rivendell-api (~> 0.0.5)
13
+ rivendell-api (~> 0.8)
14
14
  rivendell-db (~> 0.3)
15
15
  sinatra
16
16
  sqlite3
@@ -22,20 +22,20 @@ GEM
22
22
  remote: https://rubygems.org/
23
23
  specs:
24
24
  SyslogLogger (2.0)
25
- activemodel (3.2.19)
26
- activesupport (= 3.2.19)
25
+ activemodel (3.2.21)
26
+ activesupport (= 3.2.21)
27
27
  builder (~> 3.0.0)
28
- activerecord (3.2.19)
29
- activemodel (= 3.2.19)
30
- activesupport (= 3.2.19)
28
+ activerecord (3.2.21)
29
+ activemodel (= 3.2.21)
30
+ activesupport (= 3.2.21)
31
31
  arel (~> 3.0.2)
32
32
  tzinfo (~> 0.3.29)
33
- activesupport (3.2.19)
33
+ activesupport (3.2.21)
34
34
  i18n (~> 0.6, >= 0.6.4)
35
35
  multi_json (~> 1.0)
36
36
  addressable (2.3.6)
37
37
  arel (3.0.3)
38
- bcrypt (3.1.7)
38
+ bcrypt (3.1.9)
39
39
  bcrypt-ruby (3.1.5)
40
40
  bcrypt (>= 3.1.3)
41
41
  builder (3.0.4)
@@ -100,7 +100,7 @@ GEM
100
100
  guard-rspec (3.1.0)
101
101
  guard (>= 1.8)
102
102
  rspec (~> 2.13)
103
- httmultiparty (0.3.15)
103
+ httmultiparty (0.3.16)
104
104
  httparty (>= 0.7.3)
105
105
  mimemagic
106
106
  multipart-post
@@ -117,10 +117,10 @@ GEM
117
117
  rb-inotify (>= 0.9)
118
118
  rb-kqueue (>= 0.2)
119
119
  lumberjack (1.0.9)
120
- mail (2.6.1)
120
+ mail (2.6.3)
121
121
  mime-types (>= 1.16, < 3)
122
122
  method_source (0.8.2)
123
- mime-types (2.3)
123
+ mime-types (2.4.3)
124
124
  mimemagic (0.2.1)
125
125
  multi_json (1.10.1)
126
126
  multi_test (0.1.1)
@@ -145,7 +145,7 @@ GEM
145
145
  ffi (>= 0.5.0)
146
146
  rdoc (4.1.2)
147
147
  json (~> 1.4)
148
- rivendell-api (0.0.5)
148
+ rivendell-api (0.8)
149
149
  activesupport
150
150
  httmultiparty
151
151
  null_logger
@@ -175,7 +175,7 @@ GEM
175
175
  rack-protection (~> 1.4)
176
176
  tilt (~> 1.3, >= 1.3.4)
177
177
  slop (3.6.0)
178
- sqlite3 (1.3.9)
178
+ sqlite3 (1.3.10)
179
179
  sshkit (1.5.1)
180
180
  colorize
181
181
  net-scp (>= 1.1.2)
@@ -184,8 +184,8 @@ GEM
184
184
  taglib-ruby (0.7.0)
185
185
  thor (0.19.1)
186
186
  tilt (1.4.1)
187
- trollop (2.0)
188
- tzinfo (0.3.41)
187
+ trollop (2.1.1)
188
+ tzinfo (0.3.42)
189
189
  uuidtools (2.1.5)
190
190
  will_paginate (3.0.7)
191
191
 
data/examples/config.rb CHANGED
@@ -41,6 +41,7 @@ Rivendell::Import.config do |config|
41
41
 
42
42
  cart.clear_cuts!
43
43
  cart.find_by_title name
44
+ cart.cut.description = file.basename
44
45
  end
45
46
 
46
47
  cart.group ||= "TEST"
@@ -48,6 +49,6 @@ Rivendell::Import.config do |config|
48
49
  # To delete file when task is completed
49
50
  #task.delete_file!
50
51
 
51
- notify 'alban@tryphon.eu', :by => :email
52
+ # notify 'alban@tryphon.eu', :by => :email
52
53
  end
53
54
  end
@@ -1,9 +1,11 @@
1
1
  require "rivendell/import/version"
2
2
 
3
3
  require "null_logger"
4
+ require "active_support/core_ext/enumerable"
5
+ require "active_support/core_ext/hash/except"
4
6
  require "active_support/core_ext/module/attribute_accessors"
5
7
  require "active_support/core_ext/module/delegation"
6
- require "active_support/core_ext/enumerable"
8
+ require "active_support/hash_with_indifferent_access"
7
9
  require 'taglib'
8
10
 
9
11
  require "rivendell/import/config"
@@ -24,6 +24,23 @@ module Rivendell::Import
24
24
  tasks.to_json
25
25
  end
26
26
 
27
+ def config_loader
28
+ settings.config_loader
29
+ end
30
+
31
+ def edit_config
32
+ erb :config, :locals => { :config => config_loader.current_config }
33
+ end
34
+
35
+ get '/config' do
36
+ edit_config
37
+ end
38
+
39
+ post '/config' do
40
+ config_loader.save params["config"]
41
+ edit_config
42
+ end
43
+
27
44
  def tasks
28
45
  Task.order("updated_at DESC")
29
46
  end
@@ -70,7 +70,7 @@ module Rivendell::Import
70
70
  class Updater
71
71
 
72
72
  attr_accessor :cart
73
-
73
+
74
74
  def initialize(cart)
75
75
  @cart = cart
76
76
  end
@@ -88,7 +88,7 @@ module Rivendell::Import
88
88
  default_title if default_title && empty_title?(current_title)
89
89
  end
90
90
  end
91
-
91
+
92
92
  def update
93
93
  begin
94
94
  update!
@@ -140,8 +140,8 @@ module Rivendell::Import
140
140
 
141
141
  if title_with_default or not scheduler_codes.empty?
142
142
  Rivendell::Import.logger.debug "Update Cart by DB"
143
- current_cart.title = title_with_default
144
- current_cart.scheduler_codes = scheduler_codes
143
+ current_cart.title = title_with_default if title_with_default
144
+ current_cart.scheduler_codes = scheduler_codes unless scheduler_codes.empty?
145
145
  current_cart.save
146
146
  end
147
147
  end
@@ -167,7 +167,7 @@ module Rivendell::Import
167
167
  cut.create
168
168
 
169
169
  Rivendell::Import.logger.debug "Import #{file.path} in Cut #{cut.number}"
170
- xport.import number, cut.number, file.path, import_options
170
+ xport.import number, cut.number, file.path, import_options.symbolize_keys
171
171
  cut.update
172
172
  end
173
173
 
@@ -97,6 +97,7 @@ module Rivendell::Import
97
97
  Rivendell::Import.logger.debug "Start webserver"
98
98
 
99
99
  Thread.new do
100
+ Rivendell::Import::Application.set :config_loader, config_loader
100
101
  Rivendell::Import::Application.run!
101
102
 
102
103
  # FIXME we don't see difference between normal quit and start error (EADDRINUSE, ...)
@@ -106,7 +107,7 @@ module Rivendell::Import
106
107
  end
107
108
 
108
109
  def config_loader
109
- ConfigLoader.new(config_file, listen_mode?)
110
+ @config_loader = ConfigLoader.new(config_file, listen_mode?)
110
111
  end
111
112
 
112
113
  def daemonize
@@ -13,6 +13,14 @@ module Rivendell::Import
13
13
  Kernel.load file
14
14
  end
15
15
 
16
+ def current_config
17
+ ::File.read file
18
+ end
19
+
20
+ def save(config)
21
+ ::File.write absolute_path, config
22
+ end
23
+
16
24
  def listen_file
17
25
  return unless auto_reload?
18
26
 
@@ -7,6 +7,8 @@ module Rivendell::Import
7
7
  attr_reader :cart
8
8
 
9
9
  attr_accessor :number
10
+ attr_accessor :description, :outcue, :isrc, :isci
11
+
10
12
  attr_accessor :datetime
11
13
  attr_accessor :daypart
12
14
  attr_accessor :days
@@ -24,7 +26,7 @@ module Rivendell::Import
24
26
  end
25
27
 
26
28
  def attributes
27
- %w{datetime daypart days}.inject({}) do |map, attribute|
29
+ %w{description outcue isrc isci datetime daypart days}.inject({}) do |map, attribute|
28
30
  value = send attribute
29
31
  map[attribute] = value if value
30
32
  map
@@ -48,6 +50,14 @@ module Rivendell::Import
48
50
  "%06d_%03d" % [cart.number, number]
49
51
  end
50
52
 
53
+ def api_attributes
54
+ attributes.extract!("description", "outcue", "isrc", "isci").delete_if { |_,v| v.blank? }
55
+ end
56
+
57
+ def api_attributes?
58
+ api_attributes.present?
59
+ end
60
+
51
61
  def db_attributes?
52
62
  [datetime, daypart, days].any? &:present?
53
63
  end
@@ -72,6 +82,10 @@ module Rivendell::Import
72
82
 
73
83
  db_cut.save
74
84
  end
85
+ if api_attributes?
86
+ Rivendell::Import.logger.debug "Change Cut #{number} via API #{api_attributes.inspect}"
87
+ xport.edit_cut cart.number, number, api_attributes
88
+ end
75
89
  end
76
90
 
77
91
  def datetime=(datetime)
@@ -0,0 +1,309 @@
1
+ /* BASICS */
2
+
3
+ .CodeMirror {
4
+ /* Set height, width, borders, and global font properties here */
5
+ font-family: monospace;
6
+ height: 300px;
7
+ }
8
+ .CodeMirror-scroll {
9
+ /* Set scrolling behaviour here */
10
+ overflow: auto;
11
+ }
12
+
13
+ /* PADDING */
14
+
15
+ .CodeMirror-lines {
16
+ padding: 4px 0; /* Vertical padding around content */
17
+ }
18
+ .CodeMirror pre {
19
+ padding: 0 4px; /* Horizontal padding of content */
20
+ }
21
+
22
+ .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
23
+ background-color: white; /* The little square between H and V scrollbars */
24
+ }
25
+
26
+ /* GUTTER */
27
+
28
+ .CodeMirror-gutters {
29
+ border-right: 1px solid #ddd;
30
+ background-color: #f7f7f7;
31
+ white-space: nowrap;
32
+ }
33
+ .CodeMirror-linenumbers {}
34
+ .CodeMirror-linenumber {
35
+ padding: 0 3px 0 5px;
36
+ min-width: 20px;
37
+ text-align: right;
38
+ color: #999;
39
+ -moz-box-sizing: content-box;
40
+ box-sizing: content-box;
41
+ }
42
+
43
+ .CodeMirror-guttermarker { color: black; }
44
+ .CodeMirror-guttermarker-subtle { color: #999; }
45
+
46
+ /* CURSOR */
47
+
48
+ .CodeMirror div.CodeMirror-cursor {
49
+ border-left: 1px solid black;
50
+ }
51
+ /* Shown when moving in bi-directional text */
52
+ .CodeMirror div.CodeMirror-secondarycursor {
53
+ border-left: 1px solid silver;
54
+ }
55
+ .CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
56
+ width: auto;
57
+ border: 0;
58
+ background: #7e7;
59
+ }
60
+ .CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursors {
61
+ z-index: 1;
62
+ }
63
+
64
+ .cm-animate-fat-cursor {
65
+ width: auto;
66
+ border: 0;
67
+ -webkit-animation: blink 1.06s steps(1) infinite;
68
+ -moz-animation: blink 1.06s steps(1) infinite;
69
+ animation: blink 1.06s steps(1) infinite;
70
+ }
71
+ @-moz-keyframes blink {
72
+ 0% { background: #7e7; }
73
+ 50% { background: none; }
74
+ 100% { background: #7e7; }
75
+ }
76
+ @-webkit-keyframes blink {
77
+ 0% { background: #7e7; }
78
+ 50% { background: none; }
79
+ 100% { background: #7e7; }
80
+ }
81
+ @keyframes blink {
82
+ 0% { background: #7e7; }
83
+ 50% { background: none; }
84
+ 100% { background: #7e7; }
85
+ }
86
+
87
+ /* Can style cursor different in overwrite (non-insert) mode */
88
+ div.CodeMirror-overwrite div.CodeMirror-cursor {}
89
+
90
+ .cm-tab { display: inline-block; text-decoration: inherit; }
91
+
92
+ .CodeMirror-ruler {
93
+ border-left: 1px solid #ccc;
94
+ position: absolute;
95
+ }
96
+
97
+ /* DEFAULT THEME */
98
+
99
+ .cm-s-default .cm-keyword {color: #708;}
100
+ .cm-s-default .cm-atom {color: #219;}
101
+ .cm-s-default .cm-number {color: #164;}
102
+ .cm-s-default .cm-def {color: #00f;}
103
+ .cm-s-default .cm-variable,
104
+ .cm-s-default .cm-punctuation,
105
+ .cm-s-default .cm-property,
106
+ .cm-s-default .cm-operator {}
107
+ .cm-s-default .cm-variable-2 {color: #05a;}
108
+ .cm-s-default .cm-variable-3 {color: #085;}
109
+ .cm-s-default .cm-comment {color: #a50;}
110
+ .cm-s-default .cm-string {color: #a11;}
111
+ .cm-s-default .cm-string-2 {color: #f50;}
112
+ .cm-s-default .cm-meta {color: #555;}
113
+ .cm-s-default .cm-qualifier {color: #555;}
114
+ .cm-s-default .cm-builtin {color: #30a;}
115
+ .cm-s-default .cm-bracket {color: #997;}
116
+ .cm-s-default .cm-tag {color: #170;}
117
+ .cm-s-default .cm-attribute {color: #00c;}
118
+ .cm-s-default .cm-header {color: blue;}
119
+ .cm-s-default .cm-quote {color: #090;}
120
+ .cm-s-default .cm-hr {color: #999;}
121
+ .cm-s-default .cm-link {color: #00c;}
122
+
123
+ .cm-negative {color: #d44;}
124
+ .cm-positive {color: #292;}
125
+ .cm-header, .cm-strong {font-weight: bold;}
126
+ .cm-em {font-style: italic;}
127
+ .cm-link {text-decoration: underline;}
128
+
129
+ .cm-s-default .cm-error {color: #f00;}
130
+ .cm-invalidchar {color: #f00;}
131
+
132
+ /* Default styles for common addons */
133
+
134
+ div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
135
+ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
136
+ .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
137
+ .CodeMirror-activeline-background {background: #e8f2ff;}
138
+
139
+ /* STOP */
140
+
141
+ /* The rest of this file contains styles related to the mechanics of
142
+ the editor. You probably shouldn't touch them. */
143
+
144
+ .CodeMirror {
145
+ line-height: 1;
146
+ position: relative;
147
+ overflow: hidden;
148
+ background: white;
149
+ color: black;
150
+ }
151
+
152
+ .CodeMirror-scroll {
153
+ /* 30px is the magic margin used to hide the element's real scrollbars */
154
+ /* See overflow: hidden in .CodeMirror */
155
+ margin-bottom: -30px; margin-right: -30px;
156
+ padding-bottom: 30px;
157
+ height: 100%;
158
+ outline: none; /* Prevent dragging from highlighting the element */
159
+ position: relative;
160
+ -moz-box-sizing: content-box;
161
+ box-sizing: content-box;
162
+ }
163
+ .CodeMirror-sizer {
164
+ position: relative;
165
+ border-right: 30px solid transparent;
166
+ -moz-box-sizing: content-box;
167
+ box-sizing: content-box;
168
+ }
169
+
170
+ /* The fake, visible scrollbars. Used to force redraw during scrolling
171
+ before actuall scrolling happens, thus preventing shaking and
172
+ flickering artifacts. */
173
+ .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
174
+ position: absolute;
175
+ z-index: 6;
176
+ display: none;
177
+ }
178
+ .CodeMirror-vscrollbar {
179
+ right: 0; top: 0;
180
+ overflow-x: hidden;
181
+ overflow-y: scroll;
182
+ }
183
+ .CodeMirror-hscrollbar {
184
+ bottom: 0; left: 0;
185
+ overflow-y: hidden;
186
+ overflow-x: scroll;
187
+ }
188
+ .CodeMirror-scrollbar-filler {
189
+ right: 0; bottom: 0;
190
+ }
191
+ .CodeMirror-gutter-filler {
192
+ left: 0; bottom: 0;
193
+ }
194
+
195
+ .CodeMirror-gutters {
196
+ position: absolute; left: 0; top: 0;
197
+ padding-bottom: 30px;
198
+ z-index: 3;
199
+ }
200
+ .CodeMirror-gutter {
201
+ white-space: normal;
202
+ height: 100%;
203
+ -moz-box-sizing: content-box;
204
+ box-sizing: content-box;
205
+ padding-bottom: 30px;
206
+ margin-bottom: -32px;
207
+ display: inline-block;
208
+ /* Hack to make IE7 behave */
209
+ *zoom:1;
210
+ *display:inline;
211
+ }
212
+ .CodeMirror-gutter-elt {
213
+ position: absolute;
214
+ cursor: default;
215
+ z-index: 4;
216
+ }
217
+
218
+ .CodeMirror-lines {
219
+ cursor: text;
220
+ min-height: 1px; /* prevents collapsing before first draw */
221
+ }
222
+ .CodeMirror pre {
223
+ /* Reset some styles that the rest of the page might have set */
224
+ -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
225
+ border-width: 0;
226
+ background: transparent;
227
+ font-family: inherit;
228
+ font-size: inherit;
229
+ margin: 0;
230
+ white-space: pre;
231
+ word-wrap: normal;
232
+ line-height: inherit;
233
+ color: inherit;
234
+ z-index: 2;
235
+ position: relative;
236
+ overflow: visible;
237
+ }
238
+ .CodeMirror-wrap pre {
239
+ word-wrap: break-word;
240
+ white-space: pre-wrap;
241
+ word-break: normal;
242
+ }
243
+
244
+ .CodeMirror-linebackground {
245
+ position: absolute;
246
+ left: 0; right: 0; top: 0; bottom: 0;
247
+ z-index: 0;
248
+ }
249
+
250
+ .CodeMirror-linewidget {
251
+ position: relative;
252
+ z-index: 2;
253
+ overflow: auto;
254
+ }
255
+
256
+ .CodeMirror-widget {}
257
+
258
+ .CodeMirror-wrap .CodeMirror-scroll {
259
+ overflow-x: hidden;
260
+ }
261
+
262
+ .CodeMirror-measure {
263
+ position: absolute;
264
+ width: 100%;
265
+ height: 0;
266
+ overflow: hidden;
267
+ visibility: hidden;
268
+ }
269
+ .CodeMirror-measure pre { position: static; }
270
+
271
+ .CodeMirror div.CodeMirror-cursor {
272
+ position: absolute;
273
+ border-right: none;
274
+ width: 0;
275
+ }
276
+
277
+ div.CodeMirror-cursors {
278
+ visibility: hidden;
279
+ position: relative;
280
+ z-index: 3;
281
+ }
282
+ .CodeMirror-focused div.CodeMirror-cursors {
283
+ visibility: visible;
284
+ }
285
+
286
+ .CodeMirror-selected { background: #d9d9d9; }
287
+ .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
288
+ .CodeMirror-crosshair { cursor: crosshair; }
289
+
290
+ .cm-searching {
291
+ background: #ffa;
292
+ background: rgba(255, 255, 0, .4);
293
+ }
294
+
295
+ /* IE7 hack to prevent it from returning funny offsetTops on the spans */
296
+ .CodeMirror span { *vertical-align: text-bottom; }
297
+
298
+ /* Used to force a border model for a node */
299
+ .cm-force-border { padding-right: .1px; }
300
+
301
+ @media print {
302
+ /* Hide the cursor when printing */
303
+ .CodeMirror div.CodeMirror-cursors {
304
+ visibility: hidden;
305
+ }
306
+ }
307
+
308
+ /* Help users use markselection to safely style text background */
309
+ span.CodeMirror-selectedtext { background: none; }