sass-json-vars 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MzJiZmUzZjIxODQ1YzNhOTc1NDU1OWYzZTQxOGVmNGYzZDA4ZjZhNg==
5
- data.tar.gz: !binary |-
6
- ODFhYzM4ZDIxODU1ZWE5NWM3MzU4MDFkMmFkYzY5MWIyYmNjYjQ4YQ==
2
+ SHA1:
3
+ metadata.gz: 965ec563b6eb40a36d01af3e91b0dab01f922cee
4
+ data.tar.gz: 7ca2475cef5ed0c10d217c1ea442e078c45018bd
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NWIzMGMxZmUxYThmMThlZWM1NTI1NGYzNDZjYWQxMjBiNWRiZWRhMGE2MmZi
10
- ODE3ZjhiZjgwY2ZjMzg1Y2VmNGQ5MjVkZGNiNzdmOWZjMDdlMGNkYzgyYTE5
11
- NjE1OGUxMzllNDM3NDI0MjQ2MTEwZTRmZGIzMDc5OTAzZGEwZTk=
12
- data.tar.gz: !binary |-
13
- ZGI5YzMyYTZkOTVjZTA5ODdmZTFmMWYzYjM4ZmQ0MzY5YzljOTFlYzhmMDQ4
14
- MjJlMDM5ZTQwNWNiZmY0OTBlYjQ0YjJhYzk3YTcxN2I4ODQ1OGJmYzhjNzk0
15
- YjI1MGM1YWEyZDJhZDk5ODQyMzgyNTRkNjg3Y2ZmMGMwYzhiMDA=
6
+ metadata.gz: b21412c04ba406055516f573af4b0ea48fce4d073900f18bf6efe59a9e7e02e797db0097de75ffaaf7b836de30f9940af8a793047d1e4d07a7c3d5d9da4eb2d0
7
+ data.tar.gz: a1ad110731657f57d0ce505023caf821b48330ff850688eab4405e2523f5195407d51cae039e6310c428e4efebbbe71abbdad7db7c44fbd94f0e897aee85e5f8
data/Rakefile CHANGED
@@ -9,3 +9,5 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.pattern = 'test/**/*_test.rb'
10
10
  t.verbose = false
11
11
  end
12
+
13
+ task :default => :test
@@ -1,4 +1,2 @@
1
- module SassJSONVars; end
2
-
3
1
  require 'sass-json-vars/importer'
4
2
  require 'sass-json-vars/monkeypatch'
@@ -4,9 +4,12 @@ require 'json'
4
4
  class SassJSONVars::Importer < Sass::Importers::Filesystem
5
5
 
6
6
  def watched_file?(uri)
7
- uri =~ /\.json$/ && uri.start_with?(root + File::SEPARATOR)
7
+ uri =~ /\.json$/ &&
8
+ uri.start_with?(root + File::SEPARATOR)
8
9
  end
9
10
 
11
+ protected
12
+
10
13
  def extensions
11
14
  {'json' => :scss}
12
15
  end
@@ -15,36 +18,18 @@ class SassJSONVars::Importer < Sass::Importers::Filesystem
15
18
  File.extname(name) == '.json'
16
19
  end
17
20
 
18
- def find(name, options)
19
- super(name, options) if json? name
20
- end
21
-
22
- def find_relative(name, base, options)
23
- super(name, base, options) if json? name
24
- end
25
-
26
- def sass_engine(uri, options)
27
- json = JSON.parse(IO.read(uri))
28
-
29
- variables = json.map do |name, value|
30
- output = _convert_to_sass(value);
31
- "$#{name}: #{output}"
32
- end
33
-
34
- Sass::Engine.new(variables.join("\n"))
35
- end
36
-
37
21
  private
38
22
 
39
23
  def _find(dir, name, options)
24
+ return unless json? name
25
+
40
26
  full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
41
27
  return unless full_filename && File.readable?(full_filename)
42
28
 
43
- options[:syntax] = syntax
44
- options[:filename] = full_filename
45
- options[:importer] = self
29
+ json = JSON.parse(IO.read(full_filename))
30
+ variables = json.map { |key, value| "$#{key}: #{_convert_to_sass(value)}" }.join("\n")
46
31
 
47
- sass_engine(full_filename, options)
32
+ Sass::Engine.new(variables)
48
33
  end
49
34
 
50
35
  def _convert_to_sass(item)
@@ -64,5 +49,4 @@ class SassJSONVars::Importer < Sass::Importers::Filesystem
64
49
  def _make_map(item)
65
50
  '(' + item.map {|key, value| key.to_s + ':' + _convert_to_sass(value) }.join(',') + ')'
66
51
  end
67
-
68
52
  end
@@ -1,3 +1,3 @@
1
1
  module SassJSONVars
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-json-vars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
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-10 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  description: Allows the use of JSON to declare variables with @import 'file.json'.
@@ -57,17 +57,17 @@ require_paths:
57
57
  - lib
58
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ! '>='
60
+ - - '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ! '>='
65
+ - - '>='
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 2.2.1
70
+ rubygems_version: 2.2.2
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: Allows the use of JSON to declare variables with @import 'file.json'.