widget_bundler 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/app/models/widget_bundle.rb +16 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MThiMmU0NjUwODIxNjY1MmMyMzNmZDhkYjM1NzU5OTQ4MjExY2YyZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmQ4MDc2YTc3ODU2ODRiMTExMGQ3YjNiNTk2M2YzZWMzMWNjYmE3YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDhjYjc4YzUwMjM4MmUxZWNkYTc3YTk3ZmRiYTg4YzYxYzI4N2I3MzQwNzI5
|
10
|
+
ZjFkODhkNjZiNTQ0ZDNmYzI4ZmU2ZDgyYTc3ZTMxZWI3YzJkMjU0Mzg3Y2Uy
|
11
|
+
NDIyYzQyN2NlMjJjOTFhZGRiOTlkZGI2YTdhNTc2MDk0YjM2ZDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWRjMmM3ZGM5ZTlkODA1OWYxNWYxYzAzOTE0NDg4ODUxYzNkMTdlZmUzZDNj
|
14
|
+
Y2IzMjQ3YTQ3MThiNTk3OGFhODI3ZGFkMTg0OGViMGMyMzc3ZDRjZTgzZWYw
|
15
|
+
MGJlMjEwNTgzYjFlYTY5NzgwZmI1YmRhZTg4OWFiOWJkNjRkOWE=
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Class for packaging set of html, javascript, image and stylesheet files into a widget for an iBook
|
3
3
|
# => accepts an array of images, stylesheets and javascripts as full paths
|
4
|
+
# => images should be paperclip .url method path
|
4
5
|
# => acceps main haml file as string (fullpath)
|
5
6
|
#
|
6
7
|
require 'active_model'
|
@@ -32,18 +33,26 @@ class WidgetBundle
|
|
32
33
|
FileUtils.mkdir_p path
|
33
34
|
|
34
35
|
# make requred directories
|
35
|
-
images_dir = FileUtils.mkdir
|
36
|
-
|
37
|
-
|
36
|
+
# images_dir = FileUtils.mkdir("#{path}/")[0]
|
37
|
+
images_dir = path
|
38
|
+
css_js_dir = FileUtils.mkdir("#{path}/assets/")[0]
|
38
39
|
|
39
40
|
# copy images
|
40
|
-
FileUtils.
|
41
|
+
# TODO: tried doing this all with FileUtils.cp_r but couldn't get it to work properly, had to use this block instead
|
42
|
+
if images
|
43
|
+
images.each do |i|
|
44
|
+
file = "#{Rails.root}/public#{i}".split("?")[0]
|
45
|
+
dir = "#{images_dir}/#{File.dirname(i)}".gsub('//', '/')
|
46
|
+
FileUtils.mkdir_p dir
|
47
|
+
FileUtils.cp file, dir
|
48
|
+
end
|
49
|
+
end
|
41
50
|
|
42
51
|
# copy stylesheets
|
43
|
-
FileUtils.cp stylesheets,
|
52
|
+
FileUtils.cp stylesheets, css_js_dir if stylesheets
|
44
53
|
|
45
54
|
# copy javascripts
|
46
|
-
FileUtils.cp javascripts,
|
55
|
+
FileUtils.cp javascripts, css_js_dir if javascripts
|
47
56
|
|
48
57
|
# create Info.plist
|
49
58
|
File.open("#{path}/Info.plist", "w") { |file| file.write(plist_content(display_name, bundle_identifier, bundle_name)) }
|
@@ -53,7 +62,7 @@ class WidgetBundle
|
|
53
62
|
File.open("#{path}/main.html", "w") { |file| file.write( compiled_haml ) }
|
54
63
|
|
55
64
|
# compress the *.wdgt folder and return the full path to the zip archive
|
56
|
-
compress(path)
|
65
|
+
compress(path)
|
57
66
|
end
|
58
67
|
|
59
68
|
protected
|