wrap-bootstrap-rails 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/bin/wrapbr +14 -0
- data/lib/wrap/bootstrap/rails.rb +212 -0
- data/lib/wrap/bootstrap/rails/version.rb +7 -0
- data/wrap-bootstrap-rails.gemspec +24 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 271aa817992e831831f21fc0f020279dc494948d
|
4
|
+
data.tar.gz: 1d0a49882b2baa9331b1405c7f3921fb7f74eb9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f81dfed597a50ac12bf2b2c462f0d0d11853f4c3075ec93d5122b05ed8c25e13f515ba691924ac362a2df90b009ea91790584393274b190244c25116745a5d7b
|
7
|
+
data.tar.gz: 746e1c01289da252dd85b729c736aa8c46aec32470a89f923d893d17d01c09cf1380a18c2230e0545c4a5b1b634c7bf1e75850bce66ac9e840abcdee910d4df4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Takashi Kokubun
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Wrap::Bootstrap::Rails
|
2
|
+
|
3
|
+
Rails plugin generator for [Wrap Bootstrap](https://wrapbootstrap.com/) design templates.
|
4
|
+
This gem automatically distributes necessary assets to proper paths,
|
5
|
+
and fix their reference links for asset pipeline.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ gem install wrap-bootstrap-rails
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
1. Purchase a design template at [Wrap Bootstrap](https://wrapbootstrap.com/)
|
16
|
+
2. Download the design template and unzip downloaded zip.
|
17
|
+
3. Execute following command
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ wrapbr UNZIPPED_DIR GEM_NAME # ex) wrapbr . ace
|
21
|
+
```
|
22
|
+
|
23
|
+
## Caution
|
24
|
+
|
25
|
+
**This gem is NOT recommending redistribution of design templates which need to pay.**
|
26
|
+
Only for your personal usage.
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it ( http://github.com/k0kubun/wrap-bootstrap-rails/fork )
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/wrapbr
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.dirname(__FILE__) + '/../lib'
|
4
|
+
$:.unshift lib unless $:.include? lib
|
5
|
+
|
6
|
+
require 'wrap/bootstrap/rails'
|
7
|
+
|
8
|
+
if ARGV.size < 2
|
9
|
+
puts "Usage:\n $ wrapbr WRAP_DIR GEM_NAME"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
wrap_bootstrap_rails = Wrap::Bootstrap::Rails.new(ARGV[0], ARGV[1])
|
14
|
+
wrap_bootstrap_rails.create_gem!
|
@@ -0,0 +1,212 @@
|
|
1
|
+
require "wrap/bootstrap/rails/version"
|
2
|
+
require "unindent"
|
3
|
+
require "fileutils"
|
4
|
+
require "find"
|
5
|
+
|
6
|
+
class Wrap::Bootstrap::Rails
|
7
|
+
FG_RED = 31
|
8
|
+
DIRNAME_MAP = {
|
9
|
+
"css" => "stylesheets",
|
10
|
+
"js" => "javascripts",
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(target_dir, gem_name)
|
14
|
+
@wrap_dir = File.expand_path(target_dir)
|
15
|
+
@gem_name = gem_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_gem!
|
19
|
+
check_gem_dir_existence
|
20
|
+
check_bundler_existence
|
21
|
+
|
22
|
+
system("bundle", "gem", gem_name)
|
23
|
+
enginize_gem
|
24
|
+
add_railtie_dependency
|
25
|
+
|
26
|
+
copy_assets
|
27
|
+
fix_asset_references
|
28
|
+
write_readme
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# Define Rails::Engine to export vendor/assets directory to rails app.
|
34
|
+
def enginize_gem
|
35
|
+
source = <<-EOS.unindent
|
36
|
+
require "#{gem_name}/version"
|
37
|
+
|
38
|
+
module #{gem_name.capitalize}
|
39
|
+
module Rails
|
40
|
+
class Engine < ::Rails::Engine
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
EOS
|
45
|
+
|
46
|
+
gem_path = File.join(gem_dir, "lib", "#{gem_name}.rb")
|
47
|
+
File.write(gem_path, source)
|
48
|
+
end
|
49
|
+
|
50
|
+
def add_railtie_dependency
|
51
|
+
gemspec_path = File.join(gem_dir, "#{gem_name}.gemspec")
|
52
|
+
|
53
|
+
lines = File.read(gemspec_path).split("\n")
|
54
|
+
lines.insert(-2, " spec.add_dependency 'railties'")
|
55
|
+
File.write(gemspec_path, lines.join("\n"))
|
56
|
+
end
|
57
|
+
|
58
|
+
def copy_assets
|
59
|
+
asset_src_path = File.join(wrap_dir, "assets")
|
60
|
+
FileUtils.mkdir_p(vendor_path)
|
61
|
+
FileUtils.cp_r(asset_src_path, vendor_path)
|
62
|
+
|
63
|
+
rename_directories
|
64
|
+
separate_namespace
|
65
|
+
end
|
66
|
+
|
67
|
+
def fix_asset_references
|
68
|
+
Find.find(vendor_path) do |path|
|
69
|
+
next unless path.match(/\.css$/)
|
70
|
+
update_url_for_asset_pipeline(path)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def write_readme
|
75
|
+
html_path = File.join(wrap_dir, "html", "index.html")
|
76
|
+
return unless File.exists?(html_path)
|
77
|
+
|
78
|
+
html = File.read(html_path)
|
79
|
+
|
80
|
+
js_paths = []
|
81
|
+
html.scan(/<script src="([^\"]+)"><\/script>/) do
|
82
|
+
raw_url = $1
|
83
|
+
js_paths << raw_url.gsub(/^\.\.\/assets\/js/, gem_name)
|
84
|
+
end
|
85
|
+
|
86
|
+
css_paths = []
|
87
|
+
html.scan(/<link rel="stylesheet" href="([^\"]+)" \/>/) do
|
88
|
+
raw_url = $1
|
89
|
+
css_paths << raw_url.gsub(/^\.\.\/assets\/css/, gem_name)
|
90
|
+
end
|
91
|
+
|
92
|
+
source = <<-EOS.unindent
|
93
|
+
# #{gem_name.capitalize}
|
94
|
+
|
95
|
+
Wrap Bootstrap design template - #{gem_name.capitalize}
|
96
|
+
This gem is generated by [wrap-bootstrap-rails](https://github.com/k0kubun/wrap-bootstrap-rails)
|
97
|
+
|
98
|
+
## Usage
|
99
|
+
|
100
|
+
Add this line to your application's Gemfile:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
gem '#{gem_name}', git: 'git://github.com/#{gem_name}/#{gem_name}.git'
|
104
|
+
```
|
105
|
+
|
106
|
+
## Javascripts
|
107
|
+
|
108
|
+
You may want to require:
|
109
|
+
|
110
|
+
```
|
111
|
+
#{js_paths.map{ |path| '//= require ' + path }.join("\n ")}
|
112
|
+
```
|
113
|
+
|
114
|
+
## Stylesheets
|
115
|
+
|
116
|
+
You may want to require:
|
117
|
+
|
118
|
+
```
|
119
|
+
/*
|
120
|
+
#{css_paths.map{ |path| ' *= require ' + path }.join("\n ")}
|
121
|
+
*/
|
122
|
+
```
|
123
|
+
EOS
|
124
|
+
|
125
|
+
readme_path = File.join(gem_dir, "README.md")
|
126
|
+
File.write(readme_path, source)
|
127
|
+
end
|
128
|
+
|
129
|
+
def update_url_for_asset_pipeline(path)
|
130
|
+
source = File.read(path)
|
131
|
+
source.gsub!(/url\((\"|\')(.+?)(\'|\")\)/) do
|
132
|
+
url = $2
|
133
|
+
case url
|
134
|
+
when /^\.\.\//
|
135
|
+
url.gsub!(/^\.\.\/[^\/]+/, "/assets/#{gem_name}")
|
136
|
+
when /^[^\/]+\//
|
137
|
+
url.gsub!(/^[^\/]+/, "/assets/#{gem_name}")
|
138
|
+
end
|
139
|
+
"url('#{url}')"
|
140
|
+
end
|
141
|
+
|
142
|
+
File.write(path, source)
|
143
|
+
end
|
144
|
+
|
145
|
+
def rename_directories
|
146
|
+
DIRNAME_MAP.each do |org_name, new_name|
|
147
|
+
org_path = File.join(vendor_path, "assets", org_name)
|
148
|
+
if File.exists?(org_path)
|
149
|
+
new_path = File.join(vendor_path, "assets", new_name)
|
150
|
+
FileUtils.mv(org_path, new_path)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def separate_namespace
|
156
|
+
working_dir = File.join("/tmp", "wrap-bootstrap-rails", gem_name)
|
157
|
+
|
158
|
+
vendor_assets_path = File.join(vendor_path, "assets")
|
159
|
+
Dir.foreach(vendor_assets_path) do |dir|
|
160
|
+
next if dir.match(/^\./)
|
161
|
+
target_dir = File.join(vendor_assets_path, dir)
|
162
|
+
|
163
|
+
FileUtils.rm_rf(working_dir)
|
164
|
+
FileUtils.mkdir_p(working_dir)
|
165
|
+
copy_all_in(target_dir, working_dir)
|
166
|
+
FileUtils.mv(working_dir, target_dir)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def copy_all_in(src_dir, dst_dir)
|
171
|
+
Dir.foreach(src_dir) do |dir|
|
172
|
+
next if dir.match(/^\./)
|
173
|
+
|
174
|
+
target_path = File.join(src_dir, dir)
|
175
|
+
dst_path = File.join(dst_dir, dir)
|
176
|
+
FileUtils.mv(target_path, dst_path)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def check_gem_dir_existence
|
181
|
+
if File.exists?(gem_dir)
|
182
|
+
abort_execution("Gem create destination ('#{gem_dir}') already exists.")
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def check_bundler_existence
|
187
|
+
if `which bundle`.empty?
|
188
|
+
abort_execution("Could not find bundle in your PATH.")
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def abort_execution(message)
|
193
|
+
puts "\033[#{FG_RED}m#{message} Aborting.\033[0m"
|
194
|
+
exit
|
195
|
+
end
|
196
|
+
|
197
|
+
def vendor_path
|
198
|
+
@vendor_path ||= File.join(gem_dir, "vendor")
|
199
|
+
end
|
200
|
+
|
201
|
+
def gem_name
|
202
|
+
@gem_name
|
203
|
+
end
|
204
|
+
|
205
|
+
def gem_dir
|
206
|
+
@gem_dir ||= File.join(File.expand_path("."), gem_name)
|
207
|
+
end
|
208
|
+
|
209
|
+
def wrap_dir
|
210
|
+
@wrap_dir
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wrap/bootstrap/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wrap-bootstrap-rails"
|
8
|
+
spec.version = Wrap::Bootstrap::Rails::VERSION
|
9
|
+
spec.authors = ["Takashi Kokubun"]
|
10
|
+
spec.email = ["takashikkbn@gmail.com"]
|
11
|
+
spec.summary = %q{Gem generator for Wrap Bootstrap design templates}
|
12
|
+
spec.description = %q{Gem generator for Wrap Bootstrap design templates}
|
13
|
+
spec.homepage = "https://github.com/k0kubun/wrap-bootstrap-rails"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "unindent"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wrap-bootstrap-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takashi Kokubun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unindent
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Gem generator for Wrap Bootstrap design templates
|
56
|
+
email:
|
57
|
+
- takashikkbn@gmail.com
|
58
|
+
executables:
|
59
|
+
- wrapbr
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/wrapbr
|
69
|
+
- lib/wrap/bootstrap/rails.rb
|
70
|
+
- lib/wrap/bootstrap/rails/version.rb
|
71
|
+
- wrap-bootstrap-rails.gemspec
|
72
|
+
homepage: https://github.com/k0kubun/wrap-bootstrap-rails
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.0.3
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Gem generator for Wrap Bootstrap design templates
|
96
|
+
test_files: []
|