compass-import-once 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28596ec96dcd5b1e89c2f93ace9d3518fb204d4d
4
+ data.tar.gz: 61974005b3c6f65b7886797fb8fee1365c63216e
5
+ SHA512:
6
+ metadata.gz: 26e5401d031e9529452769b41f6bf64b80c544bf7a91ed8aaaa7f1a1c8019daa67ac9a4d3636a32cea839251d7717d40398fd155de643f30cd1ac7e2f0559a7a
7
+ data.tar.gz: 652966b41118c5f3eefae3b9b9208d6e5c3867d57c4a4d3a9cbfe674c6f968340857446d26143f06e1535b44d0249438d88df88c903918ab004083ea22d8bac3
data/.gitignore CHANGED
@@ -3,7 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
6
+ Gemfile*.lock
7
7
  InstalledFiles
8
8
  _yardoc
9
9
  coverage
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'sass', '~> 3.2.15'
data/README.md CHANGED
@@ -11,9 +11,9 @@ without compass in any Sass-based project.
11
11
 
12
12
  ## Installation
13
13
 
14
- Or add this line to your application's Gemfile if you have one:
14
+ Either add this line to your application's Gemfile if you have one:
15
15
 
16
- gem 'compass-import-once', :require => "compass/import-once/activate"
16
+ gem 'compass-import-once', :require => 'compass/import-once/activate'
17
17
 
18
18
  And then execute:
19
19
 
@@ -25,6 +25,12 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
+ To use with the Sass command line:
29
+
30
+ ```
31
+ sass -r 'compass/import-once/activate' ...
32
+ ```
33
+
28
34
  To enable in non-compass environments there's two options:
29
35
 
30
36
  require 'compass/import-once/activate'
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ t.verbose = true
9
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
@@ -18,6 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "sass", ">= 3.2", "< 3.5"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "diff-lcs"
22
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "sass-globbing"
23
26
  end
@@ -2,18 +2,18 @@ module Compass
2
2
  module ImportOnce
3
3
  # Any importer object that is extended with this module will get the import once behavior.
4
4
  module Importer
5
- def find_relative(uri, base, options)
5
+ def find_relative(uri, base, options, *args)
6
6
  uri, force_import = handle_force_import(uri)
7
- maybe_replace_with_dummy_engine(super(uri, base, options), options, force_import)
7
+ maybe_replace_with_dummy_engine(super(uri, base, options, *args), options, force_import)
8
8
  end
9
9
 
10
- def find(uri, options)
10
+ def find(uri, options, *args)
11
11
  uri, force_import = handle_force_import(uri)
12
- maybe_replace_with_dummy_engine(super(uri, options), options, force_import)
12
+ maybe_replace_with_dummy_engine(super(uri, options, *args), options, force_import)
13
13
  end
14
14
 
15
15
  # ensure that all dummy engines share the same sass cache entry.
16
- def key(uri, options)
16
+ def key(uri, options, *args)
17
17
  if uri =~ /^\(NOT IMPORTED\)/
18
18
  ["(import-once)", "dummy_engine"]
19
19
  else
@@ -21,7 +21,7 @@ module Compass
21
21
  end
22
22
  end
23
23
 
24
- def mtime(uri, options)
24
+ def mtime(uri, options, *args)
25
25
  if uri =~ /^\(NOT IMPORTED\) (.*)$/
26
26
  File.mtime($1)
27
27
  else
@@ -0,0 +1,48 @@
1
+ require 'diff/lcs'
2
+ require 'diff/lcs/hunk'
3
+
4
+ module DiffAsString
5
+ #stole this from rspec who stole this from the gem
6
+ def diff_as_string(data_old, data_new)
7
+ data_old = data_old.split(/\n/).map! { |e| e.chomp }
8
+ data_new = data_new.split(/\n/).map! { |e| e.chomp }
9
+ output = ""
10
+ diffs = ::Diff::LCS.diff(data_old, data_new)
11
+ return output if diffs.empty?
12
+ oldhunk = hunk = nil
13
+ file_length_difference = 0
14
+ diffs.each do |piece|
15
+ begin
16
+ hunk = ::Diff::LCS::Hunk.new(
17
+ data_old, data_new, piece, context_lines, file_length_difference
18
+ )
19
+ file_length_difference = hunk.file_length_difference
20
+ next unless oldhunk
21
+ # Hunks may overlap, which is why we need to be careful when our
22
+ # diff includes lines of context. Otherwise, we might print
23
+ # redundant lines.
24
+ if (context_lines > 0) and hunk.overlaps?(oldhunk)
25
+ hunk.unshift(oldhunk)
26
+ else
27
+ output << oldhunk.diff(format)
28
+ end
29
+ ensure
30
+ oldhunk = hunk
31
+ output << "\n"
32
+ end
33
+ end
34
+ #Handle the last remaining hunk
35
+ output << oldhunk.diff(format) << "\n"
36
+ end
37
+
38
+ protected
39
+
40
+ def format
41
+ :unified
42
+ end
43
+
44
+ def context_lines
45
+ 3
46
+ end
47
+
48
+ end
@@ -0,0 +1,5 @@
1
+ $simple-imported: 0 !default;
2
+ $simple-imported: $simple-imported + 1;
3
+ .simple {
4
+ times-imported: $simple-imported;
5
+ }
@@ -0,0 +1,3 @@
1
+ .simple {
2
+ times-imported: 1;
3
+ }
@@ -0,0 +1,2 @@
1
+ @import "simple_partial";
2
+ @import "simple_partial";
@@ -0,0 +1,7 @@
1
+ .simple {
2
+ times-imported: 1;
3
+ }
4
+
5
+ .simple {
6
+ times-imported: 2;
7
+ }
@@ -0,0 +1,2 @@
1
+ @import "simple_partial";
2
+ @import "simple_partial!";
@@ -0,0 +1,3 @@
1
+ .simple {
2
+ times-imported: 1;
3
+ }
@@ -0,0 +1,2 @@
1
+ @import "simple_*";
2
+ @import "simple_partial";
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test_helper'
3
+ require 'fileutils'
4
+
5
+ class ImportOnceTest < Test::Unit::TestCase
6
+ FIXTURES_DIR = File.join(File.expand_path(File.dirname(__FILE__)), "fixtures")
7
+ Dir.glob(File.join(FIXTURES_DIR, "**", "*.scss")).each do |scss_file|
8
+ if ENV["FIXTURE"]
9
+ next unless File.expand_path(ENV["FIXTURE"]) == scss_file
10
+ end
11
+ dir = File.dirname(scss_file)
12
+ basename = File.basename(scss_file, ".scss")
13
+ next if basename.start_with?("_")
14
+ define_method "test_#{basename}" do
15
+ assert_compilation_result(
16
+ File.join(dir, "#{basename}.scss"),
17
+ File.join(dir, "#{basename}.css"))
18
+ end
19
+ end
20
+
21
+ protected
22
+
23
+ def assert_compilation_result(sass_file, css_file, options = {})
24
+ options[:style] ||= :expanded
25
+ actual_result = Sass.compile_file(sass_file, options)
26
+ expected_result = File.read(css_file)
27
+ assert expected_result == actual_result, diff_as_string(expected_result, actual_result)
28
+ FileUtils.rm_f("#{css_file}.error") # cleanup from old tests now that it's passing
29
+ rescue Exception => e
30
+ open("#{css_file}.error", "w") {|f| f.write(actual_result) }
31
+ raise
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ require 'sass'
2
+ require 'compass/import-once/activate'
3
+ require 'sass-globbing'
4
+ require 'test/unit'
5
+ require 'diff_as_string'
6
+
7
+ class Test::Unit::TestCase
8
+ include DiffAsString
9
+ end
metadata CHANGED
@@ -1,20 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-import-once
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
5
- prerelease:
4
+ version: 1.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Eppstein
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-12-23 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '3.5'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '3.5'
14
33
  - !ruby/object:Gem::Dependency
15
34
  name: bundler
16
35
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
36
  requirements:
19
37
  - - ~>
20
38
  - !ruby/object:Gem::Version
@@ -22,25 +40,50 @@ dependencies:
22
40
  type: :development
23
41
  prerelease: false
24
42
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
43
  requirements:
27
44
  - - ~>
28
45
  - !ruby/object:Gem::Version
29
46
  version: '1.3'
47
+ - !ruby/object:Gem::Dependency
48
+ name: diff-lcs
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
30
61
  - !ruby/object:Gem::Dependency
31
62
  name: rake
32
63
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
64
  requirements:
35
- - - ! '>='
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: sass-globbing
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
36
80
  - !ruby/object:Gem::Version
37
81
  version: '0'
38
82
  type: :development
39
83
  prerelease: false
40
84
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
85
  requirements:
43
- - - ! '>='
86
+ - - '>='
44
87
  - !ruby/object:Gem::Version
45
88
  version: '0'
46
89
  description: Changes the behavior of Sass's @import directive to only import a file
@@ -53,6 +96,7 @@ extra_rdoc_files: []
53
96
  files:
54
97
  - .gitignore
55
98
  - Gemfile
99
+ - Gemfile_sass_3_2
56
100
  - LICENSE.txt
57
101
  - README.md
58
102
  - Rakefile
@@ -64,30 +108,49 @@ files:
64
108
  - lib/compass/import-once/engine.rb
65
109
  - lib/compass/import-once/importer.rb
66
110
  - lib/compass/import-once/version.rb
111
+ - test/diff_as_string.rb
112
+ - test/fixtures/_simple_partial.scss
113
+ - test/fixtures/basic.css
114
+ - test/fixtures/basic.scss
115
+ - test/fixtures/force_import.css
116
+ - test/fixtures/force_import.scss
117
+ - test/fixtures/with_globbing.css
118
+ - test/fixtures/with_globbing.scss
119
+ - test/import_once_test.rb
120
+ - test/test_helper.rb
67
121
  homepage: https://github.com/chriseppstein/compass/tree/master/import-once
68
122
  licenses:
69
123
  - MIT
124
+ metadata: {}
70
125
  post_install_message:
71
126
  rdoc_options: []
72
127
  require_paths:
73
128
  - lib
74
129
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
130
  requirements:
77
- - - ! '>='
131
+ - - '>='
78
132
  - !ruby/object:Gem::Version
79
133
  version: '0'
80
134
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
135
  requirements:
83
- - - ! '>='
136
+ - - '>='
84
137
  - !ruby/object:Gem::Version
85
138
  version: '0'
86
139
  requirements: []
87
140
  rubyforge_project:
88
- rubygems_version: 1.8.23
141
+ rubygems_version: 2.0.3
89
142
  signing_key:
90
- specification_version: 3
143
+ specification_version: 4
91
144
  summary: Speed up your Sass compilation by making @import only import each file once.
92
- test_files: []
145
+ test_files:
146
+ - test/diff_as_string.rb
147
+ - test/fixtures/_simple_partial.scss
148
+ - test/fixtures/basic.css
149
+ - test/fixtures/basic.scss
150
+ - test/fixtures/force_import.css
151
+ - test/fixtures/force_import.scss
152
+ - test/fixtures/with_globbing.css
153
+ - test/fixtures/with_globbing.scss
154
+ - test/import_once_test.rb
155
+ - test/test_helper.rb
93
156
  has_rdoc: