SassyExport 1.1.1 → 1.2.0

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: 508de77d8e8dfcc10b363bd5fefbd93e08af85bc
4
- data.tar.gz: 5d5e4c8343b0613438ade8808f0ecc00d667bc9b
3
+ metadata.gz: d516f53d55c3e7f0627f31e57a3ba3622b197093
4
+ data.tar.gz: 52a878d7c12f9197ef053181a75d8de5d5c3c5b1
5
5
  SHA512:
6
- metadata.gz: 74eae49f688f5dafd07e910685eb4bffcfa3dd06649f0ca8be1554733dfbced8c04601abf431e4cc16412248082d25a62cf836e26eae50d21a8bd401ce039b5b
7
- data.tar.gz: 6822ec43ab3c06c45728aa13fddeb8a5fd49038cb0ecfb709ffa05ae2d494617c421402c7216bd80807061644d7bb2afb62cd976ecbc406c1f2bc300d047c3aa
6
+ metadata.gz: 471820b590666e941d613bfa11fc7812ad6f5dac704d63953415c66d6f02c1a7a6521573924a5ac6851070b0550f423cf4326e07b4004146590c1c753f7060c0
7
+ data.tar.gz: 58175ac1215af06fe1bfc0d8f2a3b97467887766e5656209236bde4d39490f7741f5cac92bb2c607a20c2212023aae6ad717f976b45fb839fc8c2c39fa48c070
data/README.md CHANGED
@@ -36,6 +36,7 @@ $map: (
36
36
  // @param $path [string] : directory path and filename
37
37
  // @param $map [map] : map to convert to json
38
38
  // @param $pretty [bool] : pretty print json
39
+ // @param $debug [bool] : print debug string with path
39
40
  // ----------------------------------------------------------------------------------------------------
40
41
  // @return $string | write json to path
41
42
 
@@ -53,7 +54,7 @@ New JSON file is created at `./json/hello.json`. As you can see, `$path` is rela
53
54
 
54
55
  #### Breakdown
55
56
 
56
- The `SassyExport()` mixin takes a directory/filename.json `$path`, and a Sass `$map` as arguments. There is also an optional argument `$pretty` which defaults to `false`, but will print pretty JSON (nicely indented) if set to `true`.
57
+ The `SassyExport()` mixin takes a directory/filename.json `$path`, and a Sass `$map` as arguments. There is also an optional argument `$pretty` which defaults to `false`, but will print pretty JSON (nicely indented) if set to `true`.
57
58
 
58
59
  It converts the `$map` into a JSON map through Ruby, and then creates a new file (or updates an existing file), and writes the contents of the JSON string to it. I'm no Ruby expert, so if you belive that you could improve the small amount of code here, feel free to.
59
60
 
data/lib/SassyExport.rb CHANGED
@@ -7,8 +7,8 @@ Compass::Frameworks.register('SassyExport', :path => extension_path)
7
7
  # Version is a number. If a version contains alphas, it will be created as a prerelease version
8
8
  # Date is in the form of YYYY-MM-DD
9
9
  module SassyExport
10
- VERSION = "1.1.1"
11
- DATE = "2014-06-05"
10
+ VERSION = "1.2.0"
11
+ DATE = "2014-06-27"
12
12
  end
13
13
 
14
14
  # SassyExport : convert passed map to json and write to path/to/filename.json
@@ -16,11 +16,12 @@ end
16
16
  # @param path [string] : directory path and filename
17
17
  # @param map [map] : map to convert to json
18
18
  # @param pretty [bool] : pretty print json
19
+ # @param debug [bool] : print debug string with path
19
20
  # ----------------------------------------------------------------------------------------------------
20
21
  # @return string | write json to path
21
22
 
22
23
  module Sass::Script::Functions
23
- def SassyExport(path, map, pretty)
24
+ def SassyExport(path, map, pretty, debug)
24
25
 
25
26
  def opts(value)
26
27
  value.options = options
@@ -34,7 +35,7 @@ module Sass::Script::Functions
34
35
 
35
36
  # recursive parse to array
36
37
  def recurs_to_a(array)
37
- if array.is_a?(Array)
38
+ if array.is_a?(Array)
38
39
  array.map do | l |
39
40
  if l.is_a?(Sass::Script::Value::Map)
40
41
  # if map, recurse to hash
@@ -69,7 +70,7 @@ module Sass::Script::Functions
69
70
 
70
71
  # recursive parse to hash
71
72
  def recurs_to_h(hash)
72
- if hash.is_a?(Hash)
73
+ if hash.is_a?(Hash)
73
74
  hash.inject({}) do | h, (k, v) |
74
75
  if v.is_a?(Sass::Script::Value::Map)
75
76
  h[u(k)] = recurs_to_h(v)
@@ -99,9 +100,11 @@ module Sass::Script::Functions
99
100
  assert_type path, :String, :path
100
101
  assert_type map, :Map, :map
101
102
  assert_type pretty, :Bool, :pretty
103
+ assert_type debug, :Bool, :debug
102
104
 
103
105
  # parse to bool
104
106
  pretty = pretty.to_bool
107
+ debug = debug.to_bool
105
108
 
106
109
  # define root path up to current working directory
107
110
  root = Dir.pwd
@@ -125,8 +128,13 @@ module Sass::Script::Functions
125
128
  # open file [create new file if file does not exist], write string to root/path/to/filename.json
126
129
  File.open("#{dir_path}", "w") { |f| f.write(json) }
127
130
 
131
+ # print path string if debug
132
+ if debug
133
+ puts "JSON was successfully exported to #{dir_path}"
134
+ end
135
+
128
136
  # return succcess string
129
- return opts(Sass::Script::Value::String.new('JSON was successfully exported with love by SassyExport'))
137
+ return opts(Sass::Script::Value::String.new("JSON was successfully exported to #{dir_path}"))
130
138
  end
131
- declare :SassyExport, [:path, :map, :pretty]
132
- end
139
+ declare :SassyExport, [:path, :map, :pretty, :debug]
140
+ end
@@ -3,13 +3,20 @@
3
3
  // @param $path [string] : directory path and filename
4
4
  // @param $map [map] : map to convert to json
5
5
  // @param $pretty [bool] : pretty print json
6
+ // @param $debug [bool] : print debug string with path
6
7
  // ----------------------------------------------------------------------------------------------------
7
8
  // @return $string | write json to path
8
9
 
9
- @mixin SassyExport($path, $map, $pretty: false) {
10
+ @mixin SassyExport($path, $map, $pretty: false, $debug: false) {
10
11
  @at-root {
11
- %SassyExport {
12
- /* #{SassyExport($path, $map, $pretty)} */
12
+ @if $debug {
13
+ SassyExport {
14
+ content: "#{SassyExport($path, $map, $pretty, $debug)}";
15
+ }
16
+ } @else {
17
+ %SassyExport {
18
+ /* #{SassyExport($path, $map, $pretty, $debug)} */
19
+ }
13
20
  }
14
21
  }
15
- }
22
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SassyExport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezekiel Gabrielse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-05 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: json