sasstool 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ea4326315f0d5b54d4a67d44a563e9fdb85a81f27c6ce895a077c64cfa18d472
4
+ data.tar.gz: 2b87eb6577e7a46296680517478471de61eef0a6856e6dc8ea1a0336743fe8cb
5
+ SHA512:
6
+ metadata.gz: f368d194b91e7403eada76463281c3c798bd5474c1bdbb968189f6e4e570432326281cd1a247e42f56f3ba6b9414895b4a1c16e164a0bc7032644dfe452943ab
7
+ data.tar.gz: e6fe091204da158e07ff1622fd3e7a929796bae70f631c0c3194ea0ec0000f196d0e2c934f9f98cbf95948eba069d0acca33cf88155a566ead193788ed71ee67
@@ -0,0 +1,53 @@
1
+ Sasstool
2
+ ==================================================
3
+
4
+ [![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)
6
+
7
+ ---
8
+
9
+ Sass (SassC) command line renderer with globbing import support.
10
+
11
+ ---
12
+
13
+ Installation
14
+ --------------------------------------------------
15
+
16
+ $ gem install sasstool
17
+
18
+
19
+
20
+ Usage
21
+ --------------------------------------------------
22
+
23
+ ```
24
+ $ sasstool --help
25
+ sasstool - SASS Command Line Renderer
26
+
27
+ Usage:
28
+ sasstool INFILE [OUTDIR --watch]
29
+ sasstool (-h|--help)
30
+
31
+ Options:
32
+ -w, --watch
33
+ Watch the directory of the input file, and save on change
34
+
35
+ -h --help
36
+ Show this help
37
+
38
+ Parameters:
39
+ INFILE
40
+ Path to SCSS input file
41
+
42
+ OUTDIR
43
+ Path to CSS output directory. Can also be provided by an environment
44
+ variable
45
+
46
+ Environment Variables:
47
+ SASSTOOL_OUTDIR
48
+ Path to CSS output directory
49
+
50
+ Examples:
51
+ sasstool style/main.scss public/css
52
+
53
+ ```
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ require 'colsole'
3
+ require 'sasstool/cli'
4
+ include Colsole
5
+
6
+ router = Sasstool::CLI.router
7
+
8
+ begin
9
+ exit router.run ARGV
10
+ rescue => e
11
+ puts e.backtrace.reverse if ENV['DEBUG']
12
+ say! "!txtred!#{e.class}: #{e.message}"
13
+ exit 1
14
+ end
@@ -0,0 +1,8 @@
1
+ require 'sassc'
2
+ require 'sasstool/importer'
3
+ require 'sasstool/renderer'
4
+
5
+ if ENV['BYEBUG']
6
+ require 'byebug'
7
+ require 'lp'
8
+ end
@@ -0,0 +1,16 @@
1
+ require 'mister_bin'
2
+ require 'sasstool'
3
+ require_relative 'command'
4
+
5
+ module Sasstool
6
+ class CLI
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
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,46 @@
1
+ require 'filewatcher'
2
+
3
+ module Sasstool
4
+ class Command < MisterBin::Command
5
+ help "sasstool - SASS Command Line Renderer"
6
+ usage "sasstool INFILE [OUTDIR --watch]"
7
+ usage "sasstool (-h|--help)"
8
+
9
+ param "INFILE", "Path to SCSS input file"
10
+ param "OUTDIR", "Path to CSS output directory. Can also be provided by an environment variable"
11
+ option "-w, --watch", "Watch the directory of the input file, and save on change"
12
+ environment "SASSTOOL_OUTDIR", "Path to CSS output directory"
13
+
14
+ example "sasstool style/main.scss public/css"
15
+
16
+ def run
17
+ save
18
+ watch if args['--watch']
19
+ end
20
+
21
+ private
22
+
23
+ def watch
24
+ dir = File.dirname args['INFILE']
25
+ glob = "#{dir}/**/*.scss"
26
+ Filewatcher.new(glob).watch do
27
+ save
28
+ end
29
+ end
30
+
31
+ def save
32
+ renderer.save outdir
33
+ say "Saved"
34
+ end
35
+
36
+ def renderer
37
+ @renderer ||= Renderer.new(args['INFILE'])
38
+ end
39
+
40
+ def outdir
41
+ result = args['OUTDIR'] || ENV['SASSTOOL_OUTDIR']
42
+ raise ArgumentError, "Please provide an output directory" unless result
43
+ result
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,17 @@
1
+ module Sasstool
2
+ class Importer < SassC::Importer
3
+ def imports(path, parent_path)
4
+ if path.include? "*"
5
+ dir = File.dirname parent_path
6
+ glob = "#{dir}/#{path}"
7
+ files = Dir[glob].select { |file| File.extname(file) == '.scss' }
8
+
9
+ files.map do |file|
10
+ Import.new File.expand_path(file)
11
+ end
12
+ else
13
+ Import.new path
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,44 @@
1
+ require 'forwardable'
2
+
3
+ module Sasstool
4
+ class Renderer
5
+ extend Forwardable
6
+ def_delegators :engine, :render, :source_map
7
+ attr_reader :path
8
+
9
+ def initialize(path)
10
+ @path = path
11
+ end
12
+
13
+ def save(target_dir)
14
+ name = "#{target_dir}/#{basename}"
15
+ File.write name, render
16
+ File.write "#{name}.map", source_map
17
+ end
18
+
19
+ private
20
+
21
+ def basename
22
+ @basename ||= File.basename(path).gsub(/scss$/, 'css')
23
+ end
24
+
25
+ def scss_content
26
+ scss_content ||= File.read(path)
27
+ end
28
+
29
+ def options
30
+ @options ||= {
31
+ source_map_file: "#{path.gsub(/scss$/, 'css')}.map",
32
+ source_map_contents: true,
33
+ style: :nested,
34
+ importer: Importer,
35
+ filename: path
36
+ }
37
+ end
38
+
39
+ def engine
40
+ @engine ||= SassC::Engine.new(scss_content, options)
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,3 @@
1
+ module Sasstool
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sasstool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Danny Ben Shitrit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mister_bin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colsole
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sassc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: filewatcher
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ description: Sass command line renderer with globbing import support
70
+ email: db@dannyben.com
71
+ executables:
72
+ - sasstool
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - README.md
77
+ - bin/sasstool
78
+ - lib/sasstool.rb
79
+ - lib/sasstool/cli.rb
80
+ - lib/sasstool/command.rb
81
+ - lib/sasstool/importer.rb
82
+ - lib/sasstool/renderer.rb
83
+ - lib/sasstool/version.rb
84
+ homepage: https://github.com/dannyben/sasstool
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.0
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.1.4
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Sass command line renderer
107
+ test_files: []