blueberry_rails 0.3.4 → 0.3.5
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 +4 -4
- data/README.md +43 -0
- data/lib/blueberry_rails/app_builder.rb +53 -15
- data/lib/blueberry_rails/generators/app_generator.rb +30 -17
- data/lib/blueberry_rails/version.rb +2 -2
- data/spec/blueberry_rails_spec.rb +18 -3
- data/spec/support/blueberry_rails_helpers.rb +10 -2
- data/templates/Gemfile_custom.erb +15 -2
- data/templates/{README.md → README.md.erb} +2 -2
- data/templates/{gitignore_custom → gitignore_custom.erb} +4 -1
- data/templates/gulp/application.js.coffee +11 -0
- data/templates/gulp/application.sass +10 -0
- data/templates/gulp/config.coffee +47 -0
- data/templates/gulp/global.coffee +3 -0
- data/templates/gulp/global.sass +8 -0
- data/templates/gulp/gulp_helper.rb +16 -0
- data/templates/gulp/gulpfile.js +20 -0
- data/templates/gulp/message.coffee +1 -0
- data/templates/gulp/package.json +53 -0
- data/templates/gulp/rev_manifest.rb +5 -0
- data/templates/gulp/tasks/browserSync.coffee +6 -0
- data/templates/gulp/tasks/browserify.coffee +50 -0
- data/templates/gulp/tasks/build.coffee +25 -0
- data/templates/gulp/tasks/clean.coffee +6 -0
- data/templates/gulp/tasks/default.coffee +3 -0
- data/templates/gulp/tasks/fontIcons/generateIconSass.coffee +23 -0
- data/templates/gulp/tasks/fontIcons/index.coffee +9 -0
- data/templates/gulp/tasks/fontIcons/template.sass +33 -0
- data/templates/gulp/tasks/images.coffee +12 -0
- data/templates/gulp/tasks/rev/index.coffee +12 -0
- data/templates/gulp/tasks/rev/rev-assets.coffee +11 -0
- data/templates/gulp/tasks/rev/rev-font-workaround.coffee +49 -0
- data/templates/gulp/tasks/sass.coffee +24 -0
- data/templates/gulp/tasks/watch.coffee +14 -0
- data/templates/gulp/tasks/watchify.coffee +6 -0
- data/templates/gulp/util/bundleLogger.coffee +23 -0
- data/templates/gulp/util/handleErrors.coffee +11 -0
- data/templates/spec_helper.rb +1 -0
- metadata +33 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 720e38eaad71e9e817151d5467b60e1828164130
|
4
|
+
data.tar.gz: 5ce3b00ee48fab83f4bf1902eb4411f57a262b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9d218811b40d36d6e701028d749666f387aba9f7841db98bbe1ef06c5b28d74e60e902217574902b147ff05a3e8dc0f22df05e7e49268613150b681c7379832
|
7
|
+
data.tar.gz: 0945a97e587b73ddcc5be38420eeea6b19d6cae4d6a3b1b5f684cc2eec1de869a088ecbbbd1c0db5ee082ddbd1e72433bac0ac336f0b0b9d8e7449059ce14438
|
data/README.md
CHANGED
@@ -26,6 +26,10 @@ Devise model
|
|
26
26
|
|
27
27
|
--devise_model User
|
28
28
|
|
29
|
+
Use Gulp instead of Asset Pipeline
|
30
|
+
|
31
|
+
--gulp
|
32
|
+
|
29
33
|
## Gems
|
30
34
|
|
31
35
|
Blueberry Rails template contains following gems by default:
|
@@ -46,6 +50,45 @@ Testing related:
|
|
46
50
|
* [Factory Girl](https://github.com/rspec/rspec-rails) as a fixtures replacement
|
47
51
|
* [Rspec](https://github.com/rspec/rspec-rails)
|
48
52
|
|
53
|
+
## Gulp
|
54
|
+
|
55
|
+
Based on [Gulp on Rails: Replacing the Asset Pipeline](http://viget.com/extend/gulp-rails-asset-pipeline) and [corresponding GitHub repository](https://github.com/vigetlabs/gulp-rails-pipeline).
|
56
|
+
|
57
|
+
$ blueberry_rails newproject --gulp
|
58
|
+
$ npm install
|
59
|
+
|
60
|
+
Default Gulp task, compiles stylesheets/javascripts and starts BrowserSync (for frontend dev)
|
61
|
+
|
62
|
+
$ gulp
|
63
|
+
|
64
|
+
Compile all assets w/o BrowserSync (for backend dev)
|
65
|
+
|
66
|
+
$ gulp development
|
67
|
+
|
68
|
+
Generate production ready assets (including fingerprinting)
|
69
|
+
|
70
|
+
$ gulp build
|
71
|
+
|
72
|
+
Start BrowserSync
|
73
|
+
|
74
|
+
$ gulp watch
|
75
|
+
|
76
|
+
Optimize image size
|
77
|
+
|
78
|
+
$ gulp images
|
79
|
+
|
80
|
+
Generate font icons from SVGs
|
81
|
+
|
82
|
+
$ gulp fontIcons
|
83
|
+
|
84
|
+
Add fingerprints to assets
|
85
|
+
|
86
|
+
$ gulp rev
|
87
|
+
|
88
|
+
Remove all assets
|
89
|
+
|
90
|
+
$ gulp clean
|
91
|
+
|
49
92
|
## Other great stuff
|
50
93
|
|
51
94
|
* Do not secret token in the repo - load it via ENV variable
|
@@ -4,11 +4,11 @@ module BlueberryRails
|
|
4
4
|
include BlueberryRails::ActionHelpers
|
5
5
|
|
6
6
|
def readme
|
7
|
-
|
7
|
+
template 'README.md.erb', 'README.md'
|
8
8
|
end
|
9
9
|
|
10
10
|
def gitignore
|
11
|
-
|
11
|
+
template 'gitignore_custom.erb', '.gitignore'
|
12
12
|
end
|
13
13
|
|
14
14
|
def gemfile
|
@@ -20,7 +20,13 @@ module BlueberryRails
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def disable_xml_params
|
23
|
-
copy_file 'disable_xml_params.rb',
|
23
|
+
copy_file 'disable_xml_params.rb',
|
24
|
+
'config/initializers/disable_xml_params.rb'
|
25
|
+
end
|
26
|
+
|
27
|
+
def hound_config
|
28
|
+
copy_file '../.hound.yml', '.hound.yml'
|
29
|
+
copy_file '../.rubocop.yml', '.rubocop.yml'
|
24
30
|
end
|
25
31
|
|
26
32
|
def setup_mailer_hosts
|
@@ -30,11 +36,6 @@ module BlueberryRails
|
|
30
36
|
action_mailer_host 'production', "#{app_name}.com"
|
31
37
|
end
|
32
38
|
|
33
|
-
def set_ruby_to_version_being_used
|
34
|
-
inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
|
35
|
-
after: /source 'https:\/\/rubygems.org'/
|
36
|
-
end
|
37
|
-
|
38
39
|
def use_postgres_config_template
|
39
40
|
template 'database.yml.erb', 'config/database.yml',
|
40
41
|
force: true
|
@@ -62,18 +63,19 @@ module BlueberryRails
|
|
62
63
|
copy_file 'pryrc.rb', '.pryrc'
|
63
64
|
end
|
64
65
|
|
65
|
-
def remove_turbolinks
|
66
|
-
replace_in_file 'app/assets/javascripts/application.js',
|
67
|
-
/\/\/= require turbolinks\n/,
|
68
|
-
''
|
69
|
-
end
|
70
|
-
|
71
66
|
def create_database
|
72
67
|
bundle_command 'exec rake db:create'
|
73
68
|
end
|
74
69
|
|
75
70
|
def generate_rspec
|
76
71
|
generate 'rspec:install'
|
72
|
+
|
73
|
+
inject_into_file 'spec/rails_helper.rb',
|
74
|
+
"\n# Screenshots\n" \
|
75
|
+
"require 'capybara-screenshot/rspec'\n" \
|
76
|
+
"Capybara::Screenshot.autosave_on_failure =\n" \
|
77
|
+
" (ENV['SCR'] || ENV['AUTO_SCREENSHOT']) == '1'\n",
|
78
|
+
after: "Rails is not loaded until this point!\n"
|
77
79
|
end
|
78
80
|
|
79
81
|
def configure_rspec
|
@@ -93,7 +95,6 @@ module BlueberryRails
|
|
93
95
|
bundle_command 'exec guard init'
|
94
96
|
end
|
95
97
|
|
96
|
-
|
97
98
|
def raise_on_unpermitted_parameters
|
98
99
|
configure_environment 'development',
|
99
100
|
'config.action_controller.action_on_unpermitted_parameters = :raise'
|
@@ -123,6 +124,12 @@ module BlueberryRails
|
|
123
124
|
inject_into_class 'config/application.rb', 'Application', config
|
124
125
|
end
|
125
126
|
|
127
|
+
def configure_i18n_logger
|
128
|
+
configure_environment 'development',
|
129
|
+
"# I18n debug\n I18nLogger = ActiveSupport::" \
|
130
|
+
"Logger.new(Rails.root.join('log/i18n.log'))"
|
131
|
+
end
|
132
|
+
|
126
133
|
def configure_travis
|
127
134
|
template 'travis.yml.erb', '.travis.yml'
|
128
135
|
end
|
@@ -198,5 +205,36 @@ module BlueberryRails
|
|
198
205
|
run 'git init'
|
199
206
|
end
|
200
207
|
|
208
|
+
# Gulp
|
209
|
+
def gulp_files
|
210
|
+
copy_file 'gulp/gulp_helper.rb', 'app/helpers/gulp_helper.rb'
|
211
|
+
remove_file 'app/assets/stylesheets/application.css'
|
212
|
+
copy_file 'gulp/application.sass',
|
213
|
+
'app/assets/stylesheets/application.sass'
|
214
|
+
remove_file 'app/assets/javascripts/application.js'
|
215
|
+
copy_file 'gulp/application.js.coffee',
|
216
|
+
'app/assets/javascripts/application.js.coffee'
|
217
|
+
|
218
|
+
application do
|
219
|
+
"# Make public assets requireable in manifest files\n " \
|
220
|
+
"config.assets.paths << Rails.root.join('public', 'assets', 'stylesheets')\n " \
|
221
|
+
"config.assets.paths << Rails.root.join('public', 'assets', 'javascripts')\n"
|
222
|
+
end
|
223
|
+
|
224
|
+
replace_in_file 'config/environments/development.rb',
|
225
|
+
'config.assets.digest = true',
|
226
|
+
'config.assets.digest = false'
|
227
|
+
|
228
|
+
copy_file 'gulp/rev_manifest.rb', 'config/initializers/rev_manifest.rb'
|
229
|
+
copy_file 'gulp/global.coffee', 'gulp/assets/javascripts/global.coffee'
|
230
|
+
copy_file 'gulp/message.coffee', 'gulp/assets/javascripts/message.coffee'
|
231
|
+
copy_file 'gulp/global.sass', 'gulp/assets/stylesheets/global.sass'
|
232
|
+
copy_file 'gulp/config.coffee'
|
233
|
+
directory 'gulp/tasks'
|
234
|
+
directory 'gulp/util'
|
235
|
+
copy_file 'gulp/gulpfile.js', 'gulpfile.js'
|
236
|
+
copy_file 'gulp/package.json', 'package.json'
|
237
|
+
end
|
238
|
+
|
201
239
|
end
|
202
240
|
end
|
@@ -4,25 +4,33 @@ require 'rails/generators/rails/app/app_generator'
|
|
4
4
|
module BlueberryRails
|
5
5
|
class AppGenerator < Rails::Generators::AppGenerator
|
6
6
|
|
7
|
-
class_option :database, :
|
8
|
-
:
|
9
|
-
|
10
|
-
"(options: #{DATABASES.join('/')})"
|
7
|
+
class_option :database, type: :string, aliases: '-d', default: 'postgresql',
|
8
|
+
desc: "Preconfigure for selected database " \
|
9
|
+
"(options: #{DATABASES.join('/')})"
|
11
10
|
|
12
11
|
# class_option :github, :type => :string, :aliases => '-G', :default => nil,
|
13
|
-
#
|
12
|
+
# :desc => 'Create Github repository and add remote origin pointed to repo'
|
14
13
|
|
15
|
-
class_option :bootstrap, :
|
16
|
-
:
|
14
|
+
class_option :bootstrap, type: :boolean, aliases: '-b', default: false,
|
15
|
+
desc: 'Include bootstrap 3'
|
17
16
|
|
18
|
-
class_option :devise, :
|
19
|
-
:
|
17
|
+
class_option :devise, type: :boolean, aliases: '-D', default: true,
|
18
|
+
desc: 'Include and generate devise'
|
20
19
|
|
21
|
-
class_option :devise_model, :
|
22
|
-
:
|
20
|
+
class_option :devise_model, type: :string, aliases: '-M', default: 'User',
|
21
|
+
desc: 'Name of devise model to generate'
|
23
22
|
|
24
|
-
class_option :skip_test_unit, :
|
25
|
-
:
|
23
|
+
class_option :skip_test_unit, type: :boolean, aliases: '-T', default: true,
|
24
|
+
desc: 'Skip Test::Unit files'
|
25
|
+
|
26
|
+
class_option :skip_turbolinks, type: :boolean, default: true,
|
27
|
+
desc: "Skip turbolinks gem"
|
28
|
+
|
29
|
+
class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
|
30
|
+
desc: "Don't run bundle install"
|
31
|
+
|
32
|
+
class_option :gulp, type: :boolean, aliases: '-g', default: false,
|
33
|
+
desc: 'Include Gulp asset pipeline'
|
26
34
|
|
27
35
|
def finish_template
|
28
36
|
invoke :blueberry_customization
|
@@ -41,11 +49,10 @@ module BlueberryRails
|
|
41
49
|
invoke :setup_gems
|
42
50
|
invoke :fix_specs
|
43
51
|
invoke :setup_git
|
52
|
+
invoke :setup_gulp
|
44
53
|
end
|
45
54
|
|
46
55
|
def customize_gemfile
|
47
|
-
build :replace_gemfile
|
48
|
-
build :set_ruby_to_version_being_used
|
49
56
|
bundle_command 'install'
|
50
57
|
end
|
51
58
|
|
@@ -63,6 +70,7 @@ module BlueberryRails
|
|
63
70
|
say 'Setting up the development environment'
|
64
71
|
build :configure_generators
|
65
72
|
build :raise_on_unpermitted_parameters
|
73
|
+
build :configure_i18n_logger
|
66
74
|
build :configure_mailcatcher
|
67
75
|
end
|
68
76
|
|
@@ -91,9 +99,9 @@ module BlueberryRails
|
|
91
99
|
build :secret_token
|
92
100
|
build :disable_xml_params
|
93
101
|
build :setup_mailer_hosts
|
94
|
-
build :remove_turbolinks
|
95
102
|
build :create_pryrc
|
96
103
|
build :add_ruby_version_file
|
104
|
+
build :hound_config
|
97
105
|
end
|
98
106
|
|
99
107
|
def remove_routes_comment_lines
|
@@ -122,6 +130,12 @@ module BlueberryRails
|
|
122
130
|
build :init_git
|
123
131
|
end
|
124
132
|
|
133
|
+
def setup_gulp
|
134
|
+
if options[:gulp]
|
135
|
+
say 'Adding Gulp asset pipeline'
|
136
|
+
build :gulp_files
|
137
|
+
end
|
138
|
+
end
|
125
139
|
|
126
140
|
def run_bundle
|
127
141
|
end
|
@@ -131,7 +145,6 @@ module BlueberryRails
|
|
131
145
|
def get_builder_class
|
132
146
|
BlueberryRails::AppBuilder
|
133
147
|
end
|
134
|
-
|
135
148
|
end
|
136
149
|
end
|
137
150
|
|
@@ -19,15 +19,30 @@ class BlueberryRailsTest < Minitest::Test
|
|
19
19
|
def test_rake_runs_cleanly
|
20
20
|
create_project
|
21
21
|
|
22
|
-
assert_exist_file 'config
|
22
|
+
assert_exist_file 'config/initializers/simple_form.rb'
|
23
|
+
assert_exist_file '.hound.yml'
|
24
|
+
assert_exist_file '.rubocop.yml'
|
25
|
+
assert_exist_file '.rspec'
|
26
|
+
assert_file_have_content 'README.md', 'Test Project'
|
23
27
|
assert run_rake
|
24
28
|
end
|
25
29
|
|
26
30
|
def test_rake_runs_with_bootstrap_option
|
27
31
|
create_project '--bootstrap'
|
28
32
|
|
29
|
-
assert_exist_file 'config
|
30
|
-
assert_exist_file 'config
|
33
|
+
assert_exist_file 'config/initializers/simple_form.rb'
|
34
|
+
assert_exist_file 'config/initializers/simple_form_bootstrap.rb'
|
35
|
+
assert run_rake
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_rake_runs_with_gulp_option
|
39
|
+
create_project '--gulp'
|
40
|
+
|
41
|
+
assert_file_have_content 'config/environments/development.rb',
|
42
|
+
'config.assets.digest = false'
|
43
|
+
assert_exist_file 'gulp/tasks/default.coffee'
|
44
|
+
assert_exist_file 'gulpfile.js'
|
45
|
+
assert_exist_file 'package.json'
|
31
46
|
assert run_rake
|
32
47
|
end
|
33
48
|
end
|
@@ -36,7 +36,15 @@ module BlueberryRailsHelpers
|
|
36
36
|
File.expand_path('../../../', __FILE__)
|
37
37
|
end
|
38
38
|
|
39
|
-
def assert_exist_file(
|
40
|
-
assert File.exists?(
|
39
|
+
def assert_exist_file(path)
|
40
|
+
assert File.exists?(project_file(path))
|
41
|
+
end
|
42
|
+
|
43
|
+
def assert_file_have_content(path, content)
|
44
|
+
assert File.read(project_file(path)).include?(content)
|
45
|
+
end
|
46
|
+
|
47
|
+
def project_file(path)
|
48
|
+
File.join(project_path, path)
|
41
49
|
end
|
42
50
|
end
|
@@ -1,7 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
ruby '<%= BlueberryRails::RUBY_VERSION %>'
|
4
|
+
|
3
5
|
gem 'airbrake'
|
6
|
+
<% if !options[:gulp] -%>
|
4
7
|
gem 'autoprefixer-rails'
|
8
|
+
<% end -%>
|
5
9
|
<% if options[:bootstrap] -%>
|
6
10
|
gem 'bootstrap-sass'
|
7
11
|
<% end -%>
|
@@ -21,6 +25,7 @@ gem 'uglifier', '>= 1.3.0'
|
|
21
25
|
gem 'unicorn'
|
22
26
|
|
23
27
|
group :development do
|
28
|
+
gem 'awesome_print'
|
24
29
|
gem 'better_errors'
|
25
30
|
gem 'binding_of_caller'
|
26
31
|
gem 'capistrano', '~> 3.0.0'
|
@@ -30,12 +35,17 @@ group :development do
|
|
30
35
|
gem 'guard-rspec'
|
31
36
|
gem 'mailcatcher'
|
32
37
|
gem 'pry-rails'
|
38
|
+
gem 'quiet_assets'
|
39
|
+
gem 'rails-i18n-debug', github: 'XeeD/rails-i18n-debug'
|
40
|
+
gem 'rubocop', require: false
|
33
41
|
gem 'spring'
|
34
|
-
gem '
|
42
|
+
gem 'spring-commands-rspec'
|
35
43
|
end
|
36
44
|
|
37
45
|
group :development, :test do
|
38
46
|
gem 'factory_girl_rails'
|
47
|
+
gem 'pry-byebug'
|
48
|
+
gem 'pry-doc'
|
39
49
|
gem 'rspec-rails', '>= 3.1'
|
40
50
|
end
|
41
51
|
|
@@ -44,8 +54,11 @@ group :staging, :production do
|
|
44
54
|
end
|
45
55
|
|
46
56
|
group :test do
|
47
|
-
gem '
|
57
|
+
gem 'capybara-screenshot'
|
48
58
|
gem 'database_cleaner'
|
59
|
+
gem 'launchy'
|
60
|
+
gem 'poltergeist', '>= 1.5.0'
|
49
61
|
gem 'simplecov', '~> 0.9.1', require: false
|
62
|
+
gem 'webmock'
|
50
63
|
end
|
51
64
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# <%= app_name.titleize %> – Blueberry Rails project
|
2
2
|
|
3
3
|
Use the following guides for getting things done, programming well, and
|
4
4
|
programming in style.
|
@@ -6,4 +6,4 @@ programming in style.
|
|
6
6
|
* [Protocol](http://github.com/thoughtbot/guides/blob/master/protocol)
|
7
7
|
* [Best Practices](http://github.com/thoughtbot/guides/blob/master/best-practices)
|
8
8
|
* [Style](http://github.com/thoughtbot/guides/blob/master/style)
|
9
|
-
|
9
|
+
* [Git commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This is a manifest file that'll be compiled into application.js, which will
|
2
|
+
# include all the files listed below.
|
3
|
+
#
|
4
|
+
# Only include gem installed javascript assets here. All other JS develoment
|
5
|
+
# should use Common JS and will be compiled with Gulp and Browserify.
|
6
|
+
#
|
7
|
+
#= require jquery
|
8
|
+
#= require jquery_ujs
|
9
|
+
#
|
10
|
+
# Pull compiled from /public/assets/javascripts
|
11
|
+
#= require global
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will
|
3
|
+
* include all the files listed below.
|
4
|
+
*
|
5
|
+
* Use this file to include any stylesheet assets from installed gems. All other
|
6
|
+
* css is compiled with libsass with Gulp.
|
7
|
+
*
|
8
|
+
* Pull compiled from /public/assets/stylesheets
|
9
|
+
*= require global
|
10
|
+
*/
|
@@ -0,0 +1,47 @@
|
|
1
|
+
publicAssets = './public/assets'
|
2
|
+
sourceFiles = './gulp/assets'
|
3
|
+
|
4
|
+
module.exports =
|
5
|
+
publicAssets: publicAssets
|
6
|
+
|
7
|
+
browserSync:
|
8
|
+
proxy: 'localhost:3000'
|
9
|
+
files: [ './app/views/**' ]
|
10
|
+
|
11
|
+
sass:
|
12
|
+
src: sourceFiles + '/stylesheets/**/*.sass'
|
13
|
+
dest: publicAssets + '/stylesheets'
|
14
|
+
settings:
|
15
|
+
indentedSyntax: true
|
16
|
+
imagePath: '/assets/images'
|
17
|
+
errLogToConsole: true
|
18
|
+
|
19
|
+
images:
|
20
|
+
src: sourceFiles + '/images/**'
|
21
|
+
dest: publicAssets + '/images'
|
22
|
+
|
23
|
+
fontIcons:
|
24
|
+
name: 'Font Icons'
|
25
|
+
src: sourceFiles + '/icons/*.svg'
|
26
|
+
dest: publicAssets + '/fonts'
|
27
|
+
sassDest: sourceFiles + '/stylesheets/base'
|
28
|
+
template: './gulp/tasks/fontIcons/template.sass'
|
29
|
+
sassOutputName: '_font_icons.sass'
|
30
|
+
fontPath: '/assets/fonts'
|
31
|
+
className: 'icon'
|
32
|
+
options:
|
33
|
+
fontName: 'font-icons'
|
34
|
+
appendCodepoints: true
|
35
|
+
normalize: false
|
36
|
+
|
37
|
+
browserify: bundleConfigs: [ {
|
38
|
+
entries: [
|
39
|
+
# import React
|
40
|
+
#'./node_modules/react/dist/react.js'
|
41
|
+
sourceFiles + '/javascripts/global.coffee'
|
42
|
+
]
|
43
|
+
dest: publicAssets + '/javascripts'
|
44
|
+
outputName: 'global.js'
|
45
|
+
extensions: [ '.js', '.coffee' ]
|
46
|
+
debug: !process.env.RAILS_ENV == 'production'
|
47
|
+
} ]
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GulpHelper
|
2
|
+
|
3
|
+
def gulp_asset_path(path)
|
4
|
+
path = REV_MANIFEST[path] if defined?(REV_MANIFEST)
|
5
|
+
"/assets/#{path}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def image_alt(src)
|
9
|
+
super.sub(/\s[0-9A-F]{8}\z/i, '')
|
10
|
+
end
|
11
|
+
|
12
|
+
def image_tag(image, options = {})
|
13
|
+
super(gulp_asset_path("images/#{image}"), options)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
gulpfile.js
|
3
|
+
===========
|
4
|
+
Rather than manage one giant configuration file responsible
|
5
|
+
for creating multiple tasks, each task has been broken out into
|
6
|
+
its own file in gulp/tasks. Any files in that directory get
|
7
|
+
automatically required below.
|
8
|
+
|
9
|
+
To add a new task, simply add a new task file that directory.
|
10
|
+
gulp/tasks/default.js specifies the default set of tasks to run
|
11
|
+
when you run `gulp`.
|
12
|
+
*/
|
13
|
+
|
14
|
+
var requireDir = require('require-dir');
|
15
|
+
|
16
|
+
// Note the new way of requesting CoffeeScript since 1.7.x
|
17
|
+
require('coffee-script/register');
|
18
|
+
|
19
|
+
// Require all tasks in gulp/tasks, including subfolders
|
20
|
+
requireDir('./gulp/tasks', { recurse: true });
|
@@ -0,0 +1 @@
|
|
1
|
+
module.exports = 'Common.js module'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
{
|
2
|
+
"name": "gulp-rails",
|
3
|
+
"description": "Gulp Asset Pipeline with Rails",
|
4
|
+
"engines": {
|
5
|
+
"node": "0.10.36",
|
6
|
+
"npm": "2.3.0"
|
7
|
+
},
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "git://github.com/geoRG77/rails-gulp.git"
|
11
|
+
},
|
12
|
+
"scripts": {
|
13
|
+
"postinstall": "gulp build"
|
14
|
+
},
|
15
|
+
"browserify": {
|
16
|
+
"transform": [
|
17
|
+
"coffeeify"
|
18
|
+
]
|
19
|
+
},
|
20
|
+
"dependencies": {
|
21
|
+
"bootstrap-sass": "^3.3.4",
|
22
|
+
"browser-sync": "~1.3.6",
|
23
|
+
"browserify": "^8.0.2",
|
24
|
+
"coffee-script": "^1.9.1",
|
25
|
+
"coffeeify": "~0.7.0",
|
26
|
+
"del": "^1.1.1",
|
27
|
+
"gulp": "^3.8.7",
|
28
|
+
"gulp-autoprefixer": "^2.0.0",
|
29
|
+
"gulp-changed": "^0.4.1",
|
30
|
+
"gulp-cjsx": "^2.0.0",
|
31
|
+
"gulp-filesize": "0.0.6",
|
32
|
+
"gulp-iconfont": "^1.0.0",
|
33
|
+
"gulp-imagemin": "^0.6.2",
|
34
|
+
"gulp-minify-css": "^1.0.0",
|
35
|
+
"gulp-rename": "^1.2.0",
|
36
|
+
"gulp-rev": "^3.0.1",
|
37
|
+
"gulp-rev-collector": "^0.1.3",
|
38
|
+
"gulp-sass": "~1.3.1",
|
39
|
+
"gulp-sequence": "^0.3.2",
|
40
|
+
"gulp-sourcemaps": "^1.2.8",
|
41
|
+
"gulp-swig": "^0.7.4",
|
42
|
+
"gulp-util": "^3.0.0",
|
43
|
+
"lodash": "^2.4.1",
|
44
|
+
"merge-stream": "^0.1.7",
|
45
|
+
"pretty-hrtime": "~0.2.1",
|
46
|
+
"require-dir": "^0.1.0",
|
47
|
+
"vinyl-source-stream": "~0.1.1",
|
48
|
+
"watchify": "^2.2.1"
|
49
|
+
},
|
50
|
+
"devDependencies": {
|
51
|
+
"gulp-watch": "^4.1.1"
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
_ = require 'lodash'
|
2
|
+
browserify = require 'browserify'
|
3
|
+
browserSync = require 'browser-sync'
|
4
|
+
bundleLogger = require '../util/bundleLogger'
|
5
|
+
config = require('../config').browserify
|
6
|
+
gulp = require 'gulp'
|
7
|
+
handleErrors = require '../util/handleErrors'
|
8
|
+
source = require 'vinyl-source-stream'
|
9
|
+
watchify = require 'watchify'
|
10
|
+
|
11
|
+
browserifyTask = (callback, devMode) ->
|
12
|
+
bundleQueue = config.bundleConfigs.length
|
13
|
+
|
14
|
+
browserifyThis = (bundleConfig) ->
|
15
|
+
if devMode
|
16
|
+
_.extend bundleConfig, watchify.args, debug: true
|
17
|
+
bundleConfig = _.omit(bundleConfig, [ 'external', 'require' ])
|
18
|
+
b = browserify(bundleConfig)
|
19
|
+
|
20
|
+
bundle = ->
|
21
|
+
bundleLogger.start bundleConfig.outputName
|
22
|
+
|
23
|
+
b.bundle().on('error', handleErrors)
|
24
|
+
.pipe source(bundleConfig.outputName)
|
25
|
+
.pipe gulp.dest(bundleConfig.dest).on('end', reportFinished)
|
26
|
+
.pipe browserSync.reload(stream: true)
|
27
|
+
|
28
|
+
if devMode
|
29
|
+
b = watchify(b)
|
30
|
+
b.on 'update', bundle
|
31
|
+
bundleLogger.watch bundleConfig.outputName
|
32
|
+
else
|
33
|
+
if bundleConfig.require
|
34
|
+
b.require bundleConfig.require
|
35
|
+
if bundleConfig.external
|
36
|
+
b.external bundleConfig.external
|
37
|
+
|
38
|
+
reportFinished = ->
|
39
|
+
bundleLogger.end bundleConfig.outputName
|
40
|
+
if bundleQueue
|
41
|
+
bundleQueue--
|
42
|
+
if bundleQueue == 0
|
43
|
+
callback()
|
44
|
+
|
45
|
+
bundle()
|
46
|
+
|
47
|
+
config.bundleConfigs.forEach browserifyThis
|
48
|
+
|
49
|
+
gulp.task 'browserify', browserifyTask
|
50
|
+
module.exports = browserifyTask
|
@@ -0,0 +1,25 @@
|
|
1
|
+
gulp = require 'gulp'
|
2
|
+
gulpSequence = require 'gulp-sequence'
|
3
|
+
|
4
|
+
gulp.task 'build', (cb) ->
|
5
|
+
tasks = [
|
6
|
+
'clean'
|
7
|
+
[ 'fontIcons', 'images' ]
|
8
|
+
[ 'sass:production', 'browserify' ]
|
9
|
+
]
|
10
|
+
|
11
|
+
if process.env.RAILS_ENV == 'production'
|
12
|
+
tasks.push 'rev'
|
13
|
+
|
14
|
+
tasks.push cb
|
15
|
+
gulpSequence.apply this, tasks
|
16
|
+
|
17
|
+
gulp.task 'development', (cb) ->
|
18
|
+
tasks = [
|
19
|
+
'clean'
|
20
|
+
[ 'fontIcons', 'images' ]
|
21
|
+
[ 'sass', 'browserify' ]
|
22
|
+
]
|
23
|
+
|
24
|
+
tasks.push cb
|
25
|
+
gulpSequence.apply this, tasks
|
@@ -0,0 +1,23 @@
|
|
1
|
+
gulp = require 'gulp'
|
2
|
+
config = require('../../config').fontIcons
|
3
|
+
template = require 'gulp-swig'
|
4
|
+
rename = require 'gulp-rename'
|
5
|
+
|
6
|
+
module.exports = (codepoints, options) ->
|
7
|
+
iconSass = template(data:
|
8
|
+
icons: codepoints.map((icon) ->
|
9
|
+
{
|
10
|
+
name: icon.name
|
11
|
+
code: icon.codepoint.toString(16)
|
12
|
+
}
|
13
|
+
)
|
14
|
+
fontName: config.options.fontName
|
15
|
+
fontPath: config.fontPath
|
16
|
+
className: config.className
|
17
|
+
comment: 'DO NOT EDIT DIRECTLY!\n Generated by ./gulp/tasks/fontIcons/ge' +
|
18
|
+
'nerateIconSass.coffee\n from ' + config.template)
|
19
|
+
|
20
|
+
gulp.src(config.template)
|
21
|
+
.pipe iconSass
|
22
|
+
.pipe rename(config.sassOutputName)
|
23
|
+
.pipe gulp.dest(config.sassDest)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
gulp = require 'gulp'
|
2
|
+
iconfont = require 'gulp-iconfont'
|
3
|
+
config = require('../../config').fontIcons
|
4
|
+
generateIconSass = require './generateIconSass'
|
5
|
+
|
6
|
+
gulp.task 'fontIcons', ->
|
7
|
+
gulp.src(config.src)
|
8
|
+
.pipe iconfont(config.options).on('codepoints', generateIconSass)
|
9
|
+
.pipe gulp.dest(config.dest)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// {{comment}}
|
2
|
+
|
3
|
+
@font-face
|
4
|
+
font-family: {{fontName}}
|
5
|
+
src: url("{{fontPath}}/{{fontName}}.eot")
|
6
|
+
src: url("{{fontPath}}/{{fontName}}.eot?#iefix") format('embedded-opentype'), url("{{fontPath}}/{{fontName}}.woff") format('woff'), url("{{fontPath}}/{{fontName}}.ttf") format('truetype'), url("{{fontPath}}/{{fontName}}.svg#{{fontName}}") format('svg')
|
7
|
+
font-weight: normal
|
8
|
+
font-style: normal
|
9
|
+
|
10
|
+
=icon($content)
|
11
|
+
&:before
|
12
|
+
content: $content
|
13
|
+
font-family: '{{fontName}}'
|
14
|
+
font-style: normal
|
15
|
+
font-variant: normal
|
16
|
+
font-weight: normal
|
17
|
+
line-height: 1
|
18
|
+
speak: none
|
19
|
+
text-transform: none
|
20
|
+
-moz-osx-font-smoothing: grayscale
|
21
|
+
-webkit-font-smoothing: antialiased
|
22
|
+
@content
|
23
|
+
|
24
|
+
{% for icon in icons -%}
|
25
|
+
=icon--{{icon.name}}
|
26
|
+
+icon("\{{icon.code}}")
|
27
|
+
@content
|
28
|
+
|
29
|
+
.icon
|
30
|
+
&.{{icon.name}}
|
31
|
+
+icon--{{icon.name}}
|
32
|
+
|
33
|
+
{% endfor %}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
changed = require 'gulp-changed'
|
2
|
+
gulp = require 'gulp'
|
3
|
+
imagemin = require 'gulp-imagemin'
|
4
|
+
config = require('../config').images
|
5
|
+
browserSync = require 'browser-sync'
|
6
|
+
|
7
|
+
gulp.task 'images', ->
|
8
|
+
gulp.src(config.src)
|
9
|
+
.pipe changed(config.dest)
|
10
|
+
.pipe imagemin()
|
11
|
+
.pipe gulp.dest(config.dest)
|
12
|
+
.pipe browserSync.reload(stream: true)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
config = require '../../config'
|
2
|
+
gulp = require 'gulp'
|
3
|
+
revCollector = require 'gulp-rev-collector'
|
4
|
+
|
5
|
+
# Replace asset references in compiled CSS and JS files
|
6
|
+
gulp.task 'rev', [ 'rev-assets', 'rev-font-workaround' ], ->
|
7
|
+
gulp.src([
|
8
|
+
config.publicAssets + '/rev-manifest.json'
|
9
|
+
config.publicAssets + '/**/*.{css,js}'
|
10
|
+
])
|
11
|
+
.pipe revCollector()
|
12
|
+
.pipe gulp.dest(config.publicAssets)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
config = require '../../config'
|
2
|
+
gulp = require 'gulp'
|
3
|
+
rev = require 'gulp-rev'
|
4
|
+
|
5
|
+
# Add md5 hashes to assets
|
6
|
+
gulp.task 'rev-assets', ->
|
7
|
+
gulp.src(config.publicAssets + '/**/**.!(css|js|eot|woff|ttf)')
|
8
|
+
.pipe rev()
|
9
|
+
.pipe gulp.dest(config.publicAssets)
|
10
|
+
.pipe rev.manifest()
|
11
|
+
.pipe gulp.dest(config.publicAssets)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# 2) Font rev workaround
|
2
|
+
_ = require 'lodash'
|
3
|
+
config = require '../../config'
|
4
|
+
fs = require 'fs'
|
5
|
+
gulp = require 'gulp'
|
6
|
+
merge = require 'merge-stream'
|
7
|
+
rename = require 'gulp-rename'
|
8
|
+
rev = require 'gulp-rev'
|
9
|
+
|
10
|
+
# .ttf fonts have an embedded timestamp, which cause the contents
|
11
|
+
# of the file to change ever-so-slightly. This was a problem for
|
12
|
+
# file reving, which generates a hash based on the contents of the file.
|
13
|
+
# This meant that even if source files had not changed, the hash would
|
14
|
+
# change with every recompile, as well as .eot, and .woff files, which
|
15
|
+
# are derived from a source svg font
|
16
|
+
# The solution is to only hash svg font files, then append the
|
17
|
+
# generated hash to the ttf, eot, and woff files (instead of
|
18
|
+
# leting each file generate its own hash)
|
19
|
+
|
20
|
+
gulp.task 'rev-font-workaround', [ 'rev-assets' ], ->
|
21
|
+
manifest = require('../../.' + config.publicAssets + '/rev-manifest.json')
|
22
|
+
fontList = []
|
23
|
+
|
24
|
+
_.each manifest, (reference, key) ->
|
25
|
+
fontPath = config.fontIcons.dest.split(config.publicAssets)[1].substr(1)
|
26
|
+
|
27
|
+
if key.match(fontPath + '/' + config.fontIcons.options.fontName)
|
28
|
+
path = key.split('.svg')[0]
|
29
|
+
hash = reference.split(path)[1].split('.svg')[0]
|
30
|
+
|
31
|
+
fontList.push
|
32
|
+
path: path
|
33
|
+
hash: hash
|
34
|
+
|
35
|
+
# Add hash to non-svg font files
|
36
|
+
streams = fontList.map((file) ->
|
37
|
+
# Add references in manifest
|
38
|
+
[ '.eot', '.woff', '.ttf' ].forEach (ext) ->
|
39
|
+
manifest[file.path + ext] = file.path + file.hash + ext
|
40
|
+
|
41
|
+
gulp.src(config.publicAssets + '/' + file.path + '*.!(svg)')
|
42
|
+
.pipe rename(suffix: file.hash)
|
43
|
+
.pipe gulp.dest(config.fontIcons.dest)
|
44
|
+
)
|
45
|
+
|
46
|
+
# Re-write rev-manifest.json to disk
|
47
|
+
fs.writeFile config.publicAssets + '/rev-manifest.json',
|
48
|
+
JSON.stringify(manifest, null, 2)
|
49
|
+
merge.apply this, streams
|
@@ -0,0 +1,24 @@
|
|
1
|
+
gulp = require 'gulp'
|
2
|
+
browserSync = require 'browser-sync'
|
3
|
+
sass = require 'gulp-sass'
|
4
|
+
sourcemaps = require 'gulp-sourcemaps'
|
5
|
+
minifyCSS = require 'gulp-minify-css'
|
6
|
+
handleErrors = require '../util/handleErrors'
|
7
|
+
config = require('../config').sass
|
8
|
+
autoprefixer = require 'gulp-autoprefixer'
|
9
|
+
|
10
|
+
gulp.task 'sass', ->
|
11
|
+
gulp.src(config.src)
|
12
|
+
.pipe sourcemaps.init()
|
13
|
+
.pipe sass(config.settings).on('error', handleErrors)
|
14
|
+
.pipe autoprefixer(browsers: [ 'last 2 version' ])
|
15
|
+
.pipe sourcemaps.write()
|
16
|
+
.pipe gulp.dest(config.dest)
|
17
|
+
.pipe browserSync.reload(stream: true)
|
18
|
+
|
19
|
+
gulp.task 'sass:production', ->
|
20
|
+
gulp.src(config.src)
|
21
|
+
.pipe sass(config.settings).on('error', handleErrors)
|
22
|
+
.pipe autoprefixer(browsers: [ 'last 2 version' ])
|
23
|
+
.pipe minifyCSS()
|
24
|
+
.pipe gulp.dest(config.dest)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
### Notes:
|
2
|
+
- gulp/tasks/browserify.js handles js recompiling with watchify
|
3
|
+
- gulp/tasks/browserSync.js watches and reloads compiled files
|
4
|
+
###
|
5
|
+
|
6
|
+
gulp = require 'gulp'
|
7
|
+
config = require '../config'
|
8
|
+
watch = require 'gulp-watch'
|
9
|
+
|
10
|
+
gulp.task 'watch', [ 'watchify', 'browserSync' ], (callback) ->
|
11
|
+
watch config.sass.src, ->
|
12
|
+
gulp.start 'sass'
|
13
|
+
watch config.images.src, ->
|
14
|
+
gulp.start 'images'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
### bundleLogger
|
2
|
+
Provides gulp style logs to the bundle method in browserify.js
|
3
|
+
###
|
4
|
+
|
5
|
+
gutil = require 'gulp-util'
|
6
|
+
prettyHrtime = require 'pretty-hrtime'
|
7
|
+
startTime = undefined
|
8
|
+
|
9
|
+
module.exports =
|
10
|
+
start: (filepath) ->
|
11
|
+
startTime = process.hrtime()
|
12
|
+
gutil.log 'Bundling', gutil.colors.green(filepath) + '...'
|
13
|
+
|
14
|
+
watch: (bundleName) ->
|
15
|
+
gutil.log 'Watching files required by', gutil.colors.yellow(bundleName)
|
16
|
+
|
17
|
+
end: (filepath) ->
|
18
|
+
taskTime = process.hrtime(startTime)
|
19
|
+
prettyTime = prettyHrtime(taskTime)
|
20
|
+
gutil.log 'Bundled',
|
21
|
+
gutil.colors.green(filepath),
|
22
|
+
'in',
|
23
|
+
gutil.colors.magenta(prettyTime)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module.exports = ->
|
2
|
+
args = Array::slice.call(arguments)
|
3
|
+
|
4
|
+
# Send error to notification center with gulp-notify
|
5
|
+
#notify.onError(
|
6
|
+
# title: 'Compile Error'
|
7
|
+
#message: '<%= error %>').apply this, args
|
8
|
+
console.log args
|
9
|
+
|
10
|
+
# Keep gulp from hanging on this task
|
11
|
+
@emit 'end'
|
data/templates/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blueberry_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BlueberryApps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.2.
|
33
|
+
version: 4.2.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.2.
|
40
|
+
version: 4.2.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,7 +79,7 @@ files:
|
|
79
79
|
- spec/support/blueberry_rails_helpers.rb
|
80
80
|
- templates/Capfile
|
81
81
|
- templates/Gemfile_custom.erb
|
82
|
-
- templates/README.md
|
82
|
+
- templates/README.md.erb
|
83
83
|
- templates/_flashes.html.slim
|
84
84
|
- templates/capistrano_dotenv.cap
|
85
85
|
- templates/database.yml.erb
|
@@ -90,7 +90,34 @@ files:
|
|
90
90
|
- templates/disable_xml_params.rb
|
91
91
|
- templates/factories_spec.rb
|
92
92
|
- templates/factory_girl_syntax.rb
|
93
|
-
- templates/gitignore_custom
|
93
|
+
- templates/gitignore_custom.erb
|
94
|
+
- templates/gulp/application.js.coffee
|
95
|
+
- templates/gulp/application.sass
|
96
|
+
- templates/gulp/config.coffee
|
97
|
+
- templates/gulp/global.coffee
|
98
|
+
- templates/gulp/global.sass
|
99
|
+
- templates/gulp/gulp_helper.rb
|
100
|
+
- templates/gulp/gulpfile.js
|
101
|
+
- templates/gulp/message.coffee
|
102
|
+
- templates/gulp/package.json
|
103
|
+
- templates/gulp/rev_manifest.rb
|
104
|
+
- templates/gulp/tasks/browserSync.coffee
|
105
|
+
- templates/gulp/tasks/browserify.coffee
|
106
|
+
- templates/gulp/tasks/build.coffee
|
107
|
+
- templates/gulp/tasks/clean.coffee
|
108
|
+
- templates/gulp/tasks/default.coffee
|
109
|
+
- templates/gulp/tasks/fontIcons/generateIconSass.coffee
|
110
|
+
- templates/gulp/tasks/fontIcons/index.coffee
|
111
|
+
- templates/gulp/tasks/fontIcons/template.sass
|
112
|
+
- templates/gulp/tasks/images.coffee
|
113
|
+
- templates/gulp/tasks/rev/index.coffee
|
114
|
+
- templates/gulp/tasks/rev/rev-assets.coffee
|
115
|
+
- templates/gulp/tasks/rev/rev-font-workaround.coffee
|
116
|
+
- templates/gulp/tasks/sass.coffee
|
117
|
+
- templates/gulp/tasks/watch.coffee
|
118
|
+
- templates/gulp/tasks/watchify.coffee
|
119
|
+
- templates/gulp/util/bundleLogger.coffee
|
120
|
+
- templates/gulp/util/handleErrors.coffee
|
94
121
|
- templates/layout.html.slim
|
95
122
|
- templates/pryrc.rb
|
96
123
|
- templates/root_controller_spec.rb
|