adyen-admin 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.md +4 -0
- data/VERSION +1 -1
- data/lib/adyen-admin/skin.rb +42 -21
- data/spec/adyen-admin/skin_spec.rb +74 -9
- data/spec/fixtures/skins/DV3tf95f/metadata.yml +5 -0
- data/spec/fixtures/skins/DV3tf95f/skin.html.erb +13 -0
- metadata +20 -16
data/CHANGES.md
CHANGED
@@ -7,6 +7,10 @@
|
|
7
7
|
* add CLI binaries (to compile + upload) -> read from .adyenrc file
|
8
8
|
* make compatible with Live system
|
9
9
|
|
10
|
+
## v0.0.5
|
11
|
+
* fix name with multiple - issue
|
12
|
+
* added decompile with backup
|
13
|
+
|
10
14
|
## v0.0.4
|
11
15
|
* get the default path right
|
12
16
|
* add path to remote skins
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/lib/adyen-admin/skin.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'tempfile'
|
2
2
|
require 'zip/zip'
|
3
3
|
|
4
4
|
module Adyen
|
@@ -22,7 +22,7 @@ module Adyen
|
|
22
22
|
|
23
23
|
self.path ||= File.join(Skin.default_path, [name,code].compact.join("-"))
|
24
24
|
|
25
|
-
raise ArgumentError unless code
|
25
|
+
raise ArgumentError, "No Code given" unless code
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.default_path
|
@@ -81,9 +81,9 @@ module Adyen
|
|
81
81
|
|
82
82
|
def path=(new_path)
|
83
83
|
if Skin.is_skin_path?(new_path)
|
84
|
-
new_code, new_name = File.basename(new_path).split("-").reverse
|
84
|
+
new_code, *new_name = File.basename(new_path).split("-").reverse
|
85
85
|
self.code ||= new_code
|
86
|
-
self.name ||= new_name
|
86
|
+
self.name ||= new_name.reverse.join("-")
|
87
87
|
raise ArgumentError if self.code && self.code != new_code
|
88
88
|
@path = new_path
|
89
89
|
end
|
@@ -124,33 +124,56 @@ module Adyen
|
|
124
124
|
def download
|
125
125
|
"#{code}.zip".tap do |filename|
|
126
126
|
Adyen::Admin.client.download(DOWNLOAD % code, filename)
|
127
|
+
end
|
128
|
+
end
|
127
129
|
|
128
|
-
|
129
|
-
|
130
|
-
|
130
|
+
def decompile(filename, backup = true)
|
131
|
+
# create backup of current, include any files
|
132
|
+
if self.path
|
133
|
+
if backup
|
134
|
+
compile(/(zip|lock)$/, ".backup.zip")
|
135
|
+
end
|
136
|
+
else
|
137
|
+
File.join(Skin.default_path, [name,code].compact.join("-")).tap do |p|
|
138
|
+
`mkdir -p #{p}`
|
139
|
+
self.path = p
|
131
140
|
end
|
132
|
-
|
141
|
+
end
|
142
|
+
|
143
|
+
Zip::ZipFile.open(filename) do |zip_file|
|
144
|
+
zip_file.each do |file|
|
145
|
+
f_path = File.join(self.path, file.name.gsub("#{code}/", ""))
|
146
|
+
FileUtils.mkdir_p(File.dirname(f_path))
|
147
|
+
if File.directory?(f_path)
|
148
|
+
`mkdir -p #{f_path}`
|
149
|
+
else
|
150
|
+
`rm -f #{f_path}`
|
151
|
+
zip_file.extract(file, f_path)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
if backup
|
157
|
+
`mv .backup.zip #{File.join(self.path, ".backup.zip")}`
|
133
158
|
end
|
134
159
|
end
|
135
160
|
|
136
|
-
def compile
|
137
|
-
raise ArgumentError unless path
|
161
|
+
def compile(exclude = /(yml|zip|erb)$/, outfile = "#{code}.zip")
|
162
|
+
raise ArgumentError, "No Path given" unless path
|
138
163
|
|
139
|
-
|
140
|
-
`rm -
|
141
|
-
Zip::ZipFile.open(filename,
|
164
|
+
outfile.tap do |filename|
|
165
|
+
`rm -f #{filename}`
|
166
|
+
Zip::ZipFile.open(filename, Zip::ZipFile::CREATE) do |zip_file|
|
142
167
|
Dir["#{path}/**/**"].each do |file|
|
143
|
-
next if file
|
144
|
-
|
145
|
-
zipfile.add(file.sub(path, code), file)
|
168
|
+
next if file =~ exclude
|
169
|
+
zip_file.add(file.sub(path, code), file)
|
146
170
|
end
|
147
171
|
|
148
172
|
dir = File.join(File.dirname(path), parent_skin_code)
|
149
173
|
Dir["#{dir}/**/**"].each do |file|
|
150
174
|
begin
|
151
|
-
next if file
|
152
|
-
|
153
|
-
zipfile.add(file.sub(dir, code), file)
|
175
|
+
next if file =~ exclude
|
176
|
+
zip_file.add(file.sub(dir, code), file)
|
154
177
|
rescue Zip::ZipEntryExistsError
|
155
178
|
# NOOP
|
156
179
|
end
|
@@ -175,8 +198,6 @@ module Adyen
|
|
175
198
|
end
|
176
199
|
|
177
200
|
def publish
|
178
|
-
raise ArgumentError unless code
|
179
|
-
|
180
201
|
page = Adyen::Admin.get(PUBLISH % code)
|
181
202
|
page = Adyen::Admin.client.submit(page.form.tap do |form|
|
182
203
|
end)
|
@@ -94,6 +94,10 @@ module Adyen::Admin
|
|
94
94
|
Skin.new(:path => path).code.should == "7hFAQnmt"
|
95
95
|
end
|
96
96
|
|
97
|
+
it "auto sets name from path" do
|
98
|
+
Skin.new(:path => path).name.should == "example"
|
99
|
+
end
|
100
|
+
|
97
101
|
it "raises error on wrong code for path" do
|
98
102
|
expect do
|
99
103
|
Skin.new(:code => "different", :path => path).path.should == path
|
@@ -105,10 +109,20 @@ module Adyen::Admin
|
|
105
109
|
Skin.new
|
106
110
|
end.to raise_error
|
107
111
|
end
|
112
|
+
|
113
|
+
context "slash in name" do
|
114
|
+
let(:path) { "#{skin_fixtures}/example-test-7hFAQnmt" }
|
115
|
+
|
116
|
+
it "sets name" do
|
117
|
+
Skin.stub(:is_skin_path?).and_return(true)
|
118
|
+
Skin.new(:path => path).name.should == "example-test"
|
119
|
+
end
|
120
|
+
end
|
108
121
|
end
|
109
122
|
|
110
123
|
describe "#download" do
|
111
|
-
let(:zip_filename) { "#{skin.code}.zip"}
|
124
|
+
let(:zip_filename) { "#{skin.code}.zip" }
|
125
|
+
|
112
126
|
after do
|
113
127
|
`rm -rf #{zip_filename}`
|
114
128
|
end
|
@@ -119,17 +133,52 @@ module Adyen::Admin
|
|
119
133
|
end
|
120
134
|
end
|
121
135
|
|
136
|
+
describe "#decompile" do
|
137
|
+
let(:skin_code) { "DV3tf95f" }
|
138
|
+
let(:skin) { Skin.new(:path => "#{skin_fixtures}/#{skin_code}") }
|
139
|
+
let!(:zip_filename) { skin.compile(nil) }
|
140
|
+
let(:backup_filename) { File.join(skin.path, '.backup.zip') }
|
141
|
+
|
142
|
+
before do
|
143
|
+
`cp -r #{skin_fixtures}/#{skin_code} #{skin_fixtures}/_backup`
|
144
|
+
end
|
145
|
+
|
146
|
+
after do
|
147
|
+
`rm -rf #{zip_filename} #{backup_filename} #{skin_fixtures}/#{skin_code}`
|
148
|
+
`mv #{skin_fixtures}/_backup #{skin_fixtures}/#{skin_code}`
|
149
|
+
end
|
150
|
+
|
151
|
+
it "creates backup" do
|
152
|
+
skin.decompile(zip_filename)
|
153
|
+
|
154
|
+
File.should be_exists(backup_filename)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "unzips files" do
|
158
|
+
`rm -rf #{skin.path}`
|
159
|
+
|
160
|
+
expect do
|
161
|
+
skin.decompile(zip_filename)
|
162
|
+
end.to change { File.exists?(File.join(skin.path, 'inc', 'order_data.txt')) }
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
122
166
|
describe "#compile" do
|
123
167
|
let(:skin_code) { "DV3tf95f" }
|
124
168
|
let(:skin) { Skin.new(:path => "#{skin_fixtures}/#{skin_code}") }
|
169
|
+
let(:zip_filename) { skin.compile }
|
125
170
|
|
126
|
-
def zip_contains(
|
127
|
-
Zip::ZipFile.open(zip_filename
|
171
|
+
def zip_contains(file)
|
172
|
+
Zip::ZipFile.open(zip_filename) do |zipfile|
|
128
173
|
return true if zipfile.find_entry(File.join(skin_code, file))
|
129
174
|
end
|
130
175
|
false
|
131
176
|
end
|
132
177
|
|
178
|
+
after do
|
179
|
+
`rm -f #{skin_code}.zip`
|
180
|
+
end
|
181
|
+
|
133
182
|
context "without base" do
|
134
183
|
before do
|
135
184
|
`mv #{skin_fixtures}/base #{skin_fixtures}/base2`
|
@@ -140,32 +189,48 @@ module Adyen::Admin
|
|
140
189
|
end
|
141
190
|
|
142
191
|
it "includes screen file" do
|
143
|
-
zip_contains(
|
192
|
+
zip_contains("css/screen.css").should be_true
|
144
193
|
end
|
145
194
|
|
146
195
|
it "excludes print files" do
|
147
|
-
zip_contains(
|
196
|
+
zip_contains("css/print.css").should_not be_true
|
148
197
|
end
|
149
198
|
end
|
150
199
|
|
151
200
|
it "includes screen file" do
|
152
|
-
zip_contains(
|
201
|
+
zip_contains("css/screen.css").should be_true
|
153
202
|
end
|
154
203
|
|
155
204
|
it "includes print file" do
|
156
|
-
zip_contains(
|
205
|
+
zip_contains("css/print.css").should be_true
|
157
206
|
end
|
158
207
|
|
159
208
|
it "excludes meta file" do
|
160
|
-
zip_contains(
|
209
|
+
zip_contains("metadata.yml").should_not be_true
|
161
210
|
end
|
162
211
|
|
163
212
|
it "excludes skin file" do
|
164
|
-
zip_contains(
|
213
|
+
zip_contains("skin.html.erb").should_not be_true
|
214
|
+
end
|
215
|
+
|
216
|
+
context "no exlusion" do
|
217
|
+
let(:zip_filename) { skin.compile(nil) }
|
218
|
+
|
219
|
+
it "excludes meta file" do
|
220
|
+
zip_contains("metadata.yml").should be_true
|
221
|
+
end
|
222
|
+
|
223
|
+
it "excludes skin file" do
|
224
|
+
zip_contains("skin.html.erb").should be_true
|
225
|
+
end
|
165
226
|
end
|
166
227
|
end
|
167
228
|
|
168
229
|
describe "#upload" do
|
230
|
+
after do
|
231
|
+
`rm -f #{skin_code}.zip`
|
232
|
+
end
|
233
|
+
|
169
234
|
context "valid set" do
|
170
235
|
it "increases version" do
|
171
236
|
skin.path = "#{skin_fixtures}/example-7hFAQnmt"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<!-- ### inc/cheader_[locale].txt or inc/cheader.txt (fallback) ### -->
|
2
|
+
|
3
|
+
<% adyen_form_tag do %>
|
4
|
+
<!-- ### inc/pmheader_[locale].txt or inc/pmheader.txt (fallback) ### -->
|
5
|
+
|
6
|
+
<%= adyen_payment_fields %>
|
7
|
+
|
8
|
+
<!-- ### inc/pmfooter_[locale].txt or inc/pmfooter.txt (fallback) ### -->
|
9
|
+
|
10
|
+
<!-- ### inc/customfields_[locale].txt or inc/customfields.txt (fallback) ### -->
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<!-- ### inc/cfooter_[locale].txt or inc/cfooter.txt (fallback) ### -->
|
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.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-12 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
|
-
requirement: &
|
16
|
+
requirement: &70322653878160 !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: *
|
24
|
+
version_requirements: *70322653878160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rubyzip
|
27
|
-
requirement: &
|
27
|
+
requirement: &70322653877680 !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: *
|
35
|
+
version_requirements: *70322653877680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70322653877100 !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: *
|
46
|
+
version_requirements: *70322653877100
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70322653876640 !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: *
|
57
|
+
version_requirements: *70322653876640
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: vcr
|
60
|
-
requirement: &
|
60
|
+
requirement: &70322653876180 !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: *
|
68
|
+
version_requirements: *70322653876180
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
|
-
requirement: &
|
71
|
+
requirement: &70322653875720 !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: *
|
79
|
+
version_requirements: *70322653875720
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: debugger
|
82
|
-
requirement: &
|
82
|
+
requirement: &70322653875260 !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: *
|
90
|
+
version_requirements: *70322653875260
|
91
91
|
description: A little Gem to make your life easier when dealing with Adyen skins
|
92
92
|
email:
|
93
93
|
- tobi@soundcloud.com
|
@@ -126,6 +126,8 @@ files:
|
|
126
126
|
- spec/fixtures/cassettes/login.yml
|
127
127
|
- spec/fixtures/skins/DV3tf95f/css/screen.css
|
128
128
|
- spec/fixtures/skins/DV3tf95f/inc/order_data.txt
|
129
|
+
- spec/fixtures/skins/DV3tf95f/metadata.yml
|
130
|
+
- spec/fixtures/skins/DV3tf95f/skin.html.erb
|
129
131
|
- spec/fixtures/skins/JH0815/css/screen.css
|
130
132
|
- spec/fixtures/skins/JH0815/skin.html.erb
|
131
133
|
- spec/fixtures/skins/base/css/print.css
|
@@ -204,6 +206,8 @@ test_files:
|
|
204
206
|
- spec/fixtures/cassettes/login.yml
|
205
207
|
- spec/fixtures/skins/DV3tf95f/css/screen.css
|
206
208
|
- spec/fixtures/skins/DV3tf95f/inc/order_data.txt
|
209
|
+
- spec/fixtures/skins/DV3tf95f/metadata.yml
|
210
|
+
- spec/fixtures/skins/DV3tf95f/skin.html.erb
|
207
211
|
- spec/fixtures/skins/JH0815/css/screen.css
|
208
212
|
- spec/fixtures/skins/JH0815/skin.html.erb
|
209
213
|
- spec/fixtures/skins/base/css/print.css
|