adyen-skinbuilder 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +28 -1
- data/lib/adyen-skinbuilder/tasks/skin.rake +40 -4
- data/lib/adyen-skinbuilder/version.rb +1 -1
- metadata +4 -4
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Simple Rack server to make Adyen skin authoring easier. Also includes rake tasks to bundle skin directories into deployable bundles
|
1
|
+
Simple Rack server to make Adyen skin authoring easier. Also includes rake tasks to bundle skin directories into deployable bundles.
|
2
2
|
|
3
3
|
## Install
|
4
4
|
|
@@ -25,6 +25,33 @@ And go to http://localhost:8888 to see the generated page.
|
|
25
25
|
|
26
26
|
See `adyen-skinbuilder --help` for more options to run server on different port or with logging etc.
|
27
27
|
|
28
|
+
### Base directory
|
29
|
+
|
30
|
+
If you have multiple skin directories, this gem supports base directory that can provide files that will be included in all skins without the need to duplicate them. Let's consider this example:
|
31
|
+
|
32
|
+
+- ~/Documents
|
33
|
+
+- base
|
34
|
+
+- inc
|
35
|
+
+- cfooter.txt
|
36
|
+
+- cheader.txt
|
37
|
+
+- DV3tf95f
|
38
|
+
+- inc
|
39
|
+
+- cheader.txt
|
40
|
+
|
41
|
+
File in specific skin directory takes precedence when building skin zip file. In this example, `cheader.txt` will be bundled from skin directory `DV3tf95f/inc` but `cfooter.txt` comes from `base/inc`.
|
42
|
+
|
28
43
|
## Order Data
|
29
44
|
|
30
45
|
Adyen let's you post order data that will be shown in shopping cart view as part of html. You can put `order_data.txt` file into `inc/` folder in the skin directory. This file will be included automatically in the same place, where adyen would put it.
|
46
|
+
|
47
|
+
## Building skin for upload
|
48
|
+
|
49
|
+
There is a convenient Rake task that will create zip file of the skin file. It can be used either by providing directories as rake task arguments:
|
50
|
+
|
51
|
+
rake adyen:skin:build['/path/to/skin/directory','/path/to/target']
|
52
|
+
|
53
|
+
Also, providing environment variables will work:
|
54
|
+
|
55
|
+
rake adyen:skin:build SKIN=/path/to/skin/directory TARGET=/path/to/target
|
56
|
+
|
57
|
+
Why is it better than just zipping together skin directory by yourself? Just because we can and it also looks into base directory for shared files if you happen to have several skin directories.
|
@@ -1,13 +1,49 @@
|
|
1
1
|
require 'adyen-skinbuilder'
|
2
|
+
require 'zip/zip'
|
2
3
|
|
3
4
|
namespace :adyen do
|
4
5
|
namespace :skin do
|
5
6
|
|
6
|
-
desc 'Run server to test Adyen skins'
|
7
|
-
task :server do
|
8
|
-
|
7
|
+
desc 'Run server to test Adyen skins. Run as rake adyen:skin:server[/path/to/skin/directory]'
|
8
|
+
task :server, :skin_directory do |t, args|
|
9
|
+
port, skin_directory = 8888, File.expand_path(args[:skin_directory])
|
9
10
|
|
10
|
-
|
11
|
+
puts "Using skin directory #{skin_directory}"
|
12
|
+
puts "Running server at http://localhost:#{port}/"
|
13
|
+
|
14
|
+
Adyen::SkinBuilder::Server.run({:port => port, :log => false, :skin_directory => skin_directory})
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Build adyen skin zip file for upload. Provide SKIN and TARGET environment variables along the way.'
|
18
|
+
task :build, :skin_directory, :target_directory do |t, args|
|
19
|
+
skin_directory = File.expand_path(args[:skin_directory] || ENV['SKIN'])
|
20
|
+
base_directory = File.expand_path(File.join(skin_directory, '..', 'base'))
|
21
|
+
skin_name = File.basename(skin_directory)
|
22
|
+
target_directory = File.expand_path((args[:target_directory] || ENV['TARGET']))
|
23
|
+
|
24
|
+
if File.directory?(skin_directory) and File.directory?(target_directory)
|
25
|
+
Zip::ZipOutputStream::open(File.join(target_directory, "#{skin_name}.zip")) do |io|
|
26
|
+
%w(css img inc js res).each do |d|
|
27
|
+
if File.directory?(File.join(base_directory, d))
|
28
|
+
Dir.new(File.join(base_directory, d)).each do |file|
|
29
|
+
if File.file?(File.join(base_directory, d, file))
|
30
|
+
io.put_next_entry("#{d}/#{file}")
|
31
|
+
|
32
|
+
if File.file?(File.join(skin_directory, d, file))
|
33
|
+
io.write File.read(File.join(skin_directory, d, file))
|
34
|
+
else
|
35
|
+
io.write File.read(File.join(base_directory, d, file))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
puts "Skin zip package was created to #{File.join(target_directory, "#{skin_name}.zip")}"
|
44
|
+
else
|
45
|
+
puts "Usage: rake adyen:buildskin[<skin_directory>,<target_directory>] or rake:adyen:buildskin FROM=/from/dir TO=/to/dir"
|
46
|
+
end
|
11
47
|
end
|
12
48
|
end
|
13
49
|
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: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 2
|
8
9
|
- 1
|
9
|
-
|
10
|
-
version: 0.1.1
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Priit Haamer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-03 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|