guard-mthaml 0.1.0 → 0.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: bebf45e1efab70a01cc599778fbe9ba24b0de22e
4
- data.tar.gz: 6e99eaac82f0d5f3b05edb178a9fc0c8e30bcce0
3
+ metadata.gz: df0b052496f3e578ccba291cf4e5b0ac2cfd8d51
4
+ data.tar.gz: ba8bb2ace11c0739b1523c45e24479e45f932943
5
5
  SHA512:
6
- metadata.gz: 333cb564784aa5ad1240b86042ce0a6c4b11873e7775eb35a6bd3cb248af5da2a9b536f1320cc20adad1d7ea8c3e2029a23be91041cc617de360e0df36d0b970
7
- data.tar.gz: 04d110e33c81739fb7bcb626ab0b7bf5dac26a9ebc3acea718cda594376d5965761c3352d1786938f9103f60f91a24e39295d6790bbcdfe5f9dd5fe494d5d324
6
+ metadata.gz: 0de163ca5c2da5af1d5d102449adefc8d836fd34822e26f83be32da028d4456afa61e0500cd32459c320264ddb471f8e5fc02966e476d994ca5cc4ba5ee93bf9
7
+ data.tar.gz: f97264ceeb7c54dbc43cd4e019773fd77cfd7c177a7d7e3895288e4af77c5c22f4f22fae6fd40a907ad6e7e264044bd4711b576db6745432f2eaaf2c33a45f69
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Guard::MtHaml
1
+ # Guard::MtHaml [![Gem Version](https://badge.fury.io/rb/guard-mthaml.svg)](http://badge.fury.io/rb/guard-mthaml)
2
2
  This is a Guard wrapper to compile Haml to PHP, Twig or static HTML.
3
3
 
4
4
  Add to your `Gemfile`:
@@ -17,6 +17,7 @@ $ guard init mthaml
17
17
  ```
18
18
 
19
19
  ## Usage
20
+ Requires that `php` be executable via command line.
20
21
 
21
22
  ```ruby
22
23
  ###
@@ -30,5 +31,5 @@ $ guard init mthaml
30
31
  # :static_files (false) compile haml to static html
31
32
  # :run_at_start (true) compile files when guard starts
32
33
  ###
33
- guard :haml, :input => "views/src", :output => "views"
34
+ guard :mthaml, :input => "views/src", :output => "views"
34
35
  ```
@@ -94,7 +94,7 @@ class MtHamlCompiler {
94
94
  if( isset( $opts['input'] ) ) {
95
95
  $this->input_file = $opts['input'];
96
96
  } else {
97
- throw new \Exception( "No input file was passed into \$opts." );
97
+ throw new \Exception( self::colorize( "No input file was passed into \$opts.", ";31" ) );
98
98
  }
99
99
 
100
100
  /**
@@ -103,7 +103,7 @@ class MtHamlCompiler {
103
103
  if( isset( $opts['output'] ) ) {
104
104
  $this->output_dir = $opts["output"];
105
105
  } else {
106
- throw new \Exception( "No output directory was passed into \$opts." );
106
+ throw new \Exception( self::colorize( "No output directory was passed into \$opts.", ";31" ) );
107
107
  }
108
108
 
109
109
  /**
@@ -112,7 +112,7 @@ class MtHamlCompiler {
112
112
  if( isset( $opts['options'] ) ) {
113
113
  $this->options = $opts['options'];
114
114
  } else {
115
- throw new \Exception( "No options were passed into \$opts." );
115
+ throw new \Exception( self::colorize( "No options were passed into \$opts.", ";31" ) );
116
116
  }
117
117
 
118
118
  /**
@@ -121,7 +121,7 @@ class MtHamlCompiler {
121
121
  if( isset( $this->options['environment'] ) ) {
122
122
  $this->environment = $this->options['environment'];
123
123
  } else {
124
- throw new \Exception( "No environment was passed into \$opts." );
124
+ throw new \Exception( self::colorize( "No environment was passed into \$opts.", ";31" ) );
125
125
  }
126
126
 
127
127
  // Set the MtHaml environment
@@ -173,7 +173,7 @@ class MtHamlCompiler {
173
173
  "cache" => $this->output_dir . '/cache',
174
174
  ));
175
175
  } else {
176
- throw new \Exception("To compile static files, please set your environment to PHP. It is currently set to `$this->environment`.");
176
+ throw new \Exception(self::colorize( "To compile static files, please set your environment to PHP. It is currently set to `$this->environment`.", ";31" ) );
177
177
  }
178
178
  // Compile assets
179
179
  return $this->executor->render( $this->input_file, array() );
@@ -209,7 +209,7 @@ class MtHamlCompiler {
209
209
  }
210
210
  // If dir is still not writable, throw err
211
211
  if ( ! is_writable( $dir ) ) {
212
- throw new \Exception("It looks like the directory `$dir` isn't writable.");
212
+ throw new \Exception( self::colorize( "It looks like the directory `$dir` isn't writable.", ";31" ) );
213
213
  }
214
214
  }
215
215
 
@@ -226,9 +226,21 @@ class MtHamlCompiler {
226
226
  // Render output
227
227
  return file_put_contents( "$this->output_dir/" . basename( $this->input_file, ".haml" ) . ".$extension", $this->output );
228
228
  } else {
229
- throw new \Exception( "It looks like `" . basename( $this->input_file ) . "` compiled without any output." );
229
+ throw new \Exception( self::colorize( "It looks like `" . basename( $this->input_file ) . "` compiled without any output.", ";33" ) );
230
230
  }
231
231
  }
232
+
233
+ /**
234
+ * Colorize output messages to terminal
235
+ *
236
+ * @param {String} $message
237
+ * @param {String} $color
238
+ *
239
+ * @since 0.2.0
240
+ */
241
+ private function colorize($message, $color) {
242
+ return "\e[0$color" . "m" . "$message\e[0m";
243
+ }
232
244
  }
233
245
 
234
246
  /**
@@ -1,5 +1,5 @@
1
1
  module ::Guard
2
2
  class MtHamlVersion
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-mthaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezekiel Gabrielse