Skip to content
This repository
Browse code

Remove ruby compact function. Fix tests and cleanup the generator scr…

…ipt. Move sass require.
commit 7a359c257010f00289ffcb0893982db92e1aa2c8 1 parent c9dfa51
Phil LaPier plapier authored
6 Gemfile.lock
... ... @@ -1,8 +1,8 @@
1 1 PATH
2 2 remote: .
3 3 specs:
4   - bourbon (2.1.2)
5   - sass (>= 3.2)
  4 + bourbon (2.2.0)
  5 + sass (>= 3.2.1)
6 6 thor
7 7
8 8 GEM
@@ -36,7 +36,7 @@ GEM
36 36 rspec-expectations (2.8.0)
37 37 diff-lcs (~> 1.1.2)
38 38 rspec-mocks (2.8.0)
39   - sass (3.2.2)
  39 + sass (3.2.3)
40 40 term-ansicolor (1.0.7)
41 41 thor (0.16.0)
42 42
4 features/install.feature
@@ -6,9 +6,7 @@ Feature: Install bourbon files
6 6 Then the sass directories should have been generated
7 7 And the following directories should exist:
8 8 | bourbon |
9   - | bourbon/lib |
10 9 And the master bourbon partial should have been generated
11   - And the lib files should have been generated
12 10 And the output should contain "Bourbon files installed to bourbon/"
13 11
14 12 Scenario: Generating does not overwrite an existing bourbon directory
@@ -21,9 +19,7 @@ Feature: Install bourbon files
21 19 Then the sass directories with "custom_path" prefix should have been generated
22 20 And the following directories should exist:
23 21 | custom_path/bourbon |
24   - | custom_path/bourbon/lib |
25 22 And the master bourbon partial should have been generated within "custom_path" directory
26   - And the lib files should have been generated within "custom_path" directory
27 23 And the output should contain "Bourbon files installed to custom_path/bourbon/"
28 24
29 25 Scenario: Forcing install of bourbon
7 features/step_definitions/bourbon_steps.rb
@@ -15,13 +15,6 @@
15 15 check_file_presence([bourbon_path(prefix, '_bourbon.scss')], true)
16 16 end
17 17
18   -Then /^the lib files should have been generated(?: within "([^"]+)" directory)?$/ do |prefix|
19   - check_file_presence([bourbon_path(prefix, 'lib/bourbon.rb')], true)
20   - check_directory_presence([bourbon_path(prefix, 'lib/bourbon')], true)
21   - check_file_presence([bourbon_path(prefix, 'lib/bourbon/sass_extensions.rb')], true)
22   - check_directory_presence([bourbon_path(prefix, 'lib/bourbon/sass_extensions')], true)
23   -end
24   -
25 18 Then /^bourbon should not have been generated$/ do
26 19 check_directory_presence(['bourbon'], false)
27 20 end
4 lib/bourbon.rb
@@ -20,4 +20,6 @@ class Railtie < ::Rails::Railtie
20 20 end
21 21 end
22 22
23   -require File.join(File.dirname(__FILE__), "/bourbon/sass_extensions")
  23 +unless defined?(Sass)
  24 + require 'sass'
  25 +end
17 lib/bourbon/generator.rb
@@ -50,7 +50,6 @@ def install_path
50 50
51 51 def install_files
52 52 make_lib_directory
53   - copy_in_sass_extensions
54 53 copy_in_scss_files
55 54 end
56 55
@@ -59,13 +58,7 @@ def remove_bourbon_directory
59 58 end
60 59
61 60 def make_lib_directory
62   - FileUtils.mkdir_p(install_path.join('lib', 'bourbon'))
63   - end
64   -
65   - def copy_in_sass_extensions
66   - FileUtils.cp(File.join(lib_directory, 'bourbon.rb'), install_path.join('lib'))
67   - FileUtils.cp(File.join(lib_bourbon_directory, 'sass_extensions.rb'), install_path.join('lib', 'bourbon'))
68   - FileUtils.cp_r(File.join(lib_bourbon_directory, 'sass_extensions'), install_path.join('lib', 'bourbon'))
  61 + FileUtils.mkdir_p(install_path)
69 62 end
70 63
71 64 def copy_in_scss_files
@@ -80,14 +73,6 @@ def stylesheets_directory
80 73 File.join(top_level_directory, "app", "assets", "stylesheets")
81 74 end
82 75
83   - def lib_directory
84   - File.join(top_level_directory, "lib")
85   - end
86   -
87   - def lib_bourbon_directory
88   - File.join(top_level_directory, "lib", "bourbon")
89   - end
90   -
91 76 def top_level_directory
92 77 File.dirname(File.dirname(File.dirname(__FILE__)))
93 78 end
8 lib/bourbon/sass_extensions.rb
... ... @@ -1,8 +0,0 @@
1   -module Bourbon::SassExtensions
2   -end
3   -
4   -unless defined?(Sass)
5   - require 'sass'
6   -end
7   -
8   -require File.join(File.dirname(__FILE__), '/sass_extensions/functions')
13 lib/bourbon/sass_extensions/functions.rb
... ... @@ -1,13 +0,0 @@
1   -module Bourbon::SassExtensions::Functions
2   -end
3   -
4   -require File.join(File.dirname(__FILE__), "/functions/compact")
5   -
6   -module Sass::Script::Functions
7   - include Bourbon::SassExtensions::Functions::Compact
8   -end
9   -
10   -# Wierd that this has to be re-included to pick up sub-modules. Ruby bug?
11   -class Sass::Script::Functions::EvaluationContext
12   - include Sass::Script::Functions
13   -end
14 lib/bourbon/sass_extensions/functions/compact.rb
... ... @@ -1,14 +0,0 @@
1   -# Compact function pulled from compass
2   -module Bourbon::SassExtensions::Functions::Compact
3   -
4   - def compact(*args)
5   - sep = :comma
6   - if args.size == 1 && args.first.is_a?(Sass::Script::List)
7   - list = args.first
8   - args = list.value
9   - sep = list.separator
10   - end
11   - Sass::Script::List.new(args.reject{|a| !a.to_bool}, sep)
12   - end
13   -
14   -end

0 comments on commit 7a359c2

Please sign in to comment.
Something went wrong with that request. Please try again.