sassconf 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +192 -0
- data/Rakefile +1 -0
- data/bin/sassconf +14 -0
- data/bin/setup +7 -0
- data/lib/sassconf/config_reader.rb +56 -0
- data/lib/sassconf/core_extensions.rb +60 -0
- data/lib/sassconf/logger.rb +30 -0
- data/lib/sassconf/sass_executor.rb +46 -0
- data/lib/sassconf/util.rb +8 -0
- data/lib/sassconf/version.rb +3 -0
- data/lib/sassconf.rb +78 -0
- data/sassconf.gemspec +30 -0
- data/test/resources/Config.rb +5 -0
- data/test/resources/Input.scss +6 -0
- data/test/test_config_reader.rb +50 -0
- data/test/test_sass_executor.rb +86 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fefedce326c30fe6076ff27683fb4fa91a05efda
|
4
|
+
data.tar.gz: 3d253f23d6bb31ce5c81718347645e0bcab4c3e8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 24a52a90d53f90bf2a397329b57a4674b93e90871fbd2065b6b18d30f0825436b26e8ab37af9b30add98738930c2e37b3c9b11a6858f9f1fa8172a1352e0fc49
|
7
|
+
data.tar.gz: 18f491a65cd80cc072ad9a12555c33ba40126129f3f149690d6606252bc547b1ce689bc0e419c68de10c6d01b1e8b3d65e9ebfd1f942155eb1f7293c10f16000
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Marcel Schlegel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
# Sassconf
|
2
|
+
|
3
|
+
With the Sassconf command tool you can use a config file for defining your [Sass](https://github.com/sass/sass) options.
|
4
|
+
If you liked the config file in any Compass environment then you'll like that one also because it's very similar :)
|
5
|
+
|
6
|
+
## Requirements
|
7
|
+
|
8
|
+
- [Sass](https://github.com/sass/sass)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Install it directly from [RubyGems](https://rubygems.org):
|
13
|
+
|
14
|
+
```bash
|
15
|
+
gem install sassconf
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
General usage:
|
21
|
+
|
22
|
+
```bash
|
23
|
+
sassconf [options] [INPUT] [OUTPUT]
|
24
|
+
```
|
25
|
+
|
26
|
+
You can type:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
sassconf -h
|
30
|
+
```
|
31
|
+
|
32
|
+
or only:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
sassconf
|
36
|
+
```
|
37
|
+
|
38
|
+
in your console for show the help text.
|
39
|
+
|
40
|
+
###Config File
|
41
|
+
For using options from Sass you have to use special variable prefixes "arg_NAME" and "varg_NAME".
|
42
|
+
|
43
|
+
- "arg_NAME" for any [Sass](http://sass-lang.com/documentation/file.SASS_REFERENCE.html) options without a "=" sign like:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
--style
|
47
|
+
--load-path
|
48
|
+
--no-cache
|
49
|
+
...
|
50
|
+
```
|
51
|
+
- "varg_NAME" for any [Sass](http://sass-lang.com/documentation/file.SASS_REFERENCE.html) options with a "=" sign like:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
--sourcemap
|
55
|
+
```
|
56
|
+
|
57
|
+
If there is an option with a "-" sign, you have to replace it with a "_" sign in your variable like:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
"no-cache" changes to "arg_no_cache"
|
61
|
+
```
|
62
|
+
|
63
|
+
If there is an option without a value, you have to define it with the symbol ":no_value" like:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
arg_no_cache = :no_value
|
67
|
+
```
|
68
|
+
|
69
|
+
Example config:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
arg_style = 'compressed'
|
73
|
+
arg_load_path = '/your/path'
|
74
|
+
arg_no_cache = :no_value
|
75
|
+
varg_sourcemap = 'none'
|
76
|
+
arg_precision = 10
|
77
|
+
```
|
78
|
+
|
79
|
+
You can also set a list of values on the command line which you can use in your config file:
|
80
|
+
|
81
|
+
```bash
|
82
|
+
sassconf --config /path/config.rb --args value1,value2,value3
|
83
|
+
```
|
84
|
+
|
85
|
+
In your config file you have to use the array "extern_args" like:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
extern_args[0] #For "value1"
|
89
|
+
extern_args[1] #For "value2"
|
90
|
+
extern_args[2] #For "value3"
|
91
|
+
arg_style = 'compressed'
|
92
|
+
...
|
93
|
+
```
|
94
|
+
|
95
|
+
##CommandLine Options
|
96
|
+
|
97
|
+
###Required Options
|
98
|
+
- -c, --config CONFIG_FILE
|
99
|
+
- Specify a ruby config file e.g.: /PATH/config.rb
|
100
|
+
|
101
|
+
###Optional Options
|
102
|
+
- -a, --args ARGS
|
103
|
+
- Comma separated list of values e.g.: val_a, val_b,...
|
104
|
+
|
105
|
+
- v, --verbose
|
106
|
+
- Print all log messages.
|
107
|
+
|
108
|
+
- -?, -h, --help
|
109
|
+
- Show help text.
|
110
|
+
|
111
|
+
##Examples
|
112
|
+
###Sample 1 - Input Output File
|
113
|
+
|
114
|
+
**config.rb**
|
115
|
+
```ruby
|
116
|
+
production = false
|
117
|
+
arg_no_cache = :no_value
|
118
|
+
varg_style = production ? 'compressed' : 'expanded'
|
119
|
+
test_no_arg = 'no_arg'
|
120
|
+
varg_sourcemap = 'none'
|
121
|
+
```
|
122
|
+
|
123
|
+
**input.scss**
|
124
|
+
```sass
|
125
|
+
$color: #3BBECE;
|
126
|
+
|
127
|
+
.navigation {
|
128
|
+
border-color: $color;
|
129
|
+
color: darken($color, 9%);
|
130
|
+
}
|
131
|
+
```
|
132
|
+
|
133
|
+
**In console type:**
|
134
|
+
|
135
|
+
```bash
|
136
|
+
sassconf -c ./config.rb ./input.scss ./output.css
|
137
|
+
```
|
138
|
+
|
139
|
+
**Result:**
|
140
|
+
|
141
|
+
**output.css**
|
142
|
+
```css
|
143
|
+
.navigation {
|
144
|
+
border-color: #3BBFCE;
|
145
|
+
color: #2ca2af;
|
146
|
+
}
|
147
|
+
```
|
148
|
+
|
149
|
+
###Sample 2 - Use a "Filewatcher"
|
150
|
+
|
151
|
+
**config.rb**
|
152
|
+
```ruby
|
153
|
+
production = false
|
154
|
+
arg_no_cache = :no_value
|
155
|
+
varg_style = production ? 'compressed' : 'expanded'
|
156
|
+
test_no_arg = 'no_arg'
|
157
|
+
varg_sourcemap = 'none'
|
158
|
+
arg_watch = "./:./out"
|
159
|
+
```
|
160
|
+
|
161
|
+
**input.scss**
|
162
|
+
```sass
|
163
|
+
$color: #3BBECE;
|
164
|
+
|
165
|
+
.navigation {
|
166
|
+
border-color: $color;
|
167
|
+
color: darken($color, 9%);
|
168
|
+
}
|
169
|
+
```
|
170
|
+
|
171
|
+
**In console type:**
|
172
|
+
|
173
|
+
```bash
|
174
|
+
sassconf -c ./config.rb
|
175
|
+
```
|
176
|
+
|
177
|
+
**Console Output:**
|
178
|
+
```bash
|
179
|
+
>>> Sass is watching for changes. Press Ctrl-C to stop.
|
180
|
+
directory ./out
|
181
|
+
write ./out/input.css
|
182
|
+
```
|
183
|
+
|
184
|
+
**Result:**
|
185
|
+
|
186
|
+
**/out/input.css**
|
187
|
+
```css
|
188
|
+
.navigation {
|
189
|
+
border-color: #3BBFCE;
|
190
|
+
color: #2ca2af;
|
191
|
+
}
|
192
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/sassconf
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'sassconf'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative 'util'
|
2
|
+
require_relative 'logger'
|
3
|
+
require_relative 'core_extensions'
|
4
|
+
|
5
|
+
module Sassconf
|
6
|
+
class ConfigReader
|
7
|
+
include Logging
|
8
|
+
|
9
|
+
VARIABLE_PREFIX = 'arg_'
|
10
|
+
VARIABLE_WITH_VALUE_PREFIX = 'varg_'
|
11
|
+
ARRAY_FROM_STRING_SEPARATOR = ','
|
12
|
+
|
13
|
+
def eval_rb_file(file_path, extern_string_array = String.empty)
|
14
|
+
Util.pre_check((file_path.is_string? and file_path.is_not_nil_or_empty? and File.exist?(file_path)), "\"rb\" file path is no string, nil, empty or doesn't exist.")
|
15
|
+
Util.pre_check((extern_string_array.is_string? and !extern_string_array.nil?), 'Extern string array is no string or nil.')
|
16
|
+
|
17
|
+
@bind_extern_string_array = extern_string_array
|
18
|
+
inject_array = 'extern_args = create_array_from_string(@bind_extern_string_array);'
|
19
|
+
source_file = File.read(file_path)
|
20
|
+
collect_variables = '@vh = create_variable_hash(local_variables, binding); @vwvh = create_variable_with_value_hash(local_variables, binding)'
|
21
|
+
eval("#{inject_array} \n #{source_file} \n #{collect_variables}", reader_binding)
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def variable_hash
|
26
|
+
@vh
|
27
|
+
end
|
28
|
+
|
29
|
+
def variable_with_value_hash
|
30
|
+
@vwvh
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def create_variable_hash(variables, binding)
|
35
|
+
create_hash(VARIABLE_PREFIX, variables, binding)
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_variable_with_value_hash(variables, binding)
|
39
|
+
create_hash(VARIABLE_WITH_VALUE_PREFIX, variables, binding)
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_hash(prefix, variables, binding)
|
43
|
+
logger.info("Create Sass argument hash from config variables: #{variables}")
|
44
|
+
variables.reduce({}) { |hash, var| var_string = var.to_s; var_string.start_with?(prefix) ? hash.merge(var_string.sub(prefix, String.empty).gsub('_', '-') => eval(var_string, binding)) : hash }
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_array_from_string(arg)
|
48
|
+
logger.info("Create \"extern_args\" array from string: #{arg}")
|
49
|
+
arg.split(ARRAY_FROM_STRING_SEPARATOR).collect { |elem| elem.strip }
|
50
|
+
end
|
51
|
+
|
52
|
+
def reader_binding
|
53
|
+
binding
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'util'
|
2
|
+
|
3
|
+
module Sassconf
|
4
|
+
module CoreExtensions
|
5
|
+
module Object
|
6
|
+
def is_string?
|
7
|
+
false
|
8
|
+
end
|
9
|
+
|
10
|
+
def is_hash?
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module String
|
16
|
+
def self.included(base)
|
17
|
+
base.extend(ClassMethods)
|
18
|
+
end
|
19
|
+
|
20
|
+
def is_string?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def is_not_nil_or_empty?
|
25
|
+
!(self.nil? || self.empty?)
|
26
|
+
end
|
27
|
+
|
28
|
+
def newline(count = 1, side = :right)
|
29
|
+
count.times { side == :left ? self.insert(0, "\n") : self << "\n" }
|
30
|
+
self << (block_given? ? yield : '')
|
31
|
+
end
|
32
|
+
|
33
|
+
def paragraph(count = 1, side = :right)
|
34
|
+
count.times { side == :left ? self.insert(0, "\n\n") : self << "\n\n" }
|
35
|
+
self << (block_given? ? yield : '')
|
36
|
+
end
|
37
|
+
|
38
|
+
def blank(count = 1, side = :right)
|
39
|
+
count.times { side == :left ? self.insert(0, ' ') : self << ' ' }
|
40
|
+
self << (block_given? ? yield : '')
|
41
|
+
end
|
42
|
+
|
43
|
+
module ClassMethods
|
44
|
+
def empty
|
45
|
+
''
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
module Hash
|
51
|
+
def is_hash?
|
52
|
+
true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Object.include(Sassconf::CoreExtensions::Object)
|
58
|
+
String.include(Sassconf::CoreExtensions::String)
|
59
|
+
Hash.include(Sassconf::CoreExtensions::Hash)
|
60
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Sassconf
|
4
|
+
module Logging
|
5
|
+
def logger
|
6
|
+
@logger ||= Logging.logger_for(self.class.name)
|
7
|
+
end
|
8
|
+
|
9
|
+
@loggers = {}
|
10
|
+
|
11
|
+
class << self
|
12
|
+
@@active = false
|
13
|
+
|
14
|
+
def activate()
|
15
|
+
@@active = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def logger_for(classname)
|
19
|
+
@loggers[classname] ||= configure_logger_for(classname)
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure_logger_for(classname)
|
23
|
+
logger = Logger.new(@@active ? STDOUT : nil)
|
24
|
+
logger.progname = classname
|
25
|
+
logger.level = Logger::INFO
|
26
|
+
logger
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative 'util'
|
2
|
+
require_relative 'core_extensions'
|
3
|
+
require_relative 'logger'
|
4
|
+
|
5
|
+
module Sassconf
|
6
|
+
class SassExecutor
|
7
|
+
include Logging
|
8
|
+
|
9
|
+
SASS_PROCESS = 'sass %s %s %s'
|
10
|
+
SASS_VALUE_ARGUMENT = '--%s=%s '
|
11
|
+
SASS_ARGUMENT = '--%s %s '
|
12
|
+
|
13
|
+
def initialize(sass_input, sass_output)
|
14
|
+
@sass_input = sass_input
|
15
|
+
@sass_output = sass_output
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_argument_with_value_string(argument_hash)
|
19
|
+
create_string(SASS_VALUE_ARGUMENT, argument_hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_argument_string(argument_hash)
|
23
|
+
create_string(SASS_ARGUMENT, argument_hash)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_all_argument_strings(argument_value_hash, argument_hash)
|
27
|
+
create_argument_with_value_string(argument_value_hash).concat(' ').concat(create_argument_string(argument_hash))
|
28
|
+
end
|
29
|
+
|
30
|
+
def execute(argument_string)
|
31
|
+
Util.pre_check((argument_string.is_string? and argument_string.is_not_nil_or_empty?), 'Argument string is no string, nil or empty.')
|
32
|
+
|
33
|
+
system(SASS_PROCESS % [argument_string, @sass_input, @sass_output])
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
def create_string(argument_type, argument_hash)
|
38
|
+
Util.pre_check(argument_type.is_string?, 'Argument type is no string.')
|
39
|
+
Util.pre_check((argument_hash.is_hash? and !argument_hash.nil?), 'Argument hash is no hash or nil.')
|
40
|
+
|
41
|
+
logger.info("Create argument string from hash: #{argument_hash}")
|
42
|
+
argument_hash.each { |key, value| argument_hash[key] = String.empty if value == :no_value }
|
43
|
+
argument_hash.reduce('') { |arg_string, (key, value)| arg_string.concat((argument_type % [key, value])) }.strip
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/sassconf.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'sassconf/version'
|
2
|
+
require 'sassconf/config_reader'
|
3
|
+
require 'sassconf/sass_executor'
|
4
|
+
require 'optparse'
|
5
|
+
require 'ostruct'
|
6
|
+
|
7
|
+
module Sassconf
|
8
|
+
extend Logging
|
9
|
+
|
10
|
+
class Parser
|
11
|
+
|
12
|
+
module HelpText
|
13
|
+
USAGE = 'Usage: sassconf [options] [INPUT] [OUTPUT]'.paragraph
|
14
|
+
DESCRIPTION = 'Description:'
|
15
|
+
.newline.blank(3) { 'Adds configuration file to Sass converter.' }
|
16
|
+
.newline.blank(3) { "Version #{Sassconf::VERSION}" }
|
17
|
+
.paragraph
|
18
|
+
REQUIRED = 'Required:'
|
19
|
+
OPTIONAL = 'Optional:'.newline(1, :left)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def self.parse(options)
|
24
|
+
|
25
|
+
option_args = OpenStruct.new
|
26
|
+
option_args.config_path = String.empty
|
27
|
+
option_args.extern_args = String.empty
|
28
|
+
|
29
|
+
opt_parser = OptionParser.new do |opts|
|
30
|
+
opts.banner = HelpText::USAGE
|
31
|
+
opts.separator(HelpText::DESCRIPTION)
|
32
|
+
opts.separator(HelpText::REQUIRED)
|
33
|
+
|
34
|
+
opts.on('-c', '--config CONFIG_FILE ', String, 'Specify a ruby config file e.g.: ', '/PATH/config.rb') do |elem|
|
35
|
+
option_args.config_path = elem
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.separator(HelpText::OPTIONAL)
|
39
|
+
opts.on('-a', '--args ARGS', String, 'Comma separated list of values e.g.:', 'val_a, val_b,...'.paragraph) do |elem|
|
40
|
+
option_args.extern_args = elem
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on('-v', '--verbose', 'Print all log messages.') do
|
44
|
+
Sassconf::Logging.activate()
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on('-?', '-h', '--help', 'Show this help. "Wow you really need this help?! ... Me too. ;)"') do
|
48
|
+
puts opts
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
opt_parser.parse!(options)
|
54
|
+
|
55
|
+
if option_args.config_path.empty?
|
56
|
+
puts opt_parser
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
return option_args
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
option_args = Parser.parse(ARGV)
|
65
|
+
config_reader = ConfigReader.new
|
66
|
+
executor = SassExecutor.new(ARGV[0], ARGV[1])
|
67
|
+
|
68
|
+
config_reader.eval_rb_file(option_args.config_path, option_args.extern_args)
|
69
|
+
argument_string = executor.create_all_argument_strings(config_reader.variable_with_value_hash, config_reader.variable_hash)
|
70
|
+
executor.execute(argument_string)
|
71
|
+
|
72
|
+
rescue OptionParser::MissingArgument, OptionParser::InvalidOption, SyntaxError, ArgumentError => e
|
73
|
+
puts e.message
|
74
|
+
logger.error(e)
|
75
|
+
ensure
|
76
|
+
exit
|
77
|
+
end
|
78
|
+
end
|
data/sassconf.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sassconf/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'sassconf'
|
8
|
+
spec.version = Sassconf::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.authors = ['Marcel Schlegel']
|
11
|
+
spec.homepage = ['http://sassconf.schlegel11.de']
|
12
|
+
spec.email = ['develop@schlegel11.de']
|
13
|
+
spec.licenses = ['MIT']
|
14
|
+
|
15
|
+
spec.summary = %q{Adds configuration file to Sass converter.}
|
16
|
+
spec.description = %q{With the Sassconf command tool you can use a config file for defining your Sass arguments.
|
17
|
+
If you liked the config file in any Compass environment then you'll like that one also because it's very similar.}
|
18
|
+
spec.homepage = "http://sassconf.schlegel11.de"
|
19
|
+
|
20
|
+
spec.files = `git ls-files`.split("\n")
|
21
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'sass', '>= 0'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'minitest', '>= 0'
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'sassconf/config_reader'
|
3
|
+
|
4
|
+
class TestConfigReader < Minitest::Test
|
5
|
+
CONFIG_PATH = __dir__ + '/resources/Config.rb'
|
6
|
+
|
7
|
+
# Called before every test method runs. Can be used
|
8
|
+
# to set up fixture information.
|
9
|
+
def setup
|
10
|
+
@config_reader = Sassconf::ConfigReader.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_positive_eval_rb_file
|
14
|
+
assert_equal(nil, @config_reader.variable_hash)
|
15
|
+
assert_equal(nil, @config_reader.variable_with_value_hash)
|
16
|
+
|
17
|
+
@config_reader.eval_rb_file(CONFIG_PATH)
|
18
|
+
|
19
|
+
assert_equal({'style' => 'compressed', 'sourcemap' => 'none'}, @config_reader.variable_with_value_hash)
|
20
|
+
assert_equal({'no-cache' => :no_value}, @config_reader.variable_hash)
|
21
|
+
|
22
|
+
@config_reader.eval_rb_file(CONFIG_PATH, 'dummy, inline ')
|
23
|
+
|
24
|
+
assert_equal({'style' => 'compressed', 'sourcemap' => 'inline'}, @config_reader.variable_with_value_hash)
|
25
|
+
assert_equal({'no-cache' => :no_value}, @config_reader.variable_hash)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_negative_eval_rb_file
|
29
|
+
exception = assert_raises(ArgumentError) { @config_reader.eval_rb_file('test/resources/Config_not_exist.rb') }
|
30
|
+
assert_equal("\"rb\" file path is no string, nil, empty or doesn't exist.", exception.message)
|
31
|
+
|
32
|
+
exception = assert_raises(ArgumentError) { @config_reader.eval_rb_file(String.empty) }
|
33
|
+
assert_equal("\"rb\" file path is no string, nil, empty or doesn't exist.", exception.message)
|
34
|
+
|
35
|
+
exception = assert_raises(ArgumentError) { @config_reader.eval_rb_file(nil) }
|
36
|
+
assert_equal("\"rb\" file path is no string, nil, empty or doesn't exist.", exception.message)
|
37
|
+
|
38
|
+
exception = assert_raises(ArgumentError) { @config_reader.eval_rb_file(0) }
|
39
|
+
assert_equal("\"rb\" file path is no string, nil, empty or doesn't exist.", exception.message)
|
40
|
+
|
41
|
+
exception = assert_raises(ArgumentError) { @config_reader.eval_rb_file(CONFIG_PATH, 0) }
|
42
|
+
assert_equal('Extern string array is no string or nil.', exception.message)
|
43
|
+
|
44
|
+
exception = assert_raises(ArgumentError) { @config_reader.eval_rb_file(CONFIG_PATH, nil) }
|
45
|
+
assert_equal('Extern string array is no string or nil.', exception.message)
|
46
|
+
|
47
|
+
assert_equal(nil, @config_reader.variable_with_value_hash)
|
48
|
+
assert_equal(nil, @config_reader.variable_hash)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'sassconf/sass_executor'
|
3
|
+
require 'sassconf/config_reader'
|
4
|
+
|
5
|
+
class TestSassExecuter < Minitest::Test
|
6
|
+
|
7
|
+
SCSS_PATH = __dir__ + '/resources/Input.scss'
|
8
|
+
CSS_PATH = __dir__ + '/resources/Output.css'
|
9
|
+
CONFIG_PATH = __dir__ + '/resources/Config.rb'
|
10
|
+
# Called before every test method runs. Can be used
|
11
|
+
# to set up fixture information.
|
12
|
+
def setup
|
13
|
+
@config_reader = Sassconf::ConfigReader.new
|
14
|
+
@sass_executor = Sassconf::SassExecutor.new(SCSS_PATH, CSS_PATH)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_positive_create_argument_with_value_string
|
18
|
+
@config_reader.eval_rb_file(CONFIG_PATH)
|
19
|
+
|
20
|
+
assert_equal('--style=compressed --sourcemap=none', @sass_executor.create_argument_with_value_string(@config_reader.variable_with_value_hash))
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_negative_create_argument_with_value_string
|
24
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_argument_with_value_string(String.empty) }
|
25
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
26
|
+
|
27
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_argument_with_value_string(nil) }
|
28
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_positive_create_argument_string
|
32
|
+
@config_reader.eval_rb_file(CONFIG_PATH)
|
33
|
+
|
34
|
+
assert_equal('--no-cache', @sass_executor.create_argument_string(@config_reader.variable_hash))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_negative_create_argument_string
|
38
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_argument_string(String.empty) }
|
39
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
40
|
+
|
41
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_argument_string(nil) }
|
42
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_positive_create_all_argument_strings
|
46
|
+
@config_reader.eval_rb_file(CONFIG_PATH)
|
47
|
+
|
48
|
+
assert_equal('--style=compressed --sourcemap=none --no-cache', @sass_executor.create_all_argument_strings(@config_reader.variable_with_value_hash, @config_reader.variable_hash))
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_negative_create_all_argument_strings
|
52
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_all_argument_strings(@config_reader.variable_with_value_hash, String.empty) }
|
53
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
54
|
+
|
55
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_all_argument_strings(@config_reader.variable_with_value_hash, nil) }
|
56
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
57
|
+
|
58
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_all_argument_strings(String.empty, @config_reader.variable_hash) }
|
59
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
60
|
+
|
61
|
+
exception = assert_raises(ArgumentError) { @sass_executor.create_all_argument_strings(nil, @config_reader.variable_hash) }
|
62
|
+
assert_equal('Argument hash is no hash or nil.', exception.message)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_positive_execute
|
66
|
+
@config_reader.eval_rb_file(CONFIG_PATH)
|
67
|
+
@sass_executor.execute(@sass_executor.create_all_argument_strings(@config_reader.variable_with_value_hash, @config_reader.variable_hash))
|
68
|
+
|
69
|
+
assert_equal(".navigation{border-color:#3BBFCE;color:#2ca2af}\n", File.read(CSS_PATH))
|
70
|
+
|
71
|
+
File.delete(CSS_PATH)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_negative_execute
|
75
|
+
@config_reader.eval_rb_file(CONFIG_PATH)
|
76
|
+
|
77
|
+
exception = assert_raises(ArgumentError) { @sass_executor.execute(0) }
|
78
|
+
assert_equal('Argument string is no string, nil or empty.', exception.message)
|
79
|
+
|
80
|
+
exception = assert_raises(ArgumentError) { @sass_executor.execute(String.empty) }
|
81
|
+
assert_equal('Argument string is no string, nil or empty.', exception.message)
|
82
|
+
|
83
|
+
exception = assert_raises(ArgumentError) { @sass_executor.execute(nil) }
|
84
|
+
assert_equal('Argument string is no string, nil or empty.', exception.message)
|
85
|
+
end
|
86
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sassconf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcel Schlegel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-20 00:00:00.000000000 Z
|
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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: |-
|
70
|
+
With the Sassconf command tool you can use a config file for defining your Sass arguments.
|
71
|
+
If you liked the config file in any Compass environment then you'll like that one also because it's very similar.
|
72
|
+
email:
|
73
|
+
- develop@schlegel11.de
|
74
|
+
executables:
|
75
|
+
- sassconf
|
76
|
+
- setup
|
77
|
+
extensions: []
|
78
|
+
extra_rdoc_files: []
|
79
|
+
files:
|
80
|
+
- ".gitignore"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/sassconf
|
86
|
+
- bin/setup
|
87
|
+
- lib/sassconf.rb
|
88
|
+
- lib/sassconf/config_reader.rb
|
89
|
+
- lib/sassconf/core_extensions.rb
|
90
|
+
- lib/sassconf/logger.rb
|
91
|
+
- lib/sassconf/sass_executor.rb
|
92
|
+
- lib/sassconf/util.rb
|
93
|
+
- lib/sassconf/version.rb
|
94
|
+
- sassconf.gemspec
|
95
|
+
- test/resources/Config.rb
|
96
|
+
- test/resources/Input.scss
|
97
|
+
- test/test_config_reader.rb
|
98
|
+
- test/test_sass_executor.rb
|
99
|
+
homepage: http://sassconf.schlegel11.de
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.4.5
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Adds configuration file to Sass converter.
|
123
|
+
test_files: []
|