adyen-skinbuilder 0.3.2 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +23 -14
- data/lib/adyen-skinbuilder/helper/render.rb +14 -2
- data/lib/adyen-skinbuilder/server.rb +12 -6
- data/lib/adyen-skinbuilder/server/views/index.html.erb +1 -1
- data/lib/adyen-skinbuilder/version.rb +1 -1
- data/spec/lib/adyen-skinbuilder/helper/render_spec.rb +15 -0
- metadata +7 -5
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
adyen-skinbuilder (0.
|
4
|
+
adyen-skinbuilder (0.4.1)
|
5
5
|
adyen-admin
|
6
6
|
sinatra
|
7
7
|
sinatra-contrib
|
@@ -10,20 +10,24 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: http://rubygems.org/
|
12
12
|
specs:
|
13
|
-
adyen-admin (0.0.
|
13
|
+
adyen-admin (0.0.16)
|
14
14
|
mechanize
|
15
15
|
rubyzip
|
16
|
-
backports (2.
|
16
|
+
backports (2.6.1)
|
17
17
|
diff-lcs (1.1.3)
|
18
18
|
domain_name (0.5.3)
|
19
19
|
unf (~> 0.0.3)
|
20
20
|
eventmachine (0.12.10)
|
21
21
|
ffi (1.0.11)
|
22
|
-
guard (1.
|
23
|
-
|
22
|
+
guard (1.1.1)
|
23
|
+
listen (>= 0.4.2)
|
24
24
|
thor (>= 0.14.6)
|
25
|
-
guard-rspec (
|
26
|
-
guard (>=
|
25
|
+
guard-rspec (1.1.0)
|
26
|
+
guard (>= 1.1)
|
27
|
+
listen (0.4.5)
|
28
|
+
rb-fchange (~> 0.0.5)
|
29
|
+
rb-fsevent (~> 0.9.1)
|
30
|
+
rb-inotify (~> 0.8.8)
|
27
31
|
mechanize (2.5.1)
|
28
32
|
domain_name (~> 0.5, >= 0.5.1)
|
29
33
|
mime-types (~> 1.17, >= 1.17.2)
|
@@ -33,9 +37,9 @@ GEM
|
|
33
37
|
ntlm-http (~> 0.1, >= 0.1.1)
|
34
38
|
webrobots (~> 0.0, >= 0.0.9)
|
35
39
|
mime-types (1.18)
|
36
|
-
net-http-digest_auth (1.2)
|
37
|
-
net-http-persistent (2.
|
38
|
-
nokogiri (1.5.
|
40
|
+
net-http-digest_auth (1.2.1)
|
41
|
+
net-http-persistent (2.7)
|
42
|
+
nokogiri (1.5.4)
|
39
43
|
ntlm-http (0.1.1)
|
40
44
|
rack (1.4.1)
|
41
45
|
rack-protection (1.2.0)
|
@@ -43,15 +47,20 @@ GEM
|
|
43
47
|
rack-test (0.6.1)
|
44
48
|
rack (>= 1.0)
|
45
49
|
rake (0.9.2.2)
|
50
|
+
rb-fchange (0.0.5)
|
51
|
+
ffi
|
52
|
+
rb-fsevent (0.9.1)
|
53
|
+
rb-inotify (0.8.8)
|
54
|
+
ffi (>= 0.5.0)
|
46
55
|
rspec (2.10.0)
|
47
56
|
rspec-core (~> 2.10.0)
|
48
57
|
rspec-expectations (~> 2.10.0)
|
49
58
|
rspec-mocks (~> 2.10.0)
|
50
|
-
rspec-core (2.10.
|
59
|
+
rspec-core (2.10.1)
|
51
60
|
rspec-expectations (2.10.0)
|
52
61
|
diff-lcs (~> 1.1.3)
|
53
62
|
rspec-mocks (2.10.1)
|
54
|
-
rubyzip (0.9.
|
63
|
+
rubyzip (0.9.9)
|
55
64
|
sinatra (1.3.2)
|
56
65
|
rack (~> 1.3, >= 1.3.6)
|
57
66
|
rack-protection (~> 1.2)
|
@@ -63,11 +72,11 @@ GEM
|
|
63
72
|
rack-test
|
64
73
|
sinatra (~> 1.3.0)
|
65
74
|
tilt (~> 1.3)
|
66
|
-
thor (0.15.
|
75
|
+
thor (0.15.3)
|
67
76
|
tilt (1.3.3)
|
68
77
|
unf (0.0.5)
|
69
78
|
unf_ext
|
70
|
-
unf_ext (0.0.
|
79
|
+
unf_ext (0.0.5)
|
71
80
|
vegas (0.1.11)
|
72
81
|
rack (>= 1.0.0)
|
73
82
|
webrobots (0.0.13)
|
@@ -23,8 +23,20 @@ module Adyen
|
|
23
23
|
|
24
24
|
# render an erb partial inline
|
25
25
|
def render_partial(file, locals = {})
|
26
|
-
|
27
|
-
|
26
|
+
file = partialize(file)
|
27
|
+
file = if views = locals.delete(:views)
|
28
|
+
File.join(views, file)
|
29
|
+
else
|
30
|
+
@skin.get_file(file)
|
31
|
+
end
|
32
|
+
erb File.basename(file).gsub(".erb", "").to_sym, :layout => false, :views => File.dirname(file), :locals => locals
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def partialize(path)
|
37
|
+
path.to_s.split('/').tap do |path|
|
38
|
+
path[-1] = "_#{path.last}.html.erb"
|
39
|
+
end.join("/")
|
28
40
|
end
|
29
41
|
end
|
30
42
|
end
|
@@ -33,14 +33,20 @@ module Adyen
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def skin_file(skin, filename
|
37
|
-
|
38
|
-
if !File.exists?(
|
36
|
+
def skin_file(skin, filename)
|
37
|
+
skin.get_file(filename).tap do |file|
|
38
|
+
if !File.exists?(file)
|
39
39
|
return File.join(settings.views, filename)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def skin_erb_file(skin, filename = "skin.html")
|
45
|
+
if file = skin_file(skin, "#{filename}.erb")
|
46
|
+
return file.gsub(".erb", "")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
44
50
|
def adyen_login
|
45
51
|
if (cfg = settings.adyen_admin_cfg) && !Adyen::Admin.authenticated?
|
46
52
|
Adyen::Admin.login(cfg[:accountname], cfg[:username], cfg[:password])
|
@@ -48,7 +54,7 @@ module Adyen
|
|
48
54
|
end
|
49
55
|
|
50
56
|
def render_skin(skin)
|
51
|
-
erb(
|
57
|
+
erb(skin_erb_file(skin).to_sym, {
|
52
58
|
:views => '/',
|
53
59
|
:layout => File.join(settings.views, "layout.html").to_sym
|
54
60
|
})
|
@@ -57,7 +63,7 @@ module Adyen
|
|
57
63
|
helpers Helper::Render, Helper::Adyen
|
58
64
|
|
59
65
|
get '/sf/:skin_code/*' do |skin_code, path|
|
60
|
-
if (skin = Adyen::Admin::Skin.find(skin_code)) && (file =
|
66
|
+
if (skin = Adyen::Admin::Skin.find(skin_code)) && (file = skin.get_file(path)) && File.exists?(file)
|
61
67
|
send_file file
|
62
68
|
elsif (file = File.join(skins_directory, "base", path)) && File.exists?(file)
|
63
69
|
send_file file
|
@@ -89,7 +95,7 @@ module Adyen
|
|
89
95
|
if @skin = Adyen::Admin::Skin.find(skin_code)
|
90
96
|
@skin.download.tap do |zip_file|
|
91
97
|
@skin.decompile(zip_file)
|
92
|
-
`cp #{
|
98
|
+
`cp #{skin_erb_file(@skin)}.erb #{@skin.path}`
|
93
99
|
`rm -f #{zip_file}`
|
94
100
|
end
|
95
101
|
end
|
@@ -98,10 +98,10 @@
|
|
98
98
|
<% if Adyen::Admin.authenticated? && !skin.frozen? %>
|
99
99
|
<% if skin.path %>
|
100
100
|
<a href="/<%= skin.code %>/upload">upload</a>
|
101
|
+
<a href="/<%= skin.code %>/update">update</a>
|
101
102
|
<% else %>
|
102
103
|
<a href="/<%= skin.code %>/download">download</a>
|
103
104
|
<% end %>
|
104
|
-
<a href="/<%= skin.code %>/update">update</a>
|
105
105
|
<% else %>
|
106
106
|
<a href="/<%= skin.code %>/compile">compile</a>
|
107
107
|
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Adyen::SkinBuilder::Helper::Render do
|
4
|
+
|
5
|
+
before do
|
6
|
+
extend Adyen::SkinBuilder::Helper::Render
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#partialize" do
|
10
|
+
it { partialize("file").should == "_file.html.erb" }
|
11
|
+
it { partialize("path1/file").should == "path1/_file.html.erb" }
|
12
|
+
it { partialize("/path1/file").should == "/path1/_file.html.erb" }
|
13
|
+
it { partialize("/path1/path2/file").should == "/path1/path2/_file.html.erb" }
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adyen-skinbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Priit Haamer
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-06-
|
19
|
+
date: 2012-06-20 00:00:00 +03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- spec/fixtures/skins/base/res/resources.properties
|
213
213
|
- spec/fixtures/skins/test/skin.html.erb
|
214
214
|
- spec/fixtures/skins/test/skin.yml
|
215
|
+
- spec/lib/adyen-skinbuilder/helper/render_spec.rb
|
215
216
|
- spec/lib/adyen-skinbuilder/server_spec.rb
|
216
217
|
- spec/spec_helper.rb
|
217
218
|
has_rdoc: true
|
@@ -272,5 +273,6 @@ test_files:
|
|
272
273
|
- spec/fixtures/skins/base/res/resources.properties
|
273
274
|
- spec/fixtures/skins/test/skin.html.erb
|
274
275
|
- spec/fixtures/skins/test/skin.yml
|
276
|
+
- spec/lib/adyen-skinbuilder/helper/render_spec.rb
|
275
277
|
- spec/lib/adyen-skinbuilder/server_spec.rb
|
276
278
|
- spec/spec_helper.rb
|