sasstool 0.1.0 → 0.2.2

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
  SHA256:
3
- metadata.gz: ea4326315f0d5b54d4a67d44a563e9fdb85a81f27c6ce895a077c64cfa18d472
4
- data.tar.gz: 2b87eb6577e7a46296680517478471de61eef0a6856e6dc8ea1a0336743fe8cb
3
+ metadata.gz: ef0bcf79ec7eb20aa6311274eeb54b1edf592a50db834554772f540f7cff8f81
4
+ data.tar.gz: aba3d1af516c8509486331de1028ae2de8cbce1490b6ff600c9bb9f609917289
5
5
  SHA512:
6
- metadata.gz: f368d194b91e7403eada76463281c3c798bd5474c1bdbb968189f6e4e570432326281cd1a247e42f56f3ba6b9414895b4a1c16e164a0bc7032644dfe452943ab
7
- data.tar.gz: e6fe091204da158e07ff1622fd3e7a929796bae70f631c0c3194ea0ec0000f196d0e2c934f9f98cbf95948eba069d0acca33cf88155a566ead193788ed71ee67
6
+ metadata.gz: 5c390ac0c5673e07cbf4c24bb24d9d076b221b41eeb375466d082a82c90ad31c21355bb074362646a0989d823769c442de87877040c35443c749878132dfb32a
7
+ data.tar.gz: c460510b330d6600e5b3134cfa5e861f72db2126a233aef93293d74ab93c10d7e25cef7dccf67e1868a4eea04f1f1c82857af8dca5bfdb2356175028766b12ff
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- Sasstool
2
- ==================================================
1
+ # Sasstool
3
2
 
4
3
  [![Gem Version](https://badge.fury.io/rb/sasstool.svg)](https://badge.fury.io/rb/sasstool)
5
- [![Build Status](https://travis-ci.com/DannyBen/sasstool.svg?branch=master)](https://travis-ci.com/DannyBen/sasstool)
4
+ [![Build Status](https://github.com/DannyBen/sasstool/workflows/Test/badge.svg)](https://github.com/DannyBen/sasstool/actions?query=workflow%3ATest)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/4cef96eefe9287ab6c90/maintainability)](https://codeclimate.com/github/DannyBen/sasstool/maintainability)
6
6
 
7
7
  ---
8
8
 
@@ -10,15 +10,17 @@ Sass (SassC) command line renderer with globbing import support.
10
10
 
11
11
  ---
12
12
 
13
- Installation
14
- --------------------------------------------------
13
+ ## Installation
15
14
 
16
15
  $ gem install sasstool
17
16
 
18
17
 
18
+ ## Usage
19
19
 
20
- Usage
21
- --------------------------------------------------
20
+ You can use Sasstool from the command line, or from within ruby code.
21
+
22
+
23
+ ### Rendering from the command line
22
24
 
23
25
  ```
24
26
  $ sasstool --help
@@ -37,7 +39,7 @@ Options:
37
39
 
38
40
  Parameters:
39
41
  INFILE
40
- Path to SCSS input file
42
+ Path to SCSS or SASS input file
41
43
 
42
44
  OUTDIR
43
45
  Path to CSS output directory. Can also be provided by an environment
@@ -50,4 +52,31 @@ Environment Variables:
50
52
  Examples:
51
53
  sasstool style/main.scss public/css
52
54
 
53
- ```
55
+ ```
56
+
57
+
58
+ ### Rendering from Ruby code
59
+
60
+ ```ruby
61
+ sass = Sasstool::Renderer.new 'path/to/main.scss'
62
+
63
+ # Get the CSS string
64
+ sass.render
65
+
66
+ # Get the source map string
67
+ sass.source_map
68
+
69
+ # Save both CSS and source map
70
+ sass.save 'target/directory'
71
+ ```
72
+
73
+
74
+ ## Contributing / Support
75
+
76
+ If you experience any issue, have a question or a suggestion, or if you wish
77
+ to contribute, feel free to [open an issue][issues].
78
+
79
+ ---
80
+
81
+ [issues]: https://github.com/DannyBen/sasstool/issues
82
+
data/lib/sasstool/cli.rb CHANGED
@@ -5,12 +5,9 @@ require_relative 'command'
5
5
  module Sasstool
6
6
  class CLI
7
7
  def self.router
8
- router = MisterBin::Runner.new version: VERSION,
9
- header: "SASS Tool"
10
-
11
- router.route_all to: Command
12
-
13
- router
8
+ MisterBin::Runner.new version: VERSION,
9
+ header: "SASS Tool",
10
+ handler: Command
14
11
  end
15
12
  end
16
13
  end
@@ -6,7 +6,7 @@ module Sasstool
6
6
  usage "sasstool INFILE [OUTDIR --watch]"
7
7
  usage "sasstool (-h|--help)"
8
8
 
9
- param "INFILE", "Path to SCSS input file"
9
+ param "INFILE", "Path to SCSS or SASS input file"
10
10
  param "OUTDIR", "Path to CSS output directory. Can also be provided by an environment variable"
11
11
  option "-w, --watch", "Watch the directory of the input file, and save on change"
12
12
  environment "SASSTOOL_OUTDIR", "Path to CSS output directory"
@@ -22,7 +22,7 @@ module Sasstool
22
22
 
23
23
  def watch
24
24
  dir = File.dirname args['INFILE']
25
- glob = "#{dir}/**/*.scss"
25
+ glob = "#{dir}/**/*.s[ca]ss"
26
26
  Filewatcher.new(glob).watch do
27
27
  save
28
28
  end
@@ -34,7 +34,7 @@ module Sasstool
34
34
  end
35
35
 
36
36
  def renderer
37
- @renderer ||= Renderer.new(args['INFILE'])
37
+ Renderer.new args['INFILE']
38
38
  end
39
39
 
40
40
  def outdir
@@ -4,7 +4,9 @@ module Sasstool
4
4
  if path.include? "*"
5
5
  dir = File.dirname parent_path
6
6
  glob = "#{dir}/#{path}"
7
- files = Dir[glob].select { |file| File.extname(file) == '.scss' }
7
+ files = Dir[glob].select do |file|
8
+ ['.scss', '.sass'].include? File.extname(file)
9
+ end
8
10
 
9
11
  files.map do |file|
10
12
  Import.new File.expand_path(file)
@@ -16,19 +16,35 @@ module Sasstool
16
16
  File.write "#{name}.map", source_map
17
17
  end
18
18
 
19
+ def sass?
20
+ path.end_with? 'sass'
21
+ end
22
+
23
+ def to_scss
24
+ SassC::Sass2Scss.convert file_content
25
+ end
26
+
19
27
  private
20
28
 
21
29
  def basename
22
- @basename ||= File.basename(path).gsub(/scss$/, 'css')
30
+ @basename ||= File.basename(path).gsub(/s[ca]ss$/, 'css')
31
+ end
32
+
33
+ def file_content
34
+ @file_content ||= File.read(path)
23
35
  end
24
36
 
25
37
  def scss_content
26
- scss_content ||= File.read(path)
38
+ @scss_content ||= scss_content!
39
+ end
40
+
41
+ def scss_content!
42
+ sass? ? to_scss : file_content
27
43
  end
28
44
 
29
45
  def options
30
46
  @options ||= {
31
- source_map_file: "#{path.gsub(/scss$/, 'css')}.map",
47
+ source_map_file: "#{path.gsub(/s[ca]ss$/, 'css')}.map",
32
48
  source_map_contents: true,
33
49
  style: :nested,
34
50
  importer: Importer,
@@ -1,3 +1,3 @@
1
1
  module Sasstool
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sasstool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-05 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mister_bin
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.1'
61
+ version: '2.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.1'
68
+ version: '2.0'
69
69
  description: Sass command line renderer with globbing import support
70
70
  email: db@dannyben.com
71
71
  executables:
@@ -93,14 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.4.0
96
+ version: 2.6.0
97
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.1.4
103
+ rubygems_version: 3.3.14
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Sass command line renderer