Skip to content

Commit

Permalink
Pulling in 5.5.3.2. - adding relevant amends
Browse files Browse the repository at this point in the history
# By Mehdi Lahmam (11) and others
# Via Arthur (3) and others
* 'master' of github.com:zurb/foundation-rails: (24 commits)
  Version up to 5.5.3.2
  5.5.3.1
  Updating to 5.5.3
  ruby version number change for deploy
  Publishing 5.5.3
  explicitly write core foundation first, only append modules
  Bump to 5.5.2.1
  Add a `.ruby-version` file setting Ruby version to 2.2.1
  Fix the generator class path by moving it to it's standard path. Because: Rails wasn't picking up the generator when used in an engine as it wasn't namespaced as expected.
  Add a Travis CI config file
  Add RSpec based specs. Because: We encountered lately too much 💥 that could be avoided.
  Add a dummy style guide view, based ons Foundation docs' Kitchen Sink This help us to quickly verify everything is Ok inside a Rails app. We were relying before on `foundation-rails` style guide as a mounted engine, which was causing problems.
  Run `rails g foundation:install` in the test dummy app
  Replace test dummy app by a newer one with Rails 4.2 and Foundation 5.5
  Correct JavaScript files require order.
  Bumoing Version & Code
  Bumping Version
  Bumping Version
  Bump to 5.5.1.2
  Require 'foundation' before the rest of the JS files
  ...

Conflicts:
	vendor/assets/stylesheets/foundation/components/_forms.scss
	vendor/assets/stylesheets/foundation/components/_offcanvas.scss
  • Loading branch information
robertkyan committed Nov 6, 2015
2 parents 390e92d + 649f360 commit c093201
Show file tree
Hide file tree
Showing 137 changed files with 3,838 additions and 4,838 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.2
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: ruby
rvm: 2.2.1
cache: bundler
sudo: false
before_install:
- "echo '--colour' > ~/.rspec"
install: bundle install
notifications:
email: false
9 changes: 8 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
require "bundler/gem_tasks"
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:rspec)

desc 'Run the test suite'
task :default => :rspec
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "foundation-rails",
"version": "5.5.1.1",
"version": "5.5.3.2",
"dependencies": {
"foundation": "5.5.1"
"foundation": "5.5.3"
}
}
6 changes: 5 additions & 1 deletion foundation-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_dependency "sass", [">= 3.3.0", "< 3.5"]
spec.add_dependency "railties", [">= 3.1.0"]

spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "capybara"
spec.add_development_dependency "rake"
spec.add_development_dependency "rails"
spec.add_development_dependency "rspec", "~> 3.2"
end
1 change: 0 additions & 1 deletion lib/foundation/rails.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
require 'foundation/rails/engine'
require 'foundation/rails/version'
require 'foundation/rails/generators/install_generator'
59 changes: 0 additions & 59 deletions lib/foundation/rails/generators/install_generator.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/foundation/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Foundation
module Rails
VERSION = "5.5.1.0"
VERSION = "5.5.3.2"
end
end
69 changes: 69 additions & 0 deletions lib/generators/foundation/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
require 'rails/generators'

module Foundation
module Generators
class InstallGenerator < ::Rails::Generators::Base
source_root File.join(File.dirname(__FILE__), 'templates')
argument :layout_name, :type => :string, :default => 'application', :banner => 'layout_name'

class_option :haml, :desc => 'Generate HAML layout instead of erb', :type => :boolean
class_option :slim, :desc => 'Generate Slim layout instead of erb', :type => :boolean

def add_assets
# rails_ujs breaks, need to incorporate rails-behavior plugin for this to work seamlessly
# gsub_file "app/assets/javascripts/application#{detect_js_format[0]}", /\/\/= require jquery\n/, ""
insert_into_file File.join(javascripts_base_dir, "application#{detect_js_format[0]}"), "#{detect_js_format[1]} require foundation\n", :after => "jquery_ujs\n"
append_to_file File.join(javascripts_base_dir, "application#{detect_js_format[0]}"), "#{detect_js_format[2]}"
settings_file = File.join(File.dirname(__FILE__),"..", "..", "..", "vendor", "assets", "stylesheets", "foundation", "_settings.scss")
create_file File.join(stylesheets_base_dir, 'foundation_and_overrides.scss'), File.read(settings_file)
append_to_file File.join(stylesheets_base_dir, 'foundation_and_overrides.scss'), "\n@import 'foundation';\n"
insert_into_file File.join(stylesheets_base_dir, "application#{detect_css_format[0]}"), "\n#{detect_css_format[1]} require foundation_and_overrides\n", :after => "require_self"
end

def detect_js_format
return ['.coffee', '#=', "\n() ->\n $(document).foundation()\n"] if File.exist?(File.join(javascripts_base_dir, 'application.coffee'))
return ['.coffee.erb', '#=', "\n() ->\n $(document).foundation()\n"] if File.exist?(File.join(javascripts_base_dir, 'application.coffee.erb'))
return ['.js.coffee', '#=', "\n() ->\n $(document).foundation()\n"] if File.exist?(File.join(javascripts_base_dir, 'application.js.coffee'))
return ['.js.coffee.erb', '#=', "\n() ->\n $(document).foundation()\n"] if File.exist?(File.join(javascripts_base_dir, 'application.js.coffee.erb'))
return ['.js', '//=', "\n$(function(){ $(document).foundation(); });\n"] if File.exist?(File.join(javascripts_base_dir, 'application.js'))
return ['.js.erb', '//=', "\n$(function(){ $(document).foundation(); });\n"] if File.exist?(File.join(javascripts_base_dir, 'application.js.erb'))
end

def detect_css_format
return ['.css', ' *='] if File.exist?(File.join(stylesheets_base_dir, 'application.css'))
return ['.css.sass', ' //='] if File.exist?(File.join(stylesheets_base_dir, 'application.css.sass'))
return ['.sass', ' //='] if File.exist?(File.join(stylesheets_base_dir, 'application.sass'))
return ['.css.scss', ' //='] if File.exist?(File.join(stylesheets_base_dir, 'application.css.scss'))
return ['.scss', ' //='] if File.exist?(File.join(stylesheets_base_dir, 'application.scss'))
end

def create_layout
if options.haml?||(defined?(Haml) && options.haml?)
template 'application.html.haml', File.join(layouts_base_dir, "#{file_name}.html.haml")
elsif options.slim?||(defined?(Slim) && options.slim?)
template 'application.html.slim', File.join(layouts_base_dir, "#{file_name}.html.slim")
else
template 'application.html.erb', File.join(layouts_base_dir, "#{file_name}.html.erb")
end
end

private

def file_name
layout_name.underscore.downcase
end

def javascripts_base_dir
File.join('app', 'assets', 'javascripts')
end

def stylesheets_base_dir
File.join('app', 'assets', 'stylesheets')
end

def layouts_base_dir
File.join('app', 'views', 'layouts')
end
end
end
end
25 changes: 25 additions & 0 deletions spec/features/generator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'spec_helper'

feature 'Foundation install succeeds' do
scenario 'stylesheets assets files are added' do
application_css_file = IO.read("#{dummy_app_path}/app/assets/stylesheets/application.css")

expect(File).to exist("#{dummy_app_path}/app/assets/stylesheets/foundation_and_overrides.scss")
expect(application_css_file).to match(/require foundation_and_overrides/)
end

scenario 'javascripts assets files are added' do
application_js_file = IO.read("#{dummy_app_path}/app/assets/javascripts/application.js")

expect(application_js_file).to match(/require foundation/)
expect(application_js_file).to match(Regexp.new(Regexp.escape('$(function(){ $(document).foundation(); });')))
end

scenario 'layout file loads assets' do
layout_file = IO.read("#{dummy_app_path}/app/views/layouts/application.html.erb")

expect(layout_file).to match(/stylesheet_link_tag "application"/)
expect(layout_file).to match(/javascript_include_tag "vendor\/modernizr"/)
expect(layout_file).to match(/javascript_include_tag "application/)
end
end
19 changes: 19 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'capybara/rspec'
require 'bundler/setup'

Bundler.require(:default, :test)

Dir['./spec/support/**/*.rb'].each { |file| require file }

RSpec.configure do |config|
config.include FoundationRailsTestHelpers

config.before(:all) do
create_dummy_app
install_foundation
end

config.after(:all) do
remove_dummy_app
end
end
25 changes: 25 additions & 0 deletions spec/support/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module FoundationRailsTestHelpers
def create_dummy_app
FileUtils.cd(tmp_path) do
%x(rails new dummy --skip-active-record --skip-test-unit --skip-spring)
end
end

def remove_dummy_app
FileUtils.rm_rf(dummy_app_path)
end

def install_foundation
FileUtils.cd(dummy_app_path) do
%x(rails g foundation:install -f 2>&1)
end
end

def dummy_app_path
File.join(tmp_path, 'dummy')
end

def tmp_path
@tmp_path ||= File.join(File.dirname(__FILE__), '..')
end
end
16 changes: 0 additions & 16 deletions test/dummy/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion test/dummy/.ruby-version

This file was deleted.

47 changes: 0 additions & 47 deletions test/dummy/Gemfile

This file was deleted.

28 changes: 0 additions & 28 deletions test/dummy/README.rdoc

This file was deleted.

6 changes: 0 additions & 6 deletions test/dummy/Rakefile

This file was deleted.

Empty file removed test/dummy/app/assets/images/.keep
Empty file.
8 changes: 0 additions & 8 deletions test/dummy/app/assets/javascripts/application.js

This file was deleted.

4 changes: 0 additions & 4 deletions test/dummy/app/assets/stylesheets/application.css

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions test/dummy/app/controllers/application_controller.rb

This file was deleted.

Empty file.
4 changes: 0 additions & 4 deletions test/dummy/app/controllers/styleguide_controller.rb

This file was deleted.

2 changes: 0 additions & 2 deletions test/dummy/app/helpers/application_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions test/dummy/app/helpers/styleguide_helper.rb

This file was deleted.

Empty file removed test/dummy/app/mailers/.keep
Empty file.
Empty file removed test/dummy/app/models/.keep
Empty file.
Empty file.
Loading

0 comments on commit c093201

Please sign in to comment.