guard-mthaml 0.2.5 → 0.3.0

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
  SHA1:
3
- metadata.gz: 9f46bd6bec946973cd5ff97c13a434eff208358c
4
- data.tar.gz: 9c543e9541763958f01dd543d34746034eee4aa1
3
+ metadata.gz: 085ae92602c4830ad39e5985518ca897091166e4
4
+ data.tar.gz: 56b410d69ce89c6f65e9f59c93110d0e16ebe537
5
5
  SHA512:
6
- metadata.gz: 615f137255871de2cc5c584e77e90fbb6eb95541a12154a3d76df8126b622030369d018543477a6d4fff4dfe0d62b32f6097a3878ac29afb5f1a4e4729be7ed7
7
- data.tar.gz: 62f41d0aa92b9ac9018fdd202e50451b0ba7e9e1c462d3d9ea066d4d3877b711865855846d455826024e8014dd19e1729c650bf22fcdc0659907c31ab05645d1
6
+ metadata.gz: 2526368233ce1fdf50c9293808ec8522e175e3822fba8034b52c223ca55e1c7f4c5ff9b471540ca57d7cb8bf960cfc07b09855f8d372e6d457d4e28396363fdc
7
+ data.tar.gz: aa8da76a63075bcbfd5d0c94bb5b75471b8da8353354828022e3de5f720cb865fb195bc85279cc46cb5b6ff558f705d27759e45fc4f3a5e99c04e8905a5737bc
@@ -11,15 +11,21 @@ module Guard
11
11
  ###
12
12
  def initialize(options = {})
13
13
  options = {
14
- :input => "views/src",
15
- :output => "views",
16
- :environment => "php",
17
- :notifications => true,
18
- :compress_output => false,
19
- :static_files => false,
20
- :run_at_start => true
14
+ input: "views/src",
15
+ output: "views",
16
+ environment: "php",
17
+ extension: nil,
18
+ notifications: true,
19
+ compress_output: false,
20
+ static_files: false,
21
+ run_at_start: true
21
22
  }.merge(options)
22
23
 
24
+ # Define extension if environment is nil
25
+ if options[:extension].nil?
26
+ options[:extension] = if options[:static_files] then "html" else options[:environment] end
27
+ end
28
+
23
29
  super(options)
24
30
 
25
31
  if options[:input]
@@ -69,13 +75,23 @@ module Guard
69
75
  input_dir = Pathname.new(options[:input]).realpath
70
76
  input_file = file.realpath
71
77
 
72
- unless input_dir == file_dir
73
- output_dir = Pathname.new(options[:output]).realpath + file_dir.basename
74
- make_directory(output_dir)
75
- else
78
+ puts file, file_dir, input_dir, input_file
79
+
80
+ # Simple check to see if we need to create any directories in the output
81
+ if file_dir == input_dir
82
+ # File looks like it's in the base directory
76
83
  output_dir = Pathname.new(options[:output]).realpath
84
+ else
85
+ # Looks like we need to create a directory or two
86
+ output_dir = Pathname.new(options[:output]).realpath + file_dir.to_s.gsub(input_dir.to_s, "")[1..-1]
77
87
  end
78
88
 
89
+ puts output_dir
90
+
91
+ # Make directories if they don't already exist
92
+ make_directory(output_dir)
93
+
94
+ # Initiate compiler
79
95
  compile_haml(input_file, output_dir)
80
96
  end
81
97
  end
@@ -101,26 +117,21 @@ module Guard
101
117
  ###
102
118
  def compile_haml(input, output)
103
119
 
104
- ext = if options[:static_files]
105
- ".html"
106
- else
107
- ".#{options[:environment]}"
108
- end
109
-
110
120
  command = [
111
121
  "php #{File.dirname(__FILE__)}/mthaml/compiler/MtHaml.php",
112
122
  "--input #{input}",
113
123
  "--output #{output}",
114
124
  "--environment #{options[:environment]}",
125
+ "--extension #{options[:extension]}",
115
126
  "--static_files #{options[:static_files]}",
116
- "--compress_output #{options[:compress_output]}"
127
+ "--compress_output #{options[:compress_output]}",
117
128
  ].join " "
118
129
 
119
130
  begin
120
131
  throw :task_has_failed unless system command
121
- ::Guard::UI.info(color("write #{File.basename(input, ".*") + ext}", ";32")) if options[:notifications]
132
+ ::Guard::UI.info(color("write #{File.basename(input, ".*")}.#{options[:extension]}", ";32")) if options[:notifications]
122
133
  rescue StandardError => error
123
- ::Guard::UI.error(color("error #{File.basename(input, ".*") + ext} : #{error}", ";31")) if options[:notifications]
134
+ ::Guard::UI.error(color("error #{File.basename(input, ".*")}.#{options[:extension]} : #{error}", ";31")) if options[:notifications]
124
135
  end
125
136
  end
126
137
 
@@ -42,6 +42,14 @@ class MtHamlCompiler {
42
42
  */
43
43
  private $environment;
44
44
 
45
+ /**
46
+ * @var {String}
47
+ * Extension of output file
48
+ *
49
+ * @since 0.1.0
50
+ */
51
+ private $extension;
52
+
45
53
  /**
46
54
  * @var {Array}
47
55
  * Array of options to be passed to MtHaml
@@ -124,7 +132,7 @@ class MtHamlCompiler {
124
132
  }
125
133
 
126
134
  /**
127
- * Get the environment
135
+ * Set the environment
128
136
  */
129
137
  if( isset( $this->options['environment'] ) ) {
130
138
  $this->environment = $this->options['environment'];
@@ -132,6 +140,15 @@ class MtHamlCompiler {
132
140
  throw new \Exception( self::colorize( "No environment was passed into \$opts.", ";31" ) );
133
141
  }
134
142
 
143
+ /**
144
+ * Set the output extension
145
+ */
146
+ if( isset( $this->options['extension'] ) ) {
147
+ $this->extension = $this->options['extension'];
148
+ } else {
149
+ $this->extension = $this->environment;
150
+ }
151
+
135
152
  // Set the MtHaml environment
136
153
  self::set_environment();
137
154
  }
@@ -240,11 +257,10 @@ class MtHamlCompiler {
240
257
  */
241
258
  private function write() {
242
259
  if ( $this->output ) {
243
- $extension = $this->options["static_files"] ? "html" : $this->environment;
244
260
  // Make sure our path is writable
245
261
  self::ensure_path_writable( $this->output_dir );
246
262
  // Render output
247
- return file_put_contents( "$this->output_dir/" . basename( $this->input_file, ".haml" ) . ".$extension", $this->output );
263
+ return file_put_contents( "$this->output_dir/" . basename( $this->input_file, ".haml" ) . ".$this->extension", $this->output );
248
264
  } else {
249
265
  throw new \Exception( self::colorize( "It looks like `" . basename( $this->input_file ) . "` compiled without any output.", ";33" ) );
250
266
  }
@@ -254,7 +270,7 @@ class MtHamlCompiler {
254
270
  /**
255
271
  * Get passed arguments from Guard
256
272
  */
257
- $opts = getopt( "", array( "input:", "output:", "environment:", "static_files:", "compress_output:" ) );
273
+ $opts = getopt( "", array( "input:", "output:", "environment:", "static_files:", "compress_output:", "extension:" ) );
258
274
 
259
275
  /**
260
276
  * Instantiate compiler and parse file with input from Guard
@@ -265,6 +281,7 @@ try {
265
281
  "output" => $opts["output"],
266
282
  "options" => array(
267
283
  "environment" => $opts["environment"],
284
+ "extension" => $opts["extension"],
268
285
  "static_files" => $opts["static_files"] === "true" ? true : false,
269
286
  "compress_output" => $opts["compress_output"] === "true" ? true : false
270
287
  )
@@ -4,6 +4,7 @@
4
4
  # :input ("views/src") set input directory with haml files
5
5
  # :output ("views") set output directory for compiled files
6
6
  # :environment ("php") haml environment
7
+ # :extension (nil) output file extension, uses environment if nil
7
8
  # :notifications (true) toggle guard notifications
8
9
  # :compress_output (false) compress compiled haml files
9
10
  # :static_files (false) compile haml to static html
@@ -1,5 +1,5 @@
1
1
  module ::Guard
2
2
  class MtHamlVersion
3
- VERSION = "0.2.5"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -4,4 +4,4 @@
4
4
 
5
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
6
 
7
- return ComposerAutoloaderInit17e64cb9b57858533d303e3ace0ae982::getLoader();
7
+ return ComposerAutoloaderInit7c72a395feca2c9cf06b47db0e557a37::getLoader();
@@ -56,7 +56,11 @@ class ClassLoader
56
56
 
57
57
  public function getPrefixes()
58
58
  {
59
- return call_user_func_array('array_merge', $this->prefixesPsr0);
59
+ if (!empty($this->prefixesPsr0)) {
60
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
61
+ }
62
+
63
+ return array();
60
64
  }
61
65
 
62
66
  public function getPrefixesPsr4()
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit17e64cb9b57858533d303e3ace0ae982
5
+ class ComposerAutoloaderInit7c72a395feca2c9cf06b47db0e557a37
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit17e64cb9b57858533d303e3ace0ae982
19
19
  return self::$loader;
20
20
  }
21
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit17e64cb9b57858533d303e3ace0ae982', 'loadClassLoader'), true, true);
22
+ spl_autoload_register(array('ComposerAutoloaderInit7c72a395feca2c9cf06b47db0e557a37', 'loadClassLoader'), true, true);
23
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit17e64cb9b57858533d303e3ace0ae982', 'loadClassLoader'));
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit7c72a395feca2c9cf06b47db0e557a37', 'loadClassLoader'));
25
25
 
26
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit17e64cb9b57858533d303e3ace0ae982
44
44
  }
45
45
  }
46
46
 
47
- function composerRequire17e64cb9b57858533d303e3ace0ae982($file)
47
+ function composerRequire7c72a395feca2c9cf06b47db0e557a37($file)
48
48
  {
49
49
  require $file;
50
50
  }
@@ -1,69 +1,4 @@
1
1
  [
2
- {
3
- "name": "mthaml/mthaml",
4
- "version": "dev-master",
5
- "version_normalized": "9999999-dev",
6
- "source": {
7
- "type": "git",
8
- "url": "https://github.com/arnaud-lb/MtHaml.git",
9
- "reference": "86f094aa6e5036a349d59bb0c30c3088a3ee7b1b"
10
- },
11
- "dist": {
12
- "type": "zip",
13
- "url": "https://api.github.com/repos/arnaud-lb/MtHaml/zipball/86f094aa6e5036a349d59bb0c30c3088a3ee7b1b",
14
- "reference": "86f094aa6e5036a349d59bb0c30c3088a3ee7b1b",
15
- "shasum": ""
16
- },
17
- "require": {
18
- "php": ">=5.3.0"
19
- },
20
- "conflict": {
21
- "mthaml/mthaml-bundle": "<1.1.0"
22
- },
23
- "require-dev": {
24
- "coffeescript/coffeescript": "~1",
25
- "erusev/parsedown": "*",
26
- "leafo/lessphp": "*",
27
- "leafo/scssphp": "*",
28
- "michelf/php-markdown": "~1.3",
29
- "oyejorge/less.php": "*",
30
- "twig/twig": "~1.11"
31
- },
32
- "suggest": {
33
- "cebe/markdown": "If you want to use :markdown filter",
34
- "coffeescript/coffeescript": "If you want to use :coffee or :coffeescript filter",
35
- "erusev/parsedown": "If you want to use :markdown filter",
36
- "kzykhys/ciconia": "If you want to use :markdown filter",
37
- "leafo/lessphp": "If you want to use :less filter",
38
- "leafo/scssphp": "If you want to use :scss filter",
39
- "michelf/php-markdown": "If you want to use :markdown filter",
40
- "oyejorge/less.php": "If you want to use :less filter",
41
- "twig/twig": "If you want to use Twig templating engine"
42
- },
43
- "time": "2014-10-10 20:23:22",
44
- "type": "library",
45
- "installation-source": "source",
46
- "autoload": {
47
- "psr-0": {
48
- "MtHaml\\": "lib/"
49
- }
50
- },
51
- "notification-url": "https://packagist.org/downloads/",
52
- "license": [
53
- "MIT"
54
- ],
55
- "authors": [
56
- {
57
- "name": "Arnaud Le Blanc",
58
- "email": "arnaud.lb@gmail.com"
59
- }
60
- ],
61
- "description": "HAML for PHP",
62
- "homepage": "https://github.com/arnaud-lb/MtHaml",
63
- "keywords": [
64
- "HAML"
65
- ]
66
- },
67
2
  {
68
3
  "name": "coffeescript/coffeescript",
69
4
  "version": "1.3.1",
@@ -162,5 +97,70 @@
162
97
  "keywords": [
163
98
  "markdown"
164
99
  ]
100
+ },
101
+ {
102
+ "name": "mthaml/mthaml",
103
+ "version": "dev-master",
104
+ "version_normalized": "9999999-dev",
105
+ "source": {
106
+ "type": "git",
107
+ "url": "https://github.com/arnaud-lb/MtHaml.git",
108
+ "reference": "86f094aa6e5036a349d59bb0c30c3088a3ee7b1b"
109
+ },
110
+ "dist": {
111
+ "type": "zip",
112
+ "url": "https://api.github.com/repos/arnaud-lb/MtHaml/zipball/86f094aa6e5036a349d59bb0c30c3088a3ee7b1b",
113
+ "reference": "86f094aa6e5036a349d59bb0c30c3088a3ee7b1b",
114
+ "shasum": ""
115
+ },
116
+ "require": {
117
+ "php": ">=5.3.0"
118
+ },
119
+ "conflict": {
120
+ "mthaml/mthaml-bundle": "<1.1.0"
121
+ },
122
+ "require-dev": {
123
+ "coffeescript/coffeescript": "~1",
124
+ "erusev/parsedown": "*",
125
+ "leafo/lessphp": "*",
126
+ "leafo/scssphp": "*",
127
+ "michelf/php-markdown": "~1.3",
128
+ "oyejorge/less.php": "*",
129
+ "twig/twig": "~1.11"
130
+ },
131
+ "suggest": {
132
+ "cebe/markdown": "If you want to use :markdown filter",
133
+ "coffeescript/coffeescript": "If you want to use :coffee or :coffeescript filter",
134
+ "erusev/parsedown": "If you want to use :markdown filter",
135
+ "kzykhys/ciconia": "If you want to use :markdown filter",
136
+ "leafo/lessphp": "If you want to use :less filter",
137
+ "leafo/scssphp": "If you want to use :scss filter",
138
+ "michelf/php-markdown": "If you want to use :markdown filter",
139
+ "oyejorge/less.php": "If you want to use :less filter",
140
+ "twig/twig": "If you want to use Twig templating engine"
141
+ },
142
+ "time": "2014-10-10 20:23:22",
143
+ "type": "library",
144
+ "installation-source": "source",
145
+ "autoload": {
146
+ "psr-0": {
147
+ "MtHaml\\": "lib/"
148
+ }
149
+ },
150
+ "notification-url": "https://packagist.org/downloads/",
151
+ "license": [
152
+ "MIT"
153
+ ],
154
+ "authors": [
155
+ {
156
+ "name": "Arnaud Le Blanc",
157
+ "email": "arnaud.lb@gmail.com"
158
+ }
159
+ ],
160
+ "description": "HAML for PHP",
161
+ "homepage": "https://github.com/arnaud-lb/MtHaml",
162
+ "keywords": [
163
+ "HAML"
164
+ ]
165
165
  }
166
166
  ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-mthaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezekiel Gabrielse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: guard