convert_to_bootstrap3 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 +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +1 -0
- data/bin/convert_to_bootstrap3 +13 -0
- data/convert_to_bootstrap3.gemspec +29 -0
- data/lib/convert_to_bootstrap3.rb +60 -0
- data/lib/convert_to_bootstrap3/version.rb +3 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ec216477aa293046b44fb0065e0ef7aaa6c1240d
|
4
|
+
data.tar.gz: 4fbec20459edc03e188d73451de91db58485e0c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05ce8fe4994bb22635e09092563864295a6c6d3c1013dd17e38449a461c2e27957cf80fdb3795cc8713277fc0d5e6b63a64b95058166f810d9ae37cdba6bbf38
|
7
|
+
data.tar.gz: 7bb8e864d2a2d4f3620a8b3e18aebc780e5f0cbc0710927545d43b61c85dbafc6ef9e47c25f1eb4b3b8b31c2d9aed2ce87e5db04c7ee63c4304a8d4cb09d5a7b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Damian Mastylo
|
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,53 @@
|
|
1
|
+
# ConvertToBootstrap3
|
2
|
+
|
3
|
+
This gem converts all .html files in a folder from Bootstrap 2.x into Bootstrap 3.0.2 markup. This includes
|
4
|
+
language specific files like .html.erb, or others. You need an active internet connection to use this gem.
|
5
|
+
|
6
|
+
# Dependencies
|
7
|
+
Requires PhantomJS headless browser.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```
|
14
|
+
gem 'convert_to_bootstrap3'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
```
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
```
|
26
|
+
$ gem install convert_to_bootstrap3
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
Go to the root folder of your project, and run the command "convert_to_bootstrap_3" from a terminal or shell.
|
32
|
+
This will go through all your files (including ones in subdirectories) and convert the markup from
|
33
|
+
Bootstrap 2.x to Bootstrap 3.0.2 markup. Spacing/tabbing and identation may, or may not, be
|
34
|
+
altered in the process, and you should NOT consider this production ready code. Reviewing the
|
35
|
+
results and making sure everything is correct manually is recommended, but this tool will
|
36
|
+
considerably lessen your time spent converting the markup in your projects.
|
37
|
+
|
38
|
+
If you want to use ConvertToBootstrap3 in your code do
|
39
|
+
|
40
|
+
```
|
41
|
+
converter = ConvertToBootstrap3::Converter.new
|
42
|
+
converter.convert_in_place("directory/")
|
43
|
+
```
|
44
|
+
|
45
|
+
the directory parameter is optional, but needs to have the forward slash at the end.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it ( http://github.com/dmastylo/convert_to_bootstrap3/fork )
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'convert_to_bootstrap3/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'convert_to_bootstrap3'
|
8
|
+
spec.version = ConvertToBootstrap3::VERSION
|
9
|
+
spec.authors = ['Damian Mastylo']
|
10
|
+
spec.email = ['dmastylo@codequarry.net']
|
11
|
+
spec.summary = %q{ A gem to convert all markup in .html and .html.erb files in a folder from Bootstrap 2 into Bootstrap 3 markup. }
|
12
|
+
spec.description = %q{ A gem to convert all markup in .html and .html.erb files in a folder from Bootstrap 2 into Bootstrap 3 markup. }
|
13
|
+
spec.homepage = 'https://github.com/dmastylo/Convert_To_Bootstrap_3'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = ['convert_to_bootstrap3']
|
18
|
+
# spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
# Runtime dependency
|
23
|
+
spec.add_runtime_dependency 'capybara', '~> 2.2'
|
24
|
+
spec.add_runtime_dependency 'poltergeist', '~> 1.5'
|
25
|
+
|
26
|
+
# Development Dependencies
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.2'
|
29
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'convert_to_bootstrap3/version'
|
2
|
+
require 'capybara'
|
3
|
+
require 'capybara/poltergeist'
|
4
|
+
|
5
|
+
Capybara.default_driver = :poltergeist
|
6
|
+
Capybara.run_server = false
|
7
|
+
|
8
|
+
Capybara.register_driver :poltergeist do |app|
|
9
|
+
Capybara::Poltergeist::Driver.new(app, phantomjs_options: %w(--load-images=false --disk-cache=false))
|
10
|
+
end
|
11
|
+
|
12
|
+
module ConvertToBootstrap3
|
13
|
+
class Converter
|
14
|
+
include Capybara::DSL
|
15
|
+
|
16
|
+
attr_accessor :converter_url
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@converter_url = 'http://code.divshot.com/bootstrap3_upgrader/'
|
20
|
+
end
|
21
|
+
|
22
|
+
def convert_in_place(directory = "")
|
23
|
+
directory << '**/*.html*'
|
24
|
+
|
25
|
+
visit @converter_url
|
26
|
+
|
27
|
+
all_files = Dir.glob(directory).reject { |file| File.directory? file }
|
28
|
+
|
29
|
+
all_files.each { |file| convert_file_contents(file) }
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def convert_file_contents(file)
|
35
|
+
file_contents = File.read(file)
|
36
|
+
|
37
|
+
fill_in 'source', with: file_contents
|
38
|
+
click_button 'Convert This Code'
|
39
|
+
|
40
|
+
all(:xpath, "//textarea[@id='result']").each do |a|
|
41
|
+
result = fix_embedded_language_tags a.value
|
42
|
+
File.open(file, 'w+') { |f| f.write(result) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def fix_embedded_language_tags(string)
|
47
|
+
fix_php_tags fix_ruby_tags string
|
48
|
+
end
|
49
|
+
|
50
|
+
def fix_ruby_tags(string)
|
51
|
+
string.gsub(/<%=/, '<%=').gsub(/<%#/, '<%#').gsub(/<%-/, '<%-')
|
52
|
+
.gsub(/<%/, '<%').gsub(/=>/, '=>').gsub(/%>/, '%>')
|
53
|
+
end
|
54
|
+
|
55
|
+
def fix_php_tags(string)
|
56
|
+
string.gsub(/(<!--)\?(php)/, '<?php').gsub(/(<!--)\?/, '<?').gsub(/\?(-->)/, '?>')
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: convert_to_bootstrap3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Damian Mastylo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capybara
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: poltergeist
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.2'
|
69
|
+
description: " A gem to convert all markup in .html and .html.erb files in a folder
|
70
|
+
from Bootstrap 2 into Bootstrap 3 markup. "
|
71
|
+
email:
|
72
|
+
- dmastylo@codequarry.net
|
73
|
+
executables:
|
74
|
+
- convert_to_bootstrap3
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/convert_to_bootstrap3
|
84
|
+
- convert_to_bootstrap3.gemspec
|
85
|
+
- lib/convert_to_bootstrap3.rb
|
86
|
+
- lib/convert_to_bootstrap3/version.rb
|
87
|
+
homepage: https://github.com/dmastylo/Convert_To_Bootstrap_3
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: A gem to convert all markup in .html and .html.erb files in a folder from
|
111
|
+
Bootstrap 2 into Bootstrap 3 markup.
|
112
|
+
test_files: []
|