bootscaf 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4d71e7595198b1df9299f3a233afea2b8265284
4
+ data.tar.gz: 8478bad6011d8b3f68e579f9daf562d6ca81e057
5
+ SHA512:
6
+ metadata.gz: 70fcceebeef63283179db8aca78b59f8bd5b245f89ba4589e6e0e8fea78f2b0453d4b97664bc66ce38e0894178990d934acb5fefa04660976ba71bc1c5fda81e
7
+ data.tar.gz: 968d3af3e6dc2b3257f4a228327639fea8e7a1f037ac590c2b187c4e305f65d6e43d62de531dfd19f35015d1bd1112c97498f9ca1568160b5f2c2cbd1d486a7b
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,17 @@
1
+ language: ruby
2
+ script: "bundle exec rspec spec"
3
+ rvm:
4
+ - jruby-19mode
5
+ - 1.9.2
6
+ - 1.9.3
7
+ - 2.0.0
8
+ - 2.1.0
9
+ - 2.1.5
10
+ gemfile:
11
+ - Gemfile
12
+ notifications:
13
+ recipients:
14
+ - matt@thrivesmart.com
15
+ branches:
16
+ only:
17
+ - master
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bootscaf.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Matthew Moore
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,58 @@
1
+ # Bootscaf
2
+
3
+ [![Build Status](https://travis-ci.org/thrivesmart/bootscaf.svg)](https://travis-ci.org/thrivesmart/bootscaf)
4
+
5
+ Bootscaf is a ruby gem that turns the default `rails generate scaffold`s into fully bootstrappified scaffolds.
6
+
7
+ Read more in the original blog post.
8
+
9
+ * Supported [Bootstrap](http://getbootstrap.com/) Version: `3.x`
10
+ * Supported [JQuery](http://jquery.com/) Version: `2.x`
11
+ * Supported [Ruby on Rails](http://rubyonrails.org/) Version: `4.x`
12
+
13
+ ## Installation
14
+
15
+ Get it going in your `Gemfile`:
16
+
17
+ ```ruby
18
+ gem 'bootscaf', group: :development
19
+ ```
20
+
21
+ Install it with `bundle` from your command line:
22
+
23
+ ```sh
24
+ bundle
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Run the `bootscaf` binary on a single scaffold (e.g. `users`) from your rails project's base directory:
30
+
31
+ ```sh
32
+ bootscaf update NNNs
33
+ ```
34
+
35
+ __OR__ Run `bootscaf` binary on all scaffolds:
36
+
37
+
38
+ ```sh
39
+ bootscaf update --all
40
+ ```
41
+
42
+ Of course, get help any time simply by running the naked `bootscaf` binary:
43
+
44
+ ```sh
45
+ bootscaf
46
+ ```
47
+
48
+ ## Running Tests
49
+
50
+ `bundle exec rspec spec`
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it ( https://github.com/thrivesmart/bootscaf/fork )
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
Binary file
Binary file
Binary file
@@ -0,0 +1,13 @@
1
+ //body { padding-top: 45px; }
2
+
3
+ tr#empty-table { text-align: center; opacity: 0.5;}
4
+ .field_with_errors { display:inline; }
5
+
6
+ #content-footer {
7
+ padding-top: 40px;
8
+ padding-bottom: 40px;
9
+ margin-top: 100px;
10
+ color: #777;
11
+ text-align: center;
12
+ border-top: 1px solid #e5e5e5;
13
+ }
@@ -0,0 +1,3 @@
1
+ .select-all-on-click.form-control[readonly] {
2
+ cursor:pointer;
3
+ }
@@ -0,0 +1 @@
1
+ tr.linked-row { cursor: pointer; }
@@ -0,0 +1,17 @@
1
+ .tablesorter thead {
2
+ cursor:pointer;
3
+ }
4
+ .tablesorter th {
5
+ background-position:right 9px center;
6
+ background-size: 10px 11.23px;
7
+ background-repeat: no-repeat;
8
+ }
9
+ .tablesorter th span {
10
+ padding-right: 10px;
11
+ }
12
+ .tablesorter th.headerSortUp {
13
+ background-image: image-url('tablesorter-up.png');
14
+ }
15
+ .tablesorter th.headerSortDown {
16
+ background-image: image-url('tablesorter-down.png');
17
+ }
data/bin/bootscaf ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bootscaf/cli'
3
+ Bootscaf::CLI.start
data/bootscaf.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bootscaf/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bootscaf"
8
+ spec.version = Bootscaf::VERSION
9
+ spec.authors = ["Matthew Moore"]
10
+ spec.email = ["hello@thrivesmart.com"]
11
+ spec.summary = %q{Overwrites a Ruby on Rails scaffold generation and makes it look great.}
12
+ spec.description = %q{Really great.}
13
+ spec.homepage = "https://github.com/thrivesmart/bootscaf"
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 "thor"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,182 @@
1
+ # encoding: utf-8
2
+ require 'thor'
3
+ require 'net/http'
4
+ require_relative 'utils.rb'
5
+
6
+ module Bootscaf
7
+ class CLI < Thor
8
+ YESSES = ['y', 'yes', 'Y', 'Yes', 'YES']
9
+ NOS = ['n', 'no', 'N', 'No', 'NO']
10
+ LAST_KNOWN_BOOTSTRAP_VERSION = '3.3.1/'
11
+ LAST_KNOWN_JQUERY_VERSION = '2.1.1'
12
+ LAST_KNOWN_JQUERY_UI_VERSION = '1.11.2'
13
+
14
+ desc "version", "Ouputs the current version of Bootscaf"
15
+ def version
16
+ puts Bootscaf::VERSION
17
+ end
18
+
19
+
20
+ desc "update PLURALMODELNAME", "Updates the scaffold for the given PLURALMODELNAME (optionally, use --all)"
21
+ option :all, :type => :boolean
22
+ def update(modelname = nil)
23
+ puts options[:all] ? "Running on *all* models scaffolds." : "Running on #{modelname} scaffolds."
24
+
25
+ models = options[:all] ? [] : [ modelname ]
26
+ if options[:all]
27
+ models = Dir.glob("#{Dir.pwd}/app/views/*").select { |f| File.directory? f }.map { |f| f.split('/app/views/').last }.reject { |f| f == 'layouts' }
28
+ end
29
+
30
+ is_mac = (RbConfig::CONFIG['host_os'] =~ /^darwin/) >= 0
31
+ inplace_command = is_mac ? "-i ''" : '--in-place'
32
+
33
+ print "Would you like to update app/views/layouts/application.html.erb [y/n(default)]? "
34
+ update_apphtml = $stdin.gets.strip
35
+ if YESSES.include?(update_apphtml)
36
+
37
+ print "Checking for most recent bootstrap cdn version... "
38
+ uri = URI.parse("https://raw.githubusercontent.com/MaxCDN/bootstrap-cdn/develop/public/twitter-bootstrap/latest")
39
+ http = Net::HTTP.new(uri.host, uri.port); http.use_ssl = true
40
+ latest_bootstrap_version = http.get(uri.request_uri).body
41
+ latest_bootstrap_version.each_line { |line| }
42
+ print "#{latest_bootstrap_version}\n"
43
+ latest_boostrap_version ||= LAST_KNOWN_BOOTSTRAP_VERSION
44
+
45
+
46
+ print "Checking for most recent jquery cdn version... "
47
+ uri = URI.parse("http://code.jquery.com/")
48
+ http = Net::HTTP.new(uri.host, uri.port)
49
+ http_body = http.get(uri.request_uri).body
50
+ minor_version = /, <a href='\/jquery\-2\.(.*?)\.min\.js'>minified<\/a>/.match(http_body)[1]
51
+ latest_jquery_version = "2.#{minor_version}"
52
+ print "#{latest_jquery_version}\n"
53
+ latest_boostrap_version ||= LAST_KNOWN_BOOTSTRAP_VERSION
54
+
55
+ print "Checking for most recent jquery-ui version... "
56
+ minor_version = /, <a href='\/ui\/(.*?)\/jquery-ui.min.js'>minified<\/a>/.match(http_body)[1]
57
+ latest_jquery_ui_version = "#{minor_version}"
58
+ print "#{latest_jquery_ui_version}\n"
59
+ latest_jquery_ui_version ||= LAST_KNOWN_JQUERY_UI_VERSION
60
+
61
+ print "Updating app/views/layouts/application.html.erb. "
62
+ print `sed #{inplace_command} -e 's/<title>/<title><%= yield :page_title %>/' app/views/layouts/application.html.erb`
63
+ print `sed #{inplace_command} -e "s/<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>/<link href=\\"\\/\\/maxcdn.bootstrapcdn.com\\/bootstrap\\/#{latest_boostrap_version.gsub(/\//,'\\/')}css\\/bootstrap.min.css\\" rel=\\"stylesheet\\">\\\n<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>/" app/views/layouts/application.html.erb`
64
+ print `sed #{inplace_command} -e "s/<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>/\\\n/" app/views/layouts/application.html.erb`
65
+ print `sed #{inplace_command} -e 's/<\\/head>/ <%= yield :after_css %>\\\n<\\/head>/' app/views/layouts/application.html.erb`
66
+ print `sed #{inplace_command} -e 's/<body>/<body class="controller-<%= controller.controller_name.dasherize %> action-<%= controller.action_name.dasherize %>"> <nav class="navbar navbar-default navbar-inverse" role="navigation">\\\n <div class="container">\\\n <div class="navbar-header">\\\n <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">\\\n <span class="sr-only">Toggle navigation<\\/span>\\\n <span class="icon-bar"><\\/span>\\\n <span class="icon-bar"><\\/span>\\\n <span class="icon-bar"><\\/span>\\\n <\\/button>\\\n <a class="navbar-brand" href="\\/">Foo<\\/a>\\\n <\\/div>\\\n <div id="navbar" class="navbar-collapse collapse">\\\n <ul class="nav navbar-nav">\\\n <li<%= request.path == "\\/" ? " class=\\\\"active\\\\"".html_safe : "" %>><a href="\\/">Home<\\/a><\\/li>\\\n <\\/ul> \\\n <ul class="nav navbar-nav navbar-right">\\\n <li class="bar"><a href="\\/">Bar<\\/a><\\/li>\\\n <\\/ul>\\\n <\\/div>\\\n <\\/div>\\\n <\\/nav>\\\n <% unless notice.blank? %>\\\n <div id="notice" class="alert alert-success" role="alert">\\\n <div class="container">\\\n <%= notice %>\\\n <\\/div>\\\n <\\/div>\\\n <% end %>/' app/views/layouts/application.html.erb`
67
+ print `sed #{inplace_command} -e 's/<%= yield %>/<%= yield %>\\\n <footer id="content-footer" role="contentinfo">\\\n <div class="container">\\\n <p class="align-center">\\\n Copyright \\&copy; <%= Time.now.year %> Foo · all rights reserved.\\\n <\\/p>\\\n <\\/div>\\\n <\\/footer>\\\n\\\n <%= yield :before_js %>\\\n <% unless ENV["GOOGLE_ANALYTICS_ID"].blank? %>\\\n <script>\\\n (function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){\\\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\\\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\\\n })(window,document,"script","\\/\\/www.google-analytics.com\\/analytics.js","ga");\\\n ga("create", "<%= ENV["GOOGLE_ANALYTICS_ID"] %>", "auto");\\\n ga("send", "pageview");\\\n <\\/script>\\\n <% end %>\\\n <script src="\\/\\/code.jquery.com\\/jquery-#{latest_jquery_version}.min.js"><\\/script>\\\n <script src="\\/\\/code.jquery.com\\/ui\\/#{latest_jquery_ui_version}\\/jquery-ui.min.js"><\\/script>\\\n <script src="\\/\\/maxcdn.bootstrapcdn.com\\/bootstrap\\/#{latest_boostrap_version.gsub(/\//,'\\/')}js\\/bootstrap.min.js"><\\/script>\\\n <%= javascript_include_tag "application", "data-turbolinks-track" => true %>\\\n<%= yield :after_js %>\\\n/' app/views/layouts/application.html.erb`
68
+ print "\n"
69
+
70
+ print "Removing '//= require jquery' from app/assets/javascripts/application.js "
71
+ print `sed #{inplace_command} -e 's/\\/\\/= require jquery$//' app/assets/javascripts/application.js`
72
+ print "\n"
73
+ end
74
+
75
+ print "Would you like to overwrite scaffolds.css.scss with the bootrapified version [y/n(default)]? "
76
+ use_scaffolds_css = $stdin.gets.strip
77
+ if YESSES.include?(use_scaffolds_css)
78
+ FileUtils.cp "#{File.expand_path(File.dirname(__FILE__))}/../../assets/stylesheets/scaffolds.css.scss", "#{Dir.pwd}/app/assets/stylesheets"
79
+ print "Wrote assets/stylesheets/scaffolds.css.scss\n"
80
+ end
81
+
82
+ print "Would you like to use tablesorter [y(default)/n]? "
83
+ use_tablesorter = $stdin.gets.strip
84
+ unless NOS.include?(use_tablesorter)
85
+ uri = URI.parse('https://raw.githubusercontent.com/christianbach/tablesorter/master/jquery.tablesorter.js')
86
+ http = Net::HTTP.new(uri.host, uri.port); http.use_ssl = true
87
+ http_body = http.get(uri.request_uri).body
88
+ written = File.open("#{Dir.pwd}/app/assets/javascripts/jquery.tablesorter.js", 'w') { |file| file.write(http_body) }
89
+ print "Wrote #{written} - app/assets/javascripts/jquery.tablesorter.js\n"
90
+
91
+ tablesorter_init_body = "$('table.tablesorter').tablesorter();\n"
92
+ written = File.open("#{Dir.pwd}/app/assets/javascripts/jquery.tablesorterinit.js", 'w') { |file| file.write(tablesorter_init_body) }
93
+ print "Wrote #{written} - app/assets/javascripts/jquery.tablesorterinit.js\n"
94
+
95
+ FileUtils.cp "#{File.expand_path(File.dirname(__FILE__))}/../../assets/images/tablesorter-down.png", "#{Dir.pwd}/app/assets/images"
96
+ print "Wrote assets/images/tablesorter-down.png\n"
97
+ FileUtils.cp "#{File.expand_path(File.dirname(__FILE__))}/../../assets/images/tablesorter-up.png", "#{Dir.pwd}/app/assets/images"
98
+ print "Wrote assets/images/tablesorter-up.png\n"
99
+ FileUtils.cp "#{File.expand_path(File.dirname(__FILE__))}/../../assets/images/tablesorter.png", "#{Dir.pwd}/app/assets/images"
100
+ print "Wrote assets/images/tablesorter.png\n"
101
+
102
+ FileUtils.cp "#{File.expand_path(File.dirname(__FILE__))}/../../assets/stylesheets/tablesorter.css.scss", "#{Dir.pwd}/app/assets/stylesheets"
103
+ print "Wrote assets/stylesheets/tablesorter.css.scss\n"
104
+ end
105
+
106
+ print "Would you like to make entire index.html.erb table rows clickable [y(default)/n]? "
107
+ use_clickable_rows = $stdin.gets.strip
108
+ unless NOS.include?(use_clickable_rows)
109
+ linkedrow_init_body = "$(\".linked-row\").click(function() { window.document.location = $(this).attr(\"data-href\"); });\n"
110
+ written = File.open("#{Dir.pwd}/app/assets/javascripts/table-linked-row.js", 'w') { |file| file.write(linkedrow_init_body) }
111
+ print "Wrote #{written} - app/assets/javascripts/table-linked-row.js\n"
112
+
113
+ FileUtils.cp "#{File.expand_path(File.dirname(__FILE__))}/../../assets/stylesheets/table-linked-row.css.scss", "#{Dir.pwd}/app/assets/stylesheets"
114
+ print "Wrote assets/stylesheets/table-linked-row.css.scss\n"
115
+ end
116
+
117
+ print "Would you like to add a 'click to select-all' input element [y(default)/n]? "
118
+ use_click_to_selectall = $stdin.gets.strip
119
+ unless NOS.include?(use_click_to_selectall)
120
+ selectall_init_body = "$('.select-all-on-click').click(function () { this.select(); });\n"
121
+ written = File.open("#{Dir.pwd}/app/assets/javascripts/select-all-on-click.js", 'w') { |file| file.write(selectall_init_body) }
122
+ print "Wrote #{written} - app/assets/javascripts/select-all-on-click.js\n"
123
+
124
+ FileUtils.cp "#{File.expand_path(File.dirname(__FILE__))}/../../assets/stylesheets/select-all-on-click.css.scss", "#{Dir.pwd}/app/assets/stylesheets"
125
+ print "Wrote assets/stylesheets/select-all-on-click.css.scss\n"
126
+ end
127
+
128
+ models.each do |modelname|
129
+ print "\n\nWorking on model:#{modelname}\n\n"
130
+
131
+ print "Updating app/views/#{modelname}/_form.html.erb. "
132
+ print `sed #{inplace_command} -e 's/<div id="error_explanation">/<div id="error_explanation" class="alert alert-danger" role="alert">/' app/views/#{modelname}/_form.html.erb`
133
+ print `sed #{inplace_command} -e 's/<h2>/<strong>/' app/views/#{modelname}/_form.html.erb`
134
+ print `sed #{inplace_command} -e 's/<\\/h2>/<\\/strong>/' app/views/#{modelname}/_form.html.erb`
135
+ print `sed #{inplace_command} -e 's/<div class="field">/<div class="row">/g' app/views/#{modelname}/_form.html.erb`
136
+ print `sed #{inplace_command} -e 's/<%= f.label :\\(.*\\) %><br>/<div class="form-group<%= f.object.errors[:\\1].empty? ? "" : " has-error has-feedback" %>">\\\n<%= f.label :\\1, { class: "control-label col-sm-2" } %>\\\n<div class="col-sm-10">/g' app/views/#{modelname}/_form.html.erb`
137
+ print `sed #{inplace_command} -e 's/<%= f.\\(.*\\)_field :\\(.*\\) %>/<%= f.\\1_field :\\2, { class: "form-control" } %>\\\n<\\/div>\\\n<\\/div>/g' app/views/#{modelname}/_form.html.erb`
138
+ print `sed #{inplace_command} -e 's/<div class="actions">/<div class="actions text-center">/' app/views/#{modelname}/_form.html.erb`
139
+ print `sed #{inplace_command} -e 's/<%= f.submit %>/<%= f.submit class: "btn btn-success" %>/' app/views/#{modelname}/_form.html.erb`
140
+ print "\n"
141
+
142
+ print "Updating app/views/#{modelname}/edit.html.erb. "
143
+ print `sed #{inplace_command} -e 's/<h1>Editing \\(.*\\)<\\/h1>/<% content_for :page_title do %>\\\nEdit \\1 - \\\n<% end %>\\\n<div class="container">\\\n<div class="page-header">\\\n<h1>Editing \\1<\\/h1>\\\n<\\/div>/' app/views/#{modelname}/edit.html.erb`
144
+ print `sed #{inplace_command} -e 's/<%= link_to '\\''Show'\\'', @\\(.*\\) %> \\|/<div class="clearfix"><\\/div>\\\n<div class="pull-left">\\\n<%= link_to "<span class=\\\\"glyphicon glyphicon-ban-circle\\\\" aria-hidden=\\\\"true\\\\"><\\/span> Cancel".html_safe, @\\1, class: "btn btn-default" %>\\\n<\\/div>/' app/views/#{modelname}/edit.html.erb`
145
+ print `sed #{inplace_command} -e 's/<%= link_to '\\''Back'\\'', \\(.*\\)s_path %>/<div class="pull-right">\\\n<%= link_to "<span class=\\\\"glyphicon glyphicon-trash\\\\" aria-hidden=\\\\"true\\\\"><\\/span> Delete \\1...".html_safe, @\\1, method: :delete, data: { confirm: "Are you sure you want to delete this \\1?" }, class: "btn btn-danger" %>\\\n<\\/div>\\\n<\\/div>/' app/views/#{modelname}/edit.html.erb`
146
+ print "\n"
147
+
148
+ print "Updating app/views/#{modelname}/index.html.erb. "
149
+ print `sed #{inplace_command} -e 's/<h1>Listing \\(.*\\)s<\\/h1>/<% content_for :page_title do %>\\\n\\1s - \\\n<% end %>\\\n<div class="container">\\\n<div class="page-header">\\\n<h1>\\\n<div class="pull-left">\\\n<%= link_to "<span class=\\\\"glyphicon glyphicon-step-backward\\\\" aria-hidden=\\\\"true\\\\"><\\/span>".html_safe, "\\/", class: "btn btn-default", title: "Back" %>\\\n\\&nbsp;\\\n<\\/div>\\\n\\\n<div class="pull-right">\\\n<%= link_to "<span class=\\\\"glyphicon glyphicon-plus-sign\\\\" aria-hidden=\\\\"true\\\\"><\\/span> New \\1".html_safe, [:new, :\\1], class: "btn btn-success" %>\\\n<\\/div>\\\nListing \\1s\\\n<\\/h1>\\\n<\\/div>\\\n\\\n<table class="table table-striped table-hover tablesorter" id="\\1s-table">/' app/views/#{modelname}/index.html.erb`
150
+ print `sed #{inplace_command} -e 's/<th>\\(.*\\)<\\/th>/<th><span>\\1<\\/span><\\/th>/g' app/views/#{modelname}/index.html.erb`
151
+ print `sed #{inplace_command} -e 's/<table>//' app/views/#{modelname}/index.html.erb`
152
+ print `sed #{inplace_command} -e 's/<th colspan="3"><\\/th>//' app/views/#{modelname}/index.html.erb`
153
+ print `sed #{inplace_command} -e 's/<td><%= link_to '\\''Show'\\'', \\(.*\\) %><\\/td>//' app/views/#{modelname}/index.html.erb`
154
+ print `sed #{inplace_command} -e 's/<td><%= link_to '\\''Edit'\\'', edit_\\(.*\\)_path(\\(.*\\)) %><\\/td>//' app/views/#{modelname}/index.html.erb`
155
+ print `sed #{inplace_command} -e 's/<td><%= link_to '\\''Destroy'\\'', \\(.*\\), method: :delete, data: { confirm: '\\''Are you sure?'\\'' } %><\\/td>//' app/views/#{modelname}/index.html.erb`
156
+ print `sed #{inplace_command} -e 's/<% @\\(.*\\)s.each do \\|\\(.*\\)\\| %>/<% unless @\\1s.any? %>\\\n<tr id="empty-table">\\\n<td class="bg-warning" colspan="2">No \\1s created yet.<\\/td>\\\n<\\/tr>\\\n<% end %>\\\n<% @\\1s.each do \\|\\1\\| %>\\\n<tr class="linked-row" data-href="<%= \\1_path(\\1) %>">/' app/views/#{modelname}/index.html.erb`
157
+ print `sed #{inplace_command} -e 's/<tr>//' app/views/#{modelname}/index.html.erb`
158
+ print `sed #{inplace_command} -e 's/<thead>/<thead>\\\n<tr>/' app/views/#{modelname}/index.html.erb`
159
+ print `sed #{inplace_command} -e 's/<td><%= \\(.*\\)\\.\\(.*\\) %><\\/td>/<td><%= link_to \\1.\\2, \\1 %><\\/td>/' app/views/#{modelname}/index.html.erb`
160
+ print `sed #{inplace_command} -e 's/<br>//' app/views/#{modelname}/index.html.erb`
161
+ print `sed #{inplace_command} -e 's/<%= link_to '\\''New \\(.*\\)'\\'', new_\\(.*\\)_path %>//' app/views/#{modelname}/index.html.erb`
162
+ print "\n"
163
+
164
+ print "Updating app/views/#{modelname}/new.html.erb. "
165
+ print `sed #{inplace_command} -e 's/<h1>New \\(.*\\)<\\/h1>/<% content_for :page_title do %>\\\nCreate \\1 - \\\n<% end %>\\\n<div class="container">\\\n<div class="page-header">\\\n<h1>\\\nNew \\1\\\n<\\/h1>\\\n<\\/div>/' app/views/#{modelname}/new.html.erb`
166
+ print `sed #{inplace_command} -e 's/<%= link_to '\\''Back'\\'', \\(.*\\)s_path %>/<div class="clearfix"><\\/div>\\\n<%= link_to "<span class=\\\\"glyphicon glyphicon-ban-circle\\\\" aria-hidden=\\\\"true\\\\"><\\/span> Cancel".html_safe, \\1s_path, class: "btn btn-default" %>\\\n<\\/div>/' app/views/#{modelname}/new.html.erb`
167
+ print "\n"
168
+
169
+ print "Updating app/views/#{modelname}/show.html.erb. "
170
+ print `sed #{inplace_command} -e 's/<p id="notice"><%= notice %><\\/p>/<% content_for :page_title do %>\\\n#{Bootscaf::Utils.singularize(modelname)} Details - \\\n<% end %>\\\n<div class="container">\\\n<div class="page-header">\\\n<h1>\\\n<div class="pull-left">\\\n<%= link_to "<span class=\\\\"glyphicon glyphicon-step-backward\\\\" aria-hidden=\\\\"true\\\\"><\\/span>".html_safe, #{modelname}_path, class: "btn btn-default", title: "Back to #{modelname}" %>\\\n\\&nbsp;\\\n<\\/div>\\\n<div class="pull-right">\\\n<%= link_to "<span class=\\\\"glyphicon glyphicon-pencil\\\\" aria-hidden=\\\\"true\\\\"><\\/span> Edit".html_safe, edit_#{Bootscaf::Utils.singularize(modelname)}_path(@#{Bootscaf::Utils.singularize(modelname)}), class: "btn btn-warning" %>\\\n<\\/div>\\\n#{Bootscaf::Utils.singularize(modelname)} Details\\\n<\\/h1>\\\n<\\/div>/' app/views/#{modelname}/show.html.erb`
171
+ print `sed #{inplace_command} -e 's/<p>/<div class="row">/' app/views/#{modelname}/show.html.erb`
172
+ print `sed #{inplace_command} -e 's/<\\/p>/<\\/div>/' app/views/#{modelname}/show.html.erb`
173
+ print `sed #{inplace_command} -e 's/<strong>\\(.*\\):<\\/strong>/<label class="col-sm-3 text-right text-muted">\\1<\\/label>/g' app/views/#{modelname}/show.html.erb`
174
+ print `sed #{inplace_command} -e 's/<%= @\\(.*\\)\\.\\(.*\\) %>/<div class="col-sm-9"><%= @\\1.\\2 %><\\/div>/g' app/views/#{modelname}/show.html.erb`
175
+ print `sed #{inplace_command} -e 's/<%= link_to '\\''Edit'\\'', edit_\\(.*\\)_path(@\\(.*\\)) %> \\|/<\\/div>/' app/views/#{modelname}/show.html.erb`
176
+ print `sed #{inplace_command} -e 's/<%= link_to '\\''Back'\\'', \\(.*\\)s_path %>//' app/views/#{modelname}/show.html.erb`
177
+ print "\n"
178
+ end
179
+ end
180
+
181
+ end
182
+ end
@@ -0,0 +1,22 @@
1
+ module Bootscaf
2
+ module Utils
3
+ def self.singularize(str)
4
+ unless str == str.gsub(/([^aeiouy])ies$/i, '\1y')
5
+ return str.gsub(/([^aeiouy])ies$/i, '\1y')
6
+ end
7
+ unless str == str.gsub(/([^aeiouy]o)es$/, '\1')
8
+ return str.gsub(/([^aeiouy]o)es$/, '\1')
9
+ end
10
+ unless str == str.gsub(/([sxz]|[cs]h)es$/, '\1')
11
+ return str.gsub(/([sxz]|[cs]h)es$/, '\1')
12
+ end
13
+ unless str == str.gsub(/(ss)$/i, '\1')
14
+ return str.gsub(/(ss)$/i, '\1')
15
+ end
16
+ unless str == str.gsub(/s$/i, '')
17
+ return str.gsub(/s$/i, '')
18
+ end
19
+ return str
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Bootscaf
2
+ VERSION = "0.1.1"
3
+ end
data/lib/bootscaf.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "bootscaf/version"
2
+ require "bootscaf/utils"
3
+ require "bootscaf/cli"
4
+
5
+ module Bootscaf
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,20 @@
1
+ require 'bootscaf'
2
+
3
+ describe Bootscaf::VERSION do
4
+ it "should have a version" do
5
+ expect(Bootscaf::VERSION).to_not be_nil
6
+ end
7
+ end
8
+
9
+ describe Bootscaf::Utils do
10
+ it "should have singularize" do
11
+ expect(Bootscaf::Utils.singularize('files')).to eq('file')
12
+ expect(Bootscaf::Utils.singularize('lillies')).to eq('lilly')
13
+ end
14
+ end
15
+
16
+ # describe Bootscaf::CLI do
17
+ # it "should output a version" do
18
+ # expect(subject.command 'version').to output(Bootscaf::VERSION)
19
+ # end
20
+ # end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bootscaf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Moore
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
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.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
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
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Really great.
70
+ email:
71
+ - hello@thrivesmart.com
72
+ executables:
73
+ - bootscaf
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - assets/images/tablesorter-down.png
84
+ - assets/images/tablesorter-up.png
85
+ - assets/images/tablesorter.png
86
+ - assets/stylesheets/scaffolds.css.scss
87
+ - assets/stylesheets/select-all-on-click.css.scss
88
+ - assets/stylesheets/table-linked-row.css.scss
89
+ - assets/stylesheets/tablesorter.css.scss
90
+ - bin/bootscaf
91
+ - bootscaf.gemspec
92
+ - lib/bootscaf.rb
93
+ - lib/bootscaf/cli.rb
94
+ - lib/bootscaf/utils.rb
95
+ - lib/bootscaf/version.rb
96
+ - spec/bootscaf_spec.rb
97
+ homepage: https://github.com/thrivesmart/bootscaf
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.2.2
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Overwrites a Ruby on Rails scaffold generation and makes it look great.
121
+ test_files:
122
+ - spec/bootscaf_spec.rb