rivendell-import 0.8 → 0.9

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 (0.8)
4
+ rivendell-import (0.9)
5
5
  SyslogLogger (~> 2.0)
6
6
  activerecord (~> 3.2.8)
7
7
  activesupport (~> 3.2.8)
@@ -93,8 +93,9 @@ GEM
93
93
  guard (>= 1.1)
94
94
  rspec (~> 2.11)
95
95
  highline (1.6.16)
96
- httmultiparty (0.3.10)
96
+ httmultiparty (0.3.14)
97
97
  httparty (>= 0.7.3)
98
+ mimemagic
98
99
  multipart-post
99
100
  httparty (0.11.0)
100
101
  multi_json (~> 1.0)
@@ -112,10 +113,11 @@ GEM
112
113
  mime-types (~> 1.16)
113
114
  treetop (~> 1.4.8)
114
115
  mime-types (1.25.1)
116
+ mimemagic (0.2.1)
115
117
  multi_json (1.8.2)
116
118
  multi_test (0.0.3)
117
119
  multi_xml (0.5.5)
118
- multipart-post (1.2.0)
120
+ multipart-post (2.0.0)
119
121
  net-scp (1.1.0)
120
122
  net-ssh (>= 2.6.5)
121
123
  net-sftp (2.1.1)
@@ -124,7 +126,7 @@ GEM
124
126
  net-ssh-gateway (1.2.0)
125
127
  net-ssh (>= 2.6.5)
126
128
  null_logger (0.0.1)
127
- polyglot (0.3.4)
129
+ polyglot (0.3.5)
128
130
  rack (1.5.2)
129
131
  rack-protection (1.5.1)
130
132
  rack
@@ -1,7 +1,4 @@
1
- Feature: Manage Cart attributes
2
- In order to organize dropboxes
3
- An user
4
- wants to filter files by name
1
+ Feature: Manage file matching
5
2
 
6
3
  Scenario: Select a file by Ruby regexp
7
4
  Given a configuration with this prepare block
@@ -45,7 +45,20 @@ module Rivendell::Import
45
45
  end
46
46
  end
47
47
 
48
+ attr_accessor :file_patterns
49
+ def file_patterns
50
+ @file_patterns ||= ["**/*", "*"]
51
+ end
52
+
53
+ def ignore?(path)
54
+ not file_patterns.any? do |file_pattern|
55
+ ::File.fnmatch file_pattern, path, ::File::FNM_PATHNAME | ::File::FNM_CASEFOLD
56
+ end
57
+ end
58
+
48
59
  def file(path, base_directory = nil)
60
+ return if ignore? path
61
+
49
62
  path = ::File.expand_path(path, base_directory)
50
63
  file = Rivendell::Import::File.new path, :base_directory => base_directory
51
64
  create_task file
@@ -60,7 +60,7 @@ module Rivendell::Import
60
60
  end
61
61
 
62
62
  def empty_title?(title)
63
- not [ nil, "", "[new cart]" ].include? title
63
+ [ nil, "", "[new cart]" ].include? title
64
64
  end
65
65
 
66
66
  def update_by_api
@@ -1,5 +1,5 @@
1
1
  module Rivendell
2
2
  module Import
3
- VERSION = "0.8"
3
+ VERSION = "0.9"
4
4
  end
5
5
  end
@@ -126,4 +126,25 @@ describe Rivendell::Import::Base do
126
126
 
127
127
  end
128
128
 
129
+ describe "#ignore?" do
130
+
131
+ context "when default file patterns" do
132
+
133
+ it "should ignore hidden file" do
134
+ subject.ignore?("path/to/.nfs00000000074200420000000c").should be_true
135
+ subject.ignore?(".nfs00000000074200420000000c").should be_true
136
+ end
137
+
138
+ it "should accept files in directories" do
139
+ subject.ignore?("path/to/normal_file.mp3").should be_false
140
+ end
141
+
142
+ it "should accept files in root directory" do
143
+ subject.ignore?("file").should be_false
144
+ end
145
+
146
+ end
147
+
148
+ end
149
+
129
150
  end
@@ -208,5 +208,60 @@ describe Rivendell::Import::Cart do
208
208
 
209
209
  end
210
210
 
211
+ describe "#empty_title?" do
211
212
 
213
+ it "should true when title is nil" do
214
+ subject.empty_title?(nil).should be_true
215
+ end
216
+
217
+ it "should true when title is '[new cart]'" do
218
+ subject.empty_title?('[new cart]').should be_true
219
+ end
220
+
221
+ it "should false when title is anything else" do
222
+ subject.empty_title?('dummy').should be_false
223
+ end
224
+
225
+ end
226
+
227
+ describe "update" do
228
+
229
+ it "should invoke update_by_api" do
230
+ subject.should_receive :update_by_api
231
+ subject.update
232
+ end
233
+
234
+ context "when when update_by_api fails" do
235
+
236
+ before do
237
+ subject.stub(:update_by_api).and_raise("#fail")
238
+ end
239
+
240
+ context "when database is enabled" do
241
+
242
+ before do
243
+ Rivendell::Import::Database.stub :enabled? => true
244
+ end
245
+
246
+ it "should invoke update_by_db " do
247
+ subject.should_receive :update_by_db
248
+ subject.update
249
+ end
250
+
251
+ end
252
+
253
+ context "when database is disabled" do
254
+
255
+ before do
256
+ Rivendell::Import::Database.stub :enabled? => false
257
+ end
258
+
259
+ it "should not invoke update_by_db " do
260
+ subject.should_not_receive :update_by_db
261
+ subject.update
262
+ end
263
+
264
+ end
265
+ end
266
+ end
212
267
  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: '0.8'
4
+ version: '0.9'
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: 2014-03-25 00:00:00.000000000 Z
12
+ date: 2014-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: listen
@@ -482,7 +482,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
482
482
  version: '0'
483
483
  segments:
484
484
  - 0
485
- hash: 1555442861481114113
485
+ hash: 1053952433249090038
486
486
  required_rubygems_version: !ruby/object:Gem::Requirement
487
487
  none: false
488
488
  requirements:
@@ -491,7 +491,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
491
491
  version: '0'
492
492
  segments:
493
493
  - 0
494
- hash: 1555442861481114113
494
+ hash: 1053952433249090038
495
495
  requirements: []
496
496
  rubyforge_project:
497
497
  rubygems_version: 1.8.23