sass-json-vars 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 965ec563b6eb40a36d01af3e91b0dab01f922cee
4
- data.tar.gz: 7ca2475cef5ed0c10d217c1ea442e078c45018bd
3
+ metadata.gz: 04a057f4ee1cfa22a9d04208dbf70ac34fb37ad5
4
+ data.tar.gz: 34d30e1f2dc0a26a7e1155686f11d72dbe83a3b1
5
5
  SHA512:
6
- metadata.gz: b21412c04ba406055516f573af4b0ea48fce4d073900f18bf6efe59a9e7e02e797db0097de75ffaaf7b836de30f9940af8a793047d1e4d07a7c3d5d9da4eb2d0
7
- data.tar.gz: a1ad110731657f57d0ce505023caf821b48330ff850688eab4405e2523f5195407d51cae039e6310c428e4efebbbe71abbdad7db7c44fbd94f0e897aee85e5f8
6
+ metadata.gz: f258552b4eb6bd8d2ec46c668cb6db8acca3f0ff9ed81bc151ebb9324c3044adab12462de53fd2517706d19b43bca8ac7f0b53231c148afb4bc9168759fce4dc
7
+ data.tar.gz: c720626ba8f4b6254fd14047e8a60d03cf41a84ef3196e39fa702d4127168c2261cec77e3eebd9443dc2993cb706b1ad44943f9145fcc5ba9b30d5ed7b0e1a5e
@@ -1,2 +1,5 @@
1
1
  require 'sass-json-vars/importer'
2
2
  require 'sass-json-vars/monkeypatch'
3
+
4
+ module SassJSONVars
5
+ end
@@ -1,52 +1,55 @@
1
1
  require 'sass'
2
2
  require 'json'
3
3
 
4
- class SassJSONVars::Importer < Sass::Importers::Filesystem
4
+ module SassJSONVars
5
+ class Importer < Sass::Importers::Filesystem
5
6
 
6
- def watched_file?(uri)
7
- uri =~ /\.json$/ &&
8
- uri.start_with?(root + File::SEPARATOR)
9
- end
7
+ def watched_file?(uri)
8
+ !!(uri =~ /\.json$/ &&
9
+ uri.start_with?(root + File::SEPARATOR))
10
+ end
10
11
 
11
- protected
12
+ protected
12
13
 
13
- def extensions
14
- {'json' => :scss}
15
- end
14
+ def extensions
15
+ {'json' => :scss}
16
+ end
16
17
 
17
- def json?(name)
18
- File.extname(name) == '.json'
19
- end
18
+ def json?(name)
19
+ File.extname(name) == '.json'
20
+ end
20
21
 
21
- private
22
+ private
22
23
 
23
- def _find(dir, name, options)
24
- return unless json? name
24
+ def _find(dir, name, options)
25
+ return unless json? name
25
26
 
26
- full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
27
- return unless full_filename && File.readable?(full_filename)
27
+ full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
28
+ return unless full_filename && File.readable?(full_filename)
28
29
 
29
- json = JSON.parse(IO.read(full_filename))
30
- variables = json.map { |key, value| "$#{key}: #{_convert_to_sass(value)}" }.join("\n")
30
+ json = JSON.parse(IO.read(full_filename))
31
+ variables = json.map { |key, value| "$#{key}: #{_convert_to_sass(value)}" }.join("\n")
31
32
 
32
- Sass::Engine.new(variables)
33
- end
33
+ Sass::Engine.new(variables)
34
+ end
34
35
 
35
- def _convert_to_sass(item)
36
- if item.is_a? Array
37
- _make_list(item)
38
- elsif item.is_a? Hash
39
- _make_map(item)
40
- else
41
- item
36
+ def _convert_to_sass(item)
37
+ if item.is_a? Array
38
+ _make_list(item)
39
+ elsif item.is_a? Hash
40
+ _make_map(item)
41
+ else
42
+ item
43
+ end
42
44
  end
43
- end
44
45
 
45
- def _make_list(item)
46
- '(' + item.map { |i| _convert_to_sass(i) }.join(',') + ')'
47
- end
46
+ def _make_list(item)
47
+ '(' + item.map { |i| _convert_to_sass(i) }.join(',') + ')'
48
+ end
48
49
 
49
- def _make_map(item)
50
- '(' + item.map {|key, value| key.to_s + ':' + _convert_to_sass(value) }.join(',') + ')'
50
+ def _make_map(item)
51
+ '(' + item.map {|key, value| key.to_s + ':' + _convert_to_sass(value) }.join(',') + ')'
52
+ end
51
53
  end
54
+
52
55
  end
@@ -1,3 +1,3 @@
1
1
  module SassJSONVars
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/readme.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Sass JSON Vars
2
2
 
3
- [![Build Status](https://travis-ci.org/vigetlabs/sass-json-vars.png?branch=master)](https://travis-ci.org/vigetlabs/sass-json-vars) [![Gem Version](https://badge.fury.io/rb/sass-json-vars.png)](http://badge.fury.io/rb/sass-json-vars)
3
+ [![Build Status](https://travis-ci.org/vigetlabs/sass-json-vars.png?branch=master)](https://travis-ci.org/vigetlabs/sass-json-vars)
4
+ [![Coverage Status](https://coveralls.io/repos/vigetlabs/sass-json-vars/badge.png)](https://coveralls.io/r/vigetlabs/sass-json-vars)
5
+ [![Code Climate](https://codeclimate.com/github/vigetlabs/sass-json-vars.png)](https://codeclimate.com/github/vigetlabs/sass-json-vars)
6
+ [![Gem Version](https://badge.fury.io/rb/sass-json-vars.png)](http://badge.fury.io/rb/sass-json-vars)
4
7
 
5
8
  `@import` json data into Sass `$variables`.
6
9
 
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+ require 'test/unit'
3
+ require 'sass'
4
+ require 'sass-json-vars'
5
+
6
+ class SassJSONVarsImporterTest < Test::Unit::TestCase
7
+ def test_unwatched_non_json_file
8
+ unwatched_file = make_path(root, 'style.scss')
9
+ assert_equal false, importer.watched_file?(unwatched_file)
10
+ end
11
+
12
+ def test_unwatched_non_root_file
13
+ unwatched_file = make_path([File.dirname(__FILE__)], 'fixtures', 'maps', 'variables.json')
14
+ assert_equal false, importer.watched_file?(unwatched_file)
15
+ end
16
+
17
+ def test_watched_file
18
+ watched_file = make_path(root, 'variables.json')
19
+ assert_equal true, importer.watched_file?(watched_file)
20
+ end
21
+
22
+ private
23
+
24
+ def importer
25
+ @importer ||= SassJSONVars::Importer.new(root)
26
+ end
27
+
28
+ def root
29
+ make_path [File.dirname(__FILE__)], 'fixtures', 'strings'
30
+ end
31
+
32
+ def make_path(*path_components)
33
+ path_components.join(File::SEPARATOR)
34
+ end
35
+ end
@@ -1,3 +1,4 @@
1
+ require 'test_helper'
1
2
  require 'test/unit'
2
3
  require 'sass'
3
4
  require 'sass-json-vars'
@@ -1,3 +1,4 @@
1
+ require 'test_helper'
1
2
  require 'test/unit'
2
3
  require 'sass'
3
4
  require 'sass-json-vars'
@@ -0,0 +1,5 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ SimpleCov.start 'rails'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-json-vars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Hunzaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: simplecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
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'
27
55
  description: Allows the use of JSON to declare variables with @import 'file.json'.
28
56
  email:
29
57
  - nate.hunzaker@viget.com
@@ -45,8 +73,10 @@ files:
45
73
  - test/fixtures/sass/variables.json
46
74
  - test/fixtures/strings/style.scss
47
75
  - test/fixtures/strings/variables.json
76
+ - test/sass-json-vars_importer_test.rb
48
77
  - test/sass-json-vars_test.rb
49
78
  - test/sass_test.rb
79
+ - test/test_helper.rb
50
80
  homepage: https://github.com/vigetlabs/sass-json-vars
51
81
  licenses:
52
82
  - MIT
@@ -80,5 +110,7 @@ test_files:
80
110
  - test/fixtures/sass/variables.json
81
111
  - test/fixtures/strings/style.scss
82
112
  - test/fixtures/strings/variables.json
113
+ - test/sass-json-vars_importer_test.rb
83
114
  - test/sass-json-vars_test.rb
84
115
  - test/sass_test.rb
116
+ - test/test_helper.rb