staticz 1.1.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a14e547d746831e18d759c913c5d269066ffd391c3d36e1ba9a8c7eda6ac5a0
4
- data.tar.gz: cacec045c2bfec1e65c4317e81c969b43906893f10268c16aa600365def64373
3
+ metadata.gz: 9e7fe52aef9da5192c9275f8d0818854a9c73b42276befcfba73e039c7e14e1f
4
+ data.tar.gz: 3d28541b4452fcd45a88308c4b34651efe44352f856b78c264f16420e75ca66d
5
5
  SHA512:
6
- metadata.gz: b1d64e26c428f5ab6c3caa3f941e49f97d30e607dcc72d74ca32101aa8b940a14a8199b0267d7a148aae15af5d9369aabfe03d28734fe5a9e402c1bb52ef17cd
7
- data.tar.gz: 6d1431ec6816c6ba1b1af7bb9577a75471b8d4f4a7133fa88f19abfb259917936a23d8421b6421324aef6b741adbc07ffc72ce3ac0ea915e8f22fd2e89d97772
6
+ metadata.gz: d91007bf1075a01a630ec06c231b8f881f1f9081b550a2edd8ae20868f654d5697e1407027e64852c251270c9802cb8df53c9e9d7bf8f2a1b6776d562c5bc820
7
+ data.tar.gz: faf552e8eb42b8bf5dd593656a0f3aec0682480fee9c4152f2f5d7d8b5639a42edb56a0ea60d39dab93185187f7b1f5c2dc42cb54e26da072ad3fafdf20a6dae
@@ -1,4 +1,5 @@
1
1
  require "sass-embedded"
2
+ require "pastel"
2
3
  require_relative "../compilable"
3
4
 
4
5
  module Staticz
@@ -12,6 +13,7 @@ module Staticz
12
13
 
13
14
  def initialize(name)
14
15
  @name = name
16
+ @warnings = []
15
17
  end
16
18
 
17
19
  def build(listener_class: nil)
@@ -27,21 +29,54 @@ module Staticz
27
29
  end
28
30
 
29
31
  def render
30
- Sass.compile(source_path, style: :compressed).css
32
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
31
33
  end
32
34
 
33
35
  def errors
34
- errors = super
36
+ @_errors_cache ||= begin
37
+ errors = super
35
38
 
36
- if exists?
37
- begin
38
- Sass.compile(source_path, style: :compressed).css
39
- rescue => e
40
- errors << e.message
39
+ if exists?
40
+ begin
41
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
42
+ rescue => e
43
+ errors << e.message
44
+ end
41
45
  end
46
+
47
+ errors
48
+ end
49
+ end
50
+
51
+ def debug(message, options)
52
+ warn(message, debug)
53
+ end
54
+
55
+ def warn(message, options)
56
+ pastel = Pastel.new
57
+
58
+ line = options.span.start.line + 1
59
+ start_index = options.span.start.column
60
+ end_index = options.span.end.column
61
+
62
+ @warnings << <<~WARNING
63
+ #{pastel.yellow.bold("Warning")}: #{message}
64
+
65
+ #{" " * line.to_s.size} #{pastel.blue("╷")}
66
+ #{pastel.blue(line)} #{pastel.blue("│")} #{pastel.red(options.span.context.strip)}
67
+ #{" " * line.to_s.size} #{pastel.blue("│")} #{" " * start_index}#{pastel.red("^" * (end_index - start_index))}
68
+ #{" " * line.to_s.size} #{pastel.blue("╵")}
69
+
70
+ #{options.stack}
71
+ WARNING
72
+ end
73
+
74
+ def warnings
75
+ if valid?
76
+ Sass.compile(source_path, style: :compressed, logger: self)
42
77
  end
43
78
 
44
- errors
79
+ @warnings
45
80
  end
46
81
  end
47
82
  end
@@ -1,4 +1,5 @@
1
1
  require "sass-embedded"
2
+ require "pastel"
2
3
  require_relative "../compilable"
3
4
 
4
5
  module Staticz
@@ -12,6 +13,7 @@ module Staticz
12
13
 
13
14
  def initialize(name)
14
15
  @name = name
16
+ @warnings = []
15
17
  end
16
18
 
17
19
  def build(listener_class: nil)
@@ -27,21 +29,54 @@ module Staticz
27
29
  end
28
30
 
29
31
  def render
30
- Sass.compile(source_path, style: :compressed).css
32
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
31
33
  end
32
34
 
33
35
  def errors
34
- errors = super
36
+ @_errors_cache ||= begin
37
+ errors = super
35
38
 
36
- if exists?
37
- begin
38
- Sass.compile(source_path, style: :compressed).css
39
- rescue => e
40
- errors << e.message
39
+ if exists?
40
+ begin
41
+ Sass.compile(source_path, style: :compressed, logger: Sass::Logger.silent).css
42
+ rescue => e
43
+ errors << e.message
44
+ end
41
45
  end
46
+
47
+ errors
48
+ end
49
+ end
50
+
51
+ def debug(message, options)
52
+ warn(message, debug)
53
+ end
54
+
55
+ def warn(message, options)
56
+ pastel = Pastel.new
57
+
58
+ line = options.span.start.line + 1
59
+ start_index = options.span.start.column
60
+ end_index = options.span.end.column
61
+
62
+ @warnings << <<~WARNING
63
+ #{pastel.yellow.bold("Warning")}: #{message}
64
+
65
+ #{" " * line.to_s.size} #{pastel.blue("╷")}
66
+ #{pastel.blue(line)} #{pastel.blue("│")} #{pastel.red(options.span.context.strip)}
67
+ #{" " * line.to_s.size} #{pastel.blue("│")} #{" " * start_index}#{pastel.red("^" * (end_index - start_index))}
68
+ #{" " * line.to_s.size} #{pastel.blue("╵")}
69
+
70
+ #{options.stack}
71
+ WARNING
72
+ end
73
+
74
+ def warnings
75
+ if valid?
76
+ Sass.compile(source_path, style: :compressed, logger: self)
42
77
  end
43
78
 
44
- errors
79
+ @warnings
45
80
  end
46
81
  end
47
82
  end
@@ -46,6 +46,10 @@ module Staticz
46
46
  errors.empty?
47
47
  end
48
48
 
49
+ def warnings
50
+ []
51
+ end
52
+
49
53
  def errors
50
54
  errors = []
51
55
 
@@ -70,7 +74,11 @@ module Staticz
70
74
 
71
75
  def print(indentation, *args)
72
76
  valid_symbol = if valid?
73
- Colors.in_green("✔")
77
+ if warnings.any?
78
+ Colors.in_yellow("⚠")
79
+ else
80
+ Colors.in_green("✔")
81
+ end
74
82
  else
75
83
  Colors.in_red("✘")
76
84
  end
@@ -89,6 +97,12 @@ module Staticz
89
97
  puts "#{" " * (indentation * 3)} #{Colors.in_red(error)}"
90
98
  end
91
99
  end
100
+
101
+ warnings.each do |warning|
102
+ warning.lines.each do |line|
103
+ puts "#{" " * (indentation * 3)} #{line}"
104
+ end
105
+ end
92
106
  end
93
107
  end
94
108
  end
data/lib/server.rb CHANGED
@@ -91,8 +91,7 @@ module Staticz
91
91
  end
92
92
  .join(", ")
93
93
 
94
- $stdout.clear_screen
95
- puts "#{file_names} changed, rebuilding..."
94
+ puts "\n#{file_names} changed, rebuilding...\n\n"
96
95
  build_manifest
97
96
  puts "Rebuilding successful"
98
97
  end
data/lib/staticz.rb CHANGED
@@ -6,7 +6,7 @@ require_relative "commands/manifest_command"
6
6
  require_relative "commands/build_command"
7
7
 
8
8
  module Staticz
9
- VERSION = "1.1.0"
9
+ VERSION = "1.1.1"
10
10
 
11
11
  def self.init
12
12
  cmd, args = case ARGV[0]
@@ -48,5 +48,9 @@ module Staticz::Templates
48
48
  padding: 0
49
49
  margin: 0
50
50
  SASS
51
+
52
+ file ".gitignore", <<~GITIGNORE
53
+ build/
54
+ GITIGNORE
51
55
  end
52
56
  end
@@ -64,5 +64,9 @@ module Staticz::Templates
64
64
  padding: 0
65
65
  margin: 0
66
66
  SASS
67
+
68
+ file ".gitignore", <<~GITIGNORE
69
+ build/
70
+ GITIGNORE
67
71
  end
68
72
  end
data/lib/utils/colors.rb CHANGED
@@ -3,6 +3,10 @@ class Colors
3
3
  "\e[31m#{text}\e[0m"
4
4
  end
5
5
 
6
+ def self.in_yellow(text)
7
+ "\e[33m#{text}\e[0m"
8
+ end
9
+
6
10
  def self.in_green(text)
7
11
  "\e[32m#{text}\e[0m"
8
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schlesinger
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.9'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pastel
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.8.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.8.0
153
167
  description: Create websites with haml and sass, and compile them into static html
154
168
  and css
155
169
  email: