adyen-admin 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -6,6 +6,10 @@
6
6
  * add CLI binaries (to compile + upload) -> read from .adyenrc file
7
7
  * make compatible with Live system
8
8
 
9
+ ## v0.0.10 - 24-04-2012
10
+ * renamed `compile` to `compress`
11
+ * added `compile` which splits any given input to the inc/* file according to given pattern
12
+
9
13
  ## v0.0.9 - 23-04-2012
10
14
  * parse metafile
11
15
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.10
@@ -144,7 +144,7 @@ module Adyen
144
144
  # create backup of current, include any files
145
145
  if self.path
146
146
  if backup
147
- compile(/(zip|lock)$/, ".backup.zip")
147
+ compress(/(zip|lock)$/, ".backup.zip")
148
148
  end
149
149
  else
150
150
  backup = false
@@ -171,7 +171,19 @@ module Adyen
171
171
  end
172
172
  end
173
173
 
174
- def compile(exclude = /(yml|zip|erb)$/, outfile = "#{code}.zip")
174
+ def compile(output, pattern = /<!-- ### inc\/([a-z]+) -->(.+?)<!-- ### -->/m)
175
+ raise ArgumentError, "No Path given" unless path
176
+
177
+ output.scan(pattern) do |name, content|
178
+ file = File.join(path, "inc/#{name}.txt")
179
+ `mkdir -p #{File.dirname(file)}`
180
+ File.open(file, "w") do |f|
181
+ f.write content.strip
182
+ end
183
+ end
184
+ end
185
+
186
+ def compress(exclude = /(yml|zip|erb)$/, outfile = "#{code}.zip")
175
187
  raise ArgumentError, "No Path given" unless path
176
188
 
177
189
  outfile.tap do |filename|
@@ -201,7 +213,7 @@ module Adyen
201
213
 
202
214
  # http://stackoverflow.com/questions/3420587/ruby-mechanize-multipart-form-with-file-upload-to-a-mediawiki
203
215
  def upload
204
- file = self.compile
216
+ file = self.compress
205
217
  page = Adyen::Admin.get(UPLOAD % code)
206
218
  page = Adyen::Admin.client.submit(page.form.tap do |form|
207
219
  form.file_uploads.first.file_name = file
@@ -217,7 +217,7 @@ module Adyen::Admin
217
217
 
218
218
  context "existing skin" do
219
219
  let(:backup_filename) { File.join(skin.path, '.backup.zip') }
220
- let!(:zip_filename) { skin.compile(nil) }
220
+ let!(:zip_filename) { skin.compress(nil) }
221
221
 
222
222
  before do
223
223
  `cp -r #{skin_fixtures}/#{skin_code} #{skin_fixtures}/_backup`
@@ -260,10 +260,40 @@ module Adyen::Admin
260
260
  end
261
261
 
262
262
  describe "#compile" do
263
+ let(:skin_code) { "JH0815" }
264
+ let(:skin) { Skin.new(:path => File.join(skin_fixtures, skin_code)) }
265
+ let(:output) { File.read File.join('spec/fixtures', 'output.html') }
266
+
267
+ before do
268
+ skin.compile(output)
269
+ end
270
+
271
+ after do
272
+ FileUtils.rm_rf( skin.path + '/inc')
273
+ end
274
+
275
+ it 'writes cheader' do
276
+ File.read( skin.path + '/inc/cheader.txt').should == "<!-- ### inc/cheader_[locale].txt or inc/cheader.txt (fallback) ### -->"
277
+ end
278
+
279
+ it 'writes pmheader' do
280
+ File.read( skin.path + '/inc/pmheader.txt').should == "<!-- ### inc/pmheader_[locale].txt or inc/pmheader.txt (fallback) ### -->"
281
+ end
282
+
283
+ it 'writes pmfooter' do
284
+ File.read( skin.path + '/inc/pmfooter.txt').should == "<!-- ### inc/pmfooter_[locale].txt or inc/pmfooter.txt (fallback) ### -->\n\n <!-- ### inc/customfields_[locale].txt or inc/customfields.txt (fallback) ### -->"
285
+ end
286
+
287
+ it 'writes cfooter' do
288
+ File.read( skin.path + '/inc/cfooter.txt').should == "<!-- ### inc/cfooter_[locale].txt or inc/cfooter.txt (fallback) ### -->"
289
+ end
290
+ end
291
+
292
+ describe "#compress" do
263
293
  let(:skin_code) { "DV3tf95f" }
264
294
  let(:path) { "#{skin_fixtures}/#{skin_code}" }
265
295
  let(:skin) { Skin.new(:path => path) }
266
- let(:zip_filename) { skin.compile }
296
+ let(:zip_filename) { skin.compress }
267
297
 
268
298
  def zip_contains(file)
269
299
  Zip::ZipFile.open(zip_filename) do |zipfile|
@@ -321,7 +351,7 @@ module Adyen::Admin
321
351
  end
322
352
 
323
353
  context "no exlusion" do
324
- let(:zip_filename) { skin.compile(nil) }
354
+ let(:zip_filename) { skin.compress(nil) }
325
355
 
326
356
  it "excludes meta file" do
327
357
  zip_contains("skin.yml").should be_true
@@ -0,0 +1,17 @@
1
+ <!-- ### inc/cheader -->
2
+ <!-- ### inc/cheader_[locale].txt or inc/cheader.txt (fallback) ### -->
3
+ <!-- ### -->
4
+
5
+ <!-- ### inc/pmheader -->
6
+ <!-- ### inc/pmheader_[locale].txt or inc/pmheader.txt (fallback) ### -->
7
+ <!-- ### -->
8
+
9
+ <!-- ### inc/pmfooter -->
10
+ <!-- ### inc/pmfooter_[locale].txt or inc/pmfooter.txt (fallback) ### -->
11
+
12
+ <!-- ### inc/customfields_[locale].txt or inc/customfields.txt (fallback) ### -->
13
+ <!-- ### -->
14
+
15
+ <!-- ### inc/cfooter -->
16
+ <!-- ### inc/cfooter_[locale].txt or inc/cfooter.txt (fallback) ### -->
17
+ <!-- ### -->
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adyen-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
16
- requirement: &70352924333260 !ruby/object:Gem::Requirement
16
+ requirement: &70183294042540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70352924333260
24
+ version_requirements: *70183294042540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubyzip
27
- requirement: &70352924332780 !ruby/object:Gem::Requirement
27
+ requirement: &70183294042060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70352924332780
35
+ version_requirements: *70183294042060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70352924332200 !ruby/object:Gem::Requirement
38
+ requirement: &70183294041480 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70352924332200
46
+ version_requirements: *70183294041480
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70352924331740 !ruby/object:Gem::Requirement
49
+ requirement: &70183294041020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70352924331740
57
+ version_requirements: *70183294041020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: vcr
60
- requirement: &70352924331280 !ruby/object:Gem::Requirement
60
+ requirement: &70183294040560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70352924331280
68
+ version_requirements: *70183294040560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &70352924330820 !ruby/object:Gem::Requirement
71
+ requirement: &70183294040100 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70352924330820
79
+ version_requirements: *70183294040100
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: debugger
82
- requirement: &70352924330360 !ruby/object:Gem::Requirement
82
+ requirement: &70183294039640 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70352924330360
90
+ version_requirements: *70183294039640
91
91
  description: A little Gem to make your life easier when dealing with Adyen skins
92
92
  email:
93
93
  - tobi@soundcloud.com
@@ -128,6 +128,7 @@ files:
128
128
  - spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_upload/valid_set/increases_version.yml
129
129
  - spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_upload/valid_set/updates_skin_data.yml
130
130
  - spec/fixtures/cassettes/login.yml
131
+ - spec/fixtures/output.html
131
132
  - spec/fixtures/skins/DV3tf95f/css/screen.css
132
133
  - spec/fixtures/skins/DV3tf95f/inc/order_data.txt
133
134
  - spec/fixtures/skins/DV3tf95f/skin.html.erb
@@ -211,6 +212,7 @@ test_files:
211
212
  - spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_upload/valid_set/increases_version.yml
212
213
  - spec/fixtures/cassettes/Adyen_Admin_Skin/authenticated/_upload/valid_set/updates_skin_data.yml
213
214
  - spec/fixtures/cassettes/login.yml
215
+ - spec/fixtures/output.html
214
216
  - spec/fixtures/skins/DV3tf95f/css/screen.css
215
217
  - spec/fixtures/skins/DV3tf95f/inc/order_data.txt
216
218
  - spec/fixtures/skins/DV3tf95f/skin.html.erb