railsthemes 1.1.2 → 1.2.0
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.
- data/lib/railsthemes.rb +1 -0
- data/lib/railsthemes/asset_installer.rb +48 -0
- data/lib/railsthemes/email_installer.rb +1 -1
- data/lib/railsthemes/installer.rb +21 -3
- data/lib/railsthemes/version.rb +1 -1
- data/spec/fixtures/blank-assets-archived/design-assets.tar.gz +0 -0
- data/spec/lib/railsthemes/asset_installer_spec.rb +10 -0
- data/spec/lib/railsthemes/installer_spec.rb +24 -1
- metadata +9 -4
data/lib/railsthemes.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
module Railsthemes
|
2
|
+
class AssetInstaller < Thor
|
3
|
+
no_tasks do
|
4
|
+
include Railsthemes::Logging
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
def install_from_file_system original_source_filepath
|
8
|
+
logger.warn 'Installing design assets...'
|
9
|
+
source_filepath = original_source_filepath.gsub(/\\/, '/')
|
10
|
+
logger.info "Source filepath: #{source_filepath}"
|
11
|
+
|
12
|
+
if File.directory?(source_filepath)
|
13
|
+
install_from_directory source_filepath
|
14
|
+
elsif Utils.archive?(source_filepath + '.tar.gz')
|
15
|
+
install_from_archive source_filepath + '.tar.gz'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def install_from_directory source_filepath
|
20
|
+
Dir["#{source_filepath}/design-assets/**/*"].each do |src|
|
21
|
+
logger.debug "src: #{src}"
|
22
|
+
dest = src.sub("#{source_filepath}/design-assets/", '')
|
23
|
+
logger.debug "dest: #{dest}"
|
24
|
+
if File.directory?(src)
|
25
|
+
unless File.directory?(dest)
|
26
|
+
logger.debug "mkdir -p #{dest}"
|
27
|
+
FileUtils.mkdir_p(dest)
|
28
|
+
end
|
29
|
+
else
|
30
|
+
unless src =~ /\/\./ # remove any pesky hidden files that crept into the archive
|
31
|
+
logger.debug "cp #{src} #{dest}"
|
32
|
+
FileUtils.cp(src, dest)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
logger.warn 'Done installing design assets.'
|
38
|
+
end
|
39
|
+
|
40
|
+
def install_from_archive filepath
|
41
|
+
Railsthemes::Utils.with_tempdir do |tempdir|
|
42
|
+
Utils.unarchive filepath, tempdir
|
43
|
+
install_from_file_system tempdir
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -5,8 +5,8 @@ module Railsthemes
|
|
5
5
|
include Thor::Actions
|
6
6
|
|
7
7
|
def install_from_file_system original_source_filepath
|
8
|
-
source_filepath = original_source_filepath.gsub(/\\/, '/')
|
9
8
|
logger.warn 'Installing email theme...'
|
9
|
+
source_filepath = original_source_filepath.gsub(/\\/, '/')
|
10
10
|
logger.info "Source filepath: #{source_filepath}"
|
11
11
|
|
12
12
|
if File.directory?(source_filepath)
|
@@ -23,6 +23,11 @@ module Railsthemes
|
|
23
23
|
@email_installer ||= EmailInstaller.new
|
24
24
|
end
|
25
25
|
|
26
|
+
# can probably just make static
|
27
|
+
def asset_installer
|
28
|
+
@asset_installer ||= AssetInstaller.new
|
29
|
+
end
|
30
|
+
|
26
31
|
def popup_documentation
|
27
32
|
style_guides = Dir['doc/*Usage_And_Style_Guide.html']
|
28
33
|
# need better tests of popping up multiple docs
|
@@ -49,8 +54,13 @@ module Railsthemes
|
|
49
54
|
if File.directory?(filepath) || Utils.archive?(filepath + '.tar.gz')
|
50
55
|
email_installer.install_from_file_system filepath
|
51
56
|
@installed_email = true
|
52
|
-
|
53
|
-
|
57
|
+
end
|
58
|
+
|
59
|
+
# install design assets if present
|
60
|
+
filepath = File.join(original_source_filepath, 'design-assets')
|
61
|
+
if File.directory?(filepath) || Utils.archive?(filepath + '.tar.gz')
|
62
|
+
asset_installer.install_from_file_system filepath
|
63
|
+
@installed_assets = true
|
54
64
|
end
|
55
65
|
|
56
66
|
print_post_installation_instructions
|
@@ -66,7 +76,7 @@ module Railsthemes
|
|
66
76
|
dl_hash = get_download_hash code
|
67
77
|
|
68
78
|
if dl_hash
|
69
|
-
logger.debug "dl_hash: #{dl_hash.
|
79
|
+
logger.debug "dl_hash: #{dl_hash.inspect}"
|
70
80
|
Utils.with_tempdir do |tempdir|
|
71
81
|
download_from_hash dl_hash, tempdir
|
72
82
|
install_from_file_system tempdir
|
@@ -114,6 +124,14 @@ module Railsthemes
|
|
114
124
|
Utils.download :url => url, :save_to => archive
|
115
125
|
logger.warn "Done downloading email theme."
|
116
126
|
end
|
127
|
+
|
128
|
+
url = dl_hash['design_assets']
|
129
|
+
if url
|
130
|
+
logger.warn "Downloading design assets..."
|
131
|
+
archive = File.join(download_to, 'design-assets.tar.gz')
|
132
|
+
Utils.download :url => url, :save_to => archive
|
133
|
+
logger.warn "Done downloading design assets."
|
134
|
+
end
|
117
135
|
end
|
118
136
|
|
119
137
|
def send_gemfile code
|
data/lib/railsthemes/version.rb
CHANGED
Binary file
|
@@ -20,6 +20,7 @@ describe Railsthemes::Installer do
|
|
20
20
|
describe 'installing theme' do
|
21
21
|
before do
|
22
22
|
stub(@installer.email_installer).install_from_file_system(anything)
|
23
|
+
stub(@installer.asset_installer).install_from_file_system(anything)
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'should install the right theme version' do
|
@@ -29,7 +30,6 @@ describe Railsthemes::Installer do
|
|
29
30
|
|
30
31
|
it 'should install the right theme version if it is an archive in that directory' do
|
31
32
|
mock(@installer.theme_installer).install_from_file_system('spec/fixtures/blank-assets-archived/erb-css')
|
32
|
-
stub(@installer.email_installer).install_from_file_system(anything)
|
33
33
|
@installer.install_from_file_system 'spec/fixtures/blank-assets-archived'
|
34
34
|
end
|
35
35
|
end
|
@@ -37,6 +37,7 @@ describe Railsthemes::Installer do
|
|
37
37
|
describe 'installing email theme' do
|
38
38
|
before do
|
39
39
|
stub(@installer.theme_installer).install_from_file_system(anything)
|
40
|
+
stub(@installer.asset_installer).install_from_file_system(anything)
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'should install the email theme if present' do
|
@@ -49,6 +50,23 @@ describe Railsthemes::Installer do
|
|
49
50
|
@installer.install_from_file_system 'spec/fixtures/blank-assets-archived'
|
50
51
|
end
|
51
52
|
end
|
53
|
+
|
54
|
+
describe 'installing design assets theme' do
|
55
|
+
before do
|
56
|
+
stub(@installer.theme_installer).install_from_file_system(anything)
|
57
|
+
stub(@installer.email_installer).install_from_file_system(anything)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should install the design assets if present' do
|
61
|
+
mock(@installer.asset_installer).install_from_file_system('spec/fixtures/blank-assets/design-assets')
|
62
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should install the archived design assets if present' do
|
66
|
+
mock(@installer.asset_installer).install_from_file_system('spec/fixtures/blank-assets-archived/design-assets')
|
67
|
+
@installer.install_from_file_system 'spec/fixtures/blank-assets-archived'
|
68
|
+
end
|
69
|
+
end
|
52
70
|
end
|
53
71
|
|
54
72
|
# should probably move documentation stuff to another class
|
@@ -98,6 +116,11 @@ describe Railsthemes::Installer do
|
|
98
116
|
mock(Railsthemes::Utils).download(:url => 'email_url', :save_to => "dir/email.tar.gz")
|
99
117
|
@installer.download_from_hash({'email' => 'email_url'}, 'dir')
|
100
118
|
end
|
119
|
+
|
120
|
+
it 'should download and install design assets when that is specified' do
|
121
|
+
mock(Railsthemes::Utils).download(:url => 'asset_url', :save_to => "dir/design-assets.tar.gz")
|
122
|
+
@installer.download_from_hash({'design_assets' => 'asset_url'}, 'dir')
|
123
|
+
end
|
101
124
|
end
|
102
125
|
|
103
126
|
describe '#install_from_code' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsthemes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Railsthemes
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-08-
|
18
|
+
date: 2012-08-28 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: thor
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- bin/railsthemes
|
95
95
|
- cacert.pem
|
96
96
|
- lib/railsthemes.rb
|
97
|
+
- lib/railsthemes/asset_installer.rb
|
97
98
|
- lib/railsthemes/email_installer.rb
|
98
99
|
- lib/railsthemes/ensurer.rb
|
99
100
|
- lib/railsthemes/installer.rb
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- lib/railsthemes/utils.rb
|
106
107
|
- lib/railsthemes/version.rb
|
107
108
|
- railsthemes.gemspec
|
109
|
+
- spec/fixtures/blank-assets-archived/design-assets.tar.gz
|
108
110
|
- spec/fixtures/blank-assets-archived/email.tar.gz
|
109
111
|
- spec/fixtures/blank-assets-archived/erb-css.tar.gz
|
110
112
|
- spec/fixtures/blank-assets/email/app/assets/stylesheets/email.css
|
@@ -118,6 +120,7 @@ files:
|
|
118
120
|
- spec/fixtures/blank-assets/erb-css/base/app/views/layouts/homepage.html.erb
|
119
121
|
- spec/fixtures/blank-assets/erb-css/gems/formtastic/app/assets/stylesheets/formtastic.css.scss
|
120
122
|
- spec/fixtures/blank-assets/erb-css/gems/simple_form/app/assets/stylesheets/simple_form.css.scss
|
123
|
+
- spec/lib/railsthemes/asset_installer_spec.rb
|
121
124
|
- spec/lib/railsthemes/email_installer_spec.rb
|
122
125
|
- spec/lib/railsthemes/ensurer_spec.rb
|
123
126
|
- spec/lib/railsthemes/installer_spec.rb
|
@@ -158,6 +161,7 @@ signing_key:
|
|
158
161
|
specification_version: 3
|
159
162
|
summary: Installs gems from railsthemes.com
|
160
163
|
test_files:
|
164
|
+
- spec/fixtures/blank-assets-archived/design-assets.tar.gz
|
161
165
|
- spec/fixtures/blank-assets-archived/email.tar.gz
|
162
166
|
- spec/fixtures/blank-assets-archived/erb-css.tar.gz
|
163
167
|
- spec/fixtures/blank-assets/email/app/assets/stylesheets/email.css
|
@@ -171,6 +175,7 @@ test_files:
|
|
171
175
|
- spec/fixtures/blank-assets/erb-css/base/app/views/layouts/homepage.html.erb
|
172
176
|
- spec/fixtures/blank-assets/erb-css/gems/formtastic/app/assets/stylesheets/formtastic.css.scss
|
173
177
|
- spec/fixtures/blank-assets/erb-css/gems/simple_form/app/assets/stylesheets/simple_form.css.scss
|
178
|
+
- spec/lib/railsthemes/asset_installer_spec.rb
|
174
179
|
- spec/lib/railsthemes/email_installer_spec.rb
|
175
180
|
- spec/lib/railsthemes/ensurer_spec.rb
|
176
181
|
- spec/lib/railsthemes/installer_spec.rb
|