rivendell-import 1.01 → 1.02

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rivendell-import (1.01)
4
+ rivendell-import (1.02)
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.8)
13
+ rivendell-api (~> 0.9)
14
14
  rivendell-db (~> 0.3)
15
15
  sinatra
16
16
  sqlite3
@@ -33,9 +33,9 @@ GEM
33
33
  activesupport (3.2.21)
34
34
  i18n (~> 0.6, >= 0.6.4)
35
35
  multi_json (~> 1.0)
36
- addressable (2.3.6)
36
+ addressable (2.3.7)
37
37
  arel (3.0.3)
38
- bcrypt (3.1.9)
38
+ bcrypt (3.1.10)
39
39
  bcrypt-ruby (3.1.5)
40
40
  bcrypt (>= 3.1.3)
41
41
  builder (3.0.4)
@@ -52,7 +52,7 @@ GEM
52
52
  multi_json (>= 1.7.5, < 2.0)
53
53
  multi_test (>= 0.1.1)
54
54
  daemons (1.1.9)
55
- data_objects (0.10.14)
55
+ data_objects (0.10.15)
56
56
  addressable (~> 2.1)
57
57
  database_cleaner (1.3.0)
58
58
  diff-lcs (1.2.5)
@@ -80,8 +80,8 @@ GEM
80
80
  uuidtools (~> 2.1)
81
81
  dm-validations (1.2.0)
82
82
  dm-core (~> 1.2.0)
83
- do_mysql (0.10.14)
84
- data_objects (= 0.10.14)
83
+ do_mysql (0.10.15)
84
+ data_objects (= 0.10.15)
85
85
  docile (1.1.5)
86
86
  fastercsv (1.5.5)
87
87
  ffi (1.9.5)
@@ -107,9 +107,9 @@ GEM
107
107
  httparty (0.11.0)
108
108
  multi_json (~> 1.0)
109
109
  multi_xml (>= 0.5.2)
110
- i18n (0.6.11)
110
+ i18n (0.7.0)
111
111
  json (1.8.1)
112
- json_pure (1.8.1)
112
+ json_pure (1.8.2)
113
113
  libnotify (0.8.3)
114
114
  ffi (>= 1.0.11)
115
115
  listen (1.3.1)
@@ -134,7 +134,7 @@ GEM
134
134
  coderay (~> 1.1.0)
135
135
  method_source (~> 0.8.1)
136
136
  slop (~> 3.4)
137
- rack (1.5.2)
137
+ rack (1.6.0)
138
138
  rack-protection (1.5.3)
139
139
  rack
140
140
  rake (10.3.2)
@@ -145,11 +145,11 @@ GEM
145
145
  ffi (>= 0.5.0)
146
146
  rdoc (4.1.2)
147
147
  json (~> 1.4)
148
- rivendell-api (0.8)
148
+ rivendell-api (0.9)
149
149
  activesupport
150
150
  httmultiparty
151
151
  null_logger
152
- rivendell-db (0.3)
152
+ rivendell-db (0.4)
153
153
  dm-core
154
154
  dm-mysql-adapter
155
155
  dm-serializer
@@ -185,7 +185,7 @@ GEM
185
185
  thor (0.19.1)
186
186
  tilt (1.4.1)
187
187
  trollop (2.1.1)
188
- tzinfo (0.3.42)
188
+ tzinfo (0.3.43)
189
189
  uuidtools (2.1.5)
190
190
  will_paginate (3.0.7)
191
191
 
@@ -10,7 +10,7 @@ module Rivendell::Import
10
10
 
11
11
  def attributes
12
12
  attributes = {}
13
- %w{number group clear_cuts title default_title scheduler_codes import_options}.each do |attribute|
13
+ %w{number group clear_cuts title default_title scheduler_codes artist album import_options}.each do |attribute|
14
14
  value = send attribute
15
15
  attributes[attribute] = value if value.present?
16
16
  end
@@ -32,7 +32,7 @@ module Rivendell::Import
32
32
 
33
33
  delegate :blank?, :to => :attributes
34
34
 
35
- attr_accessor :number, :group, :title, :default_title, :scheduler_codes
35
+ attr_accessor :number, :group, :title, :default_title, :scheduler_codes, :artist, :album
36
36
  attr_reader :task
37
37
 
38
38
  def initialize(task = nil)
@@ -74,7 +74,7 @@ module Rivendell::Import
74
74
  def initialize(cart)
75
75
  @cart = cart
76
76
  end
77
- delegate :number, :title, :default_title, :scheduler_codes, :to => :cart
77
+ delegate :number, :title, :default_title, :scheduler_codes, :artist, :album, :to => :cart
78
78
 
79
79
  def empty_title?(title)
80
80
  [ nil, "", "[new cart]" ].include? title
@@ -120,6 +120,8 @@ module Rivendell::Import
120
120
  def attributes
121
121
  {}.tap do |attributes|
122
122
  attributes[:title] = title_with_default if title_with_default
123
+ attributes[:artist] = artist if artist
124
+ attributes[:album] = album if album
123
125
  end
124
126
  end
125
127
 
@@ -138,10 +140,12 @@ module Rivendell::Import
138
140
  def update!
139
141
  Database.init
140
142
 
141
- if title_with_default or not scheduler_codes.empty?
143
+ if title_with_default or artist or album or not scheduler_codes.empty?
142
144
  Rivendell::Import.logger.debug "Update Cart by DB"
143
145
  current_cart.title = title_with_default if title_with_default
144
146
  current_cart.scheduler_codes = scheduler_codes unless scheduler_codes.empty?
147
+ current_cart.artist = artist if artist
148
+ current_cart.album = album if album
145
149
  current_cart.save
146
150
  end
147
151
  end
@@ -1,5 +1,5 @@
1
1
  module Rivendell
2
2
  module Import
3
- VERSION = "1.01"
3
+ VERSION = "1.02"
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.add_runtime_dependency 'httmultiparty'
21
21
  # 0.12.0 requires ruby 1.9.3
22
22
  gem.add_runtime_dependency 'httparty', '0.11.0'
23
- gem.add_runtime_dependency 'rivendell-api', '~> 0.8'
23
+ gem.add_runtime_dependency 'rivendell-api', '~> 0.9'
24
24
  gem.add_runtime_dependency 'trollop'
25
25
  gem.add_runtime_dependency 'activerecord', '~> 3.2.8'
26
26
  gem.add_runtime_dependency 'activesupport', '~> 3.2.8'
@@ -192,7 +192,7 @@ describe Rivendell::Import::Cart do
192
192
  subject.scheduler_codes << "dummy"
193
193
  subject.attributes["scheduler_codes"].should == ["dummy"]
194
194
  end
195
-
195
+
196
196
  end
197
197
 
198
198
  describe "#to_json" do
@@ -218,12 +218,12 @@ describe Rivendell::Import::Cart do
218
218
  it "should contain ApiUpdater" do
219
219
  subject.updaters.should include(Rivendell::Import::Cart::ApiUpdater)
220
220
  end
221
-
221
+
222
222
  it "should not contain ApiUpdater if scheduler codes is defined" do
223
223
  subject.scheduler_codes << "dummy"
224
224
  subject.updaters.should_not include(Rivendell::Import::Cart::ApiUpdater)
225
225
  end
226
-
226
+
227
227
  it "should contain DbUpdater if Database is enabled" do
228
228
  Rivendell::Import::Database.stub :enabled? => true
229
229
  subject.updaters.should include(Rivendell::Import::Cart::DbUpdater)
@@ -233,7 +233,7 @@ describe Rivendell::Import::Cart do
233
233
  Rivendell::Import::Database.stub :enabled? => false
234
234
  subject.updaters.should_not include(Rivendell::Import::Cart::DbUpdater)
235
235
  end
236
-
236
+
237
237
  end
238
238
 
239
239
  describe "#update" do
@@ -256,9 +256,9 @@ describe Rivendell::Import::Cart do
256
256
  subject.stub :updaters => []
257
257
  subject.update.should be_false
258
258
  end
259
-
259
+
260
260
  end
261
-
261
+
262
262
  end
263
263
 
264
264
  describe Rivendell::Import::Cart::Updater do
@@ -299,7 +299,7 @@ describe Rivendell::Import::Cart::Updater do
299
299
  subject.stub :update! => false
300
300
  subject.update.should be_false
301
301
  end
302
-
302
+
303
303
  end
304
304
 
305
305
  describe "#title_with_default" do
@@ -317,7 +317,7 @@ describe Rivendell::Import::Cart::Updater do
317
317
  context "when default title is defined" do
318
318
 
319
319
  before { cart.default_title = "dummy" }
320
-
320
+
321
321
  it "should default title if current title is empty" do
322
322
  subject.stub current_title: "[new cart]"
323
323
  subject.title_with_default.should == cart.default_title
@@ -329,9 +329,9 @@ describe Rivendell::Import::Cart::Updater do
329
329
  end
330
330
 
331
331
  end
332
-
332
+
333
333
  end
334
-
334
+
335
335
  end
336
336
 
337
337
  describe Rivendell::Import::Cart::ApiUpdater do
@@ -353,7 +353,7 @@ describe Rivendell::Import::Cart::ApiUpdater do
353
353
  xport.should_receive(:list_cart).with(cart.number).and_return(xport_cart)
354
354
  subject.current_title.should == xport_cart.title
355
355
  end
356
-
356
+
357
357
  end
358
358
 
359
359
  describe "#attributes" do
@@ -367,7 +367,27 @@ describe Rivendell::Import::Cart::ApiUpdater do
367
367
  subject.stub title_with_default: nil
368
368
  subject.attributes.should == {}
369
369
  end
370
-
370
+
371
+ it "should contain artist if defined" do
372
+ cart.artist = "dummy"
373
+ subject.attributes[:artist].should == subject.artist
374
+ end
375
+
376
+ it "should not contain artist if not defined" do
377
+ cart.artist = nil
378
+ subject.attributes.should_not have_key(:artist)
379
+ end
380
+
381
+ it "should contain album if defined" do
382
+ cart.album = "dummy"
383
+ subject.attributes[:album].should == subject.album
384
+ end
385
+
386
+ it "should not contain album if not defined" do
387
+ cart.album = nil
388
+ subject.attributes.should_not have_key(:album)
389
+ end
390
+
371
391
  end
372
392
 
373
393
  describe "#update!" do
@@ -379,7 +399,7 @@ describe Rivendell::Import::Cart::ApiUpdater do
379
399
  xport.should_receive(:edit_cart).with(cart.number, subject.attributes)
380
400
  subject.update!
381
401
  end
382
-
402
+
383
403
  end
384
404
 
385
405
  context "when attributes is empty" do
@@ -389,11 +409,11 @@ describe Rivendell::Import::Cart::ApiUpdater do
389
409
  xport.should_not_receive(:edit_cart)
390
410
  subject.update!.should be_true
391
411
  end
392
-
412
+
393
413
  end
394
-
414
+
395
415
  end
396
-
416
+
397
417
  end
398
418
 
399
419
  describe Rivendell::Import::Cart::DbUpdater do
@@ -416,7 +436,7 @@ describe Rivendell::Import::Cart::DbUpdater do
416
436
  Rivendell::DB::Cart.should_receive(:get).with(cart.number).and_return(db_cart)
417
437
  subject.current_cart.should == db_cart
418
438
  end
419
-
439
+
420
440
  end
421
441
 
422
442
  describe "#current_title" do
@@ -425,7 +445,7 @@ describe Rivendell::Import::Cart::DbUpdater do
425
445
  db_cart.stub title: "dummy"
426
446
  subject.current_title.should == db_cart.title
427
447
  end
428
-
448
+
429
449
  end
430
450
 
431
451
  describe "#update!" do
@@ -441,12 +461,24 @@ describe Rivendell::Import::Cart::DbUpdater do
441
461
  db_cart.title.should == subject.title_with_default
442
462
  end
443
463
 
464
+ it "should use artist as Cart artist" do
465
+ subject.stub artist: "dummy"
466
+ subject.update!
467
+ db_cart.artist.should == subject.artist
468
+ end
469
+
470
+ it "should use album as Cart album" do
471
+ subject.stub album: "dummy"
472
+ subject.update!
473
+ db_cart.album.should == subject.album
474
+ end
475
+
444
476
  it "should define scheduler_codes" do
445
477
  subject.stub scheduler_codes: ["dummy"]
446
478
  subject.update!
447
479
  db_cart.scheduler_codes.should == subject.scheduler_codes
448
480
  end
449
-
481
+
450
482
  end
451
-
483
+
452
484
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rivendell-import
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.01'
4
+ version: '1.02'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-14 00:00:00.000000000 Z
12
+ date: 2015-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: listen
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '0.8'
69
+ version: '0.9'
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: '0.8'
77
+ version: '0.9'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: trollop
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -503,7 +503,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
503
503
  version: '0'
504
504
  segments:
505
505
  - 0
506
- hash: -1683844090419105726
506
+ hash: 2132046489375508529
507
507
  required_rubygems_version: !ruby/object:Gem::Requirement
508
508
  none: false
509
509
  requirements:
@@ -512,7 +512,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
512
512
  version: '0'
513
513
  segments:
514
514
  - 0
515
- hash: -1683844090419105726
515
+ hash: 2132046489375508529
516
516
  requirements: []
517
517
  rubyforge_project:
518
518
  rubygems_version: 1.8.23