mint 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +14 -31
  2. data/bin/mint +50 -34
  3. data/lib/mint/mint.rb +9 -5
  4. metadata +2 -2
data/README.md CHANGED
@@ -75,8 +75,8 @@ You can pass any of the following to a new document:
75
75
 
76
76
  1. If you specify a template name here, Mint will search its paths in order (see **The Mint Path** for more details) for a template with that name. A template file looks like the following:
77
77
 
78
- ${MINT_PATH}/templates/template_name/style.css
79
- ${MINT_PATH}/templates/template_name/layout.haml
78
+ ${MINT_PATH}/templates/template_name/style.css
79
+ ${MINT_PATH}/templates/template_name/layout.haml
80
80
 
81
81
  2. If you specify a template name that is also the name of an existing file in your working directory, Mint will use the file and not look for a template. (It is unlikely you'll have an extension-less file named 'normal' or 'default' in your working directory, so don't worry about this edge case.) If you do specify an existing file, the path/file will be resolved from the directory where you're calling Mint (the 'working directory'). To use Mint this way (and I don't see this as more than a temporary solution) you'll probably want to call Mint from within your source's directory. Alternatively, you can use [`Dir.chdir`][Dir::chdir method] for the same effect.
82
82
 
@@ -84,7 +84,7 @@ You can pass any of the following to a new document:
84
84
 
85
85
  Defaults:
86
86
 
87
- :destination => ''
87
+ :destination => nil
88
88
  :style_destination => nil
89
89
 
90
90
  Notes:
@@ -95,7 +95,7 @@ You can pass any of the following to a new document:
95
95
 
96
96
  ### Examples ###
97
97
 
98
- At this point, a couple of example may be useful.
98
+ At this point, a couple of examples may be useful.
99
99
 
100
100
  The following are possible:
101
101
 
@@ -227,14 +227,14 @@ When you name a layout or style with a string or symbol, Mint will first search
227
227
  The default Mint path (in order) is:
228
228
 
229
229
  - the current working directory
230
- - ${HOME}/.mint
231
- - /usr/share/mint (or whatever your system uses for system-wide configuration - Mint will make a smart guess)
230
+ - `${HOME}/.mint`
231
+ - `/usr/share/mint` (or whatever your system uses for system-wide configuration - Mint will make a smart guess)
232
232
  - the Mint gem directory (which holds the Mint-approved templates)
233
233
 
234
234
  Templates should be in a directory named templates. Inside this directory, there should be a subdirectory for each template:
235
235
 
236
- - ${MINT\_PATH}/templates/normal/style.css
237
- - ${MINT\_PATH}/templates/normal/layout.haml
236
+ - `${MINT_PATH}/templates/normal/style.sass`
237
+ - `${MINT_PATH}/templates/normal/layout.haml`
238
238
 
239
239
  Normally a style will go best with its layout complement. However, layouts and styles can be mixed and matched at your discretion. This is especially true where you are primarily customizing DOM elements with your stylesheet instead of targeting specific IDs or classes you're expecting to find. (In other words, this works best when your stylesheet focuses on modifying typography and not page layout.)
240
240
 
@@ -269,7 +269,6 @@ The following correspond to the parameters you can pass to `Mint::Document.new`,
269
269
  - `--style, -s`
270
270
  - `--destination, -d`
271
271
  - `--style-destination, -n`
272
- - `--copy-style`
273
272
 
274
273
  There are also scoping options, both for the `set` and `edit` commands:
275
274
 
@@ -300,16 +299,15 @@ Currently, the `mint` vocabulary consists of `set`, `edit`, and `config`.
300
299
 
301
300
  To set a local (directory-specific) configuration option, call `mint set`:
302
301
 
303
- mint set [local] --template serif-professional --destination final
302
+ mint set [--local] template=serif-professional
304
303
 
305
304
  This will create (or update) a config file: ./.mint/config.yml
306
305
 
307
306
  It will contain:
308
307
 
309
308
  template: serif-professional
310
- destination: final
311
309
 
312
- From now on, calling `mint` in this directory will automatically draw on these two options. (Commandline options will override these file options.)
310
+ From now on, calling `mint` in this directory will automatically draw on this option. (Commandline options will override any file-based options.)
313
311
 
314
312
  You can also set user-wide options:
315
313
 
@@ -328,8 +326,7 @@ Finally, you can set global options for all users:
328
326
  This configuration affects all users and will be put somewhere appropriate:
329
327
 
330
328
  - In Linux and on other FHS-compliant systems, this will be in /usr/share/mint
331
- - On Mac OS X, this is going to land somewhere unknown, possibly inside
332
- of /Library/Application Support/Mint or /usr/share/mint -- I haven't decided
329
+ - On Mac OS X, this is going to land somewhere yet to be determined, possibly inside of /Library/Application Support/Mint or /usr/share/mint -- I haven't decided
333
330
  - On Windows, this will end up *(somewhere dumber than before)*
334
331
 
335
332
  These options give you the power to unify a directory or user or all users under a certain default layout and style. These options are all overridden via commandline options and only provide defaults so that you can save typing common commands. `mint` selects the most specific option possible, starting with the commandline, then checking local the config file, and finally moving to the user-wide and global config files.
@@ -363,24 +360,10 @@ This section documents features that do not yet exist, but that I would like to
363
360
 
364
361
  ### Composed styles ###
365
362
 
366
- Not everyone wants to code an entire stylesheet every time he wants a new look. In fact, the most common use case for stylesheets is probably tweaking typography. For this reason (and to make this tool as accessible as possible), I want to implement a feature where you can select one stylesheet as a base and implement tweaks on top of that file. Of course Css makes this easy enough, but I want to implement this feature in such a way that it is easy and intuitive for everyone.
363
+ Not everyone wants to code an entire stylesheet every time he wants a new look. In fact, the most common use case for stylesheets is probably tweaking typography. For this reason (and to make this tool as accessible as possible), I want to implement a feature where you can select one stylesheet as a base and implement tweaks on top of that file, using a Yaml-based DSL. Of course Css makes this easy enough, but I want to implement this feature in such a way that it is easy and intuitive for everyone.
367
364
 
368
365
  ### Packages ###
369
366
 
370
- Sometimes, it may be useful to "finalize" the design of a document, for example, with publications. The best way I can think of to do this is to package the document's output file along with its style in a zipped package, which can be read by the following:
367
+ Sometimes, it may be useful to "finalize" the design of a document, for example, with publications. The best way I can think of to do this is to package the document's output file with its style inline. To do so, simply add the package option:
371
368
 
372
- mint open --package Minimalism --in firefox
373
-
374
- To package a document with its stylesheet, as a sort of a printing:
375
-
376
- mint package document.md --name Document
377
-
378
- Eventually, this could include multiple output formats, like Html4, Html5, Pdf and ePub. The format opened by the `mint open` command could be determined by the application you choose to open it with. (This would take some serious OS hacking, I think.)
379
-
380
- When that does happen, you'll also be able to set the default version of the document that will open using:
381
-
382
- mint set [local] --package-default html5
383
-
384
- ### More ###
385
-
386
- More ideas are coming soon...
369
+ mint package document.md
data/bin/mint CHANGED
@@ -2,37 +2,36 @@
2
2
  # A script for harnessing Mint at the commandline
3
3
 
4
4
  require 'pathname'
5
-
6
- $:.unshift Pathname.new(__FILE__).realpath.dirname + '..' + 'lib'
7
-
8
5
  require 'optparse'
9
6
  require 'yaml'
10
7
  require 'mint'
11
8
 
12
9
  module Mint
13
- # A map of all options that OptParse will accept from the commandline.
14
- # All other arguments are taken to be filenames.
15
- def self.options
16
- {
17
- # These options take parameters
18
- template: ['t', 'template', true, 'Specify the template (layout + style).'],
19
- layout: ['l', 'layout', true, 'Specify only the layout.'],
20
- style: ['s', 'style', true, 'Specify only the style.'],
21
- root: ['w', 'root', true, 'Specify a root outside the current directory.'],
22
- destination: ['d', 'destination', true, 'Specify a destination directory, relative to the root.'],
23
- style_destination: ['n', 'style-destination', true, 'Specify a destination directory for stylesheets, relative to the document destination directory. If not explicit, will be linked from original location.'],
24
-
25
- # These options do not take parameters
26
- global: ['G', 'global', false, 'Specify config changes on a global level.'],
27
- user: ['U', 'user', false, 'Specify config changes on a user-wide level.'],
28
- local: ['L', 'local', false, 'Specify config changes on a project-specific level.'],
29
- force: ['f', 'force', false, 'Force file overwrite without prompt.'],
30
- verbose: ['v', 'verbose', false, 'Verbose output.'],
31
- simulation: ['s', 'simulation', false, 'Simulate transformation without actually creating files.']
32
- }
33
- end
34
-
35
10
  module CommandLine
11
+ # A map of all options that OptParse will accept from the commandline.
12
+ # All other arguments are taken to be filenames.
13
+ def self.options
14
+ {
15
+ # These options take parameters
16
+ template: ['t', 'template', true, 'Specify the template (layout + style).'],
17
+ layout: ['l', 'layout', true, 'Specify only the layout.'],
18
+ style: ['s', 'style', true, 'Specify only the style.'],
19
+ root: ['w', 'root', true, 'Specify a root outside the current directory.'],
20
+ destination: ['d', 'destination', true,
21
+ 'Specify a destination directory, relative to the root.'],
22
+ style_destination: ['n', 'style-destination', true,
23
+ 'Specify a destination directory for stylesheets, or nil to link in place'],
24
+
25
+ # These options do not take parameters
26
+ global: ['G', 'global', false, 'Specify config changes on a global level.'],
27
+ user: ['U', 'user', false, 'Specify config changes on a user-wide level.'],
28
+ local: ['L', 'local', false, 'Specify config changes on a project-specific level.'],
29
+ force: ['f', 'force', false, 'Force file overwrite without prompt.'],
30
+ verbose: ['v', 'verbose', false, 'Verbose output.'],
31
+ simulation: ['s', 'simulation', false, 'Simulate transformation without actually creating files.']
32
+ }
33
+ end
34
+
36
35
  def self.config_options
37
36
  config_filename = Pathname.new(Mint.files[:config])
38
37
 
@@ -43,18 +42,18 @@ module Mint
43
42
  select(&:exist?).
44
43
  map {|p| YAML.load_file p }.
45
44
  reverse.
46
- reduce({}) {|r,p| r.merge p }
45
+ reduce(Hash.new) {|r,p| r.merge p }
47
46
  end
48
47
 
49
48
  def self.full_options_with(commandline_options)
50
49
  config_options.merge commandline_options
51
50
  end
52
51
 
53
- def self.write_config(opts, scope=:local)
54
- Helpers.ensure_directory Mint.path_for_scope(scope)
55
- Helpers.update_yaml(opts, Mint.path_for_scope(scope) + Mint.files[:config])
56
- end
57
-
52
+ # def self.install(file, scope=:local)
53
+ # directory = path_for_scope(scope)
54
+ # FileUtils.copy file, directory
55
+ # end
56
+
58
57
  def self.edit(name, layout_or_style=:layout)
59
58
  file = Mint.lookup_template name, layout_or_style
60
59
 
@@ -62,6 +61,12 @@ module Mint
62
61
  system "#{editor} #{file}"
63
62
  end
64
63
 
64
+ def self.write_config(opts, scope=:local)
65
+ config_directory = Mint.path_for_scope scope
66
+ Helpers.ensure_directory config_directory
67
+ Helpers.update_yaml(opts, config_directory + Mint.files[:config])
68
+ end
69
+
65
70
  def self.set(key, value, scope=:local)
66
71
  write_config({ key => value }, scope)
67
72
  end
@@ -77,7 +82,6 @@ module Mint
77
82
  # provides an easy way to stop Mint from rendering a style, even
78
83
  # if the document's style is not nil.
79
84
  def self.mint(files, commandline_options)
80
- puts "minting #{files}"
81
85
  documents = []
82
86
  options = Mint::CommandLine.full_options_with commandline_options
83
87
 
@@ -98,7 +102,7 @@ commandline_options = {}
98
102
  optparse = OptionParser.new do |opts|
99
103
  opts.banner = 'Usage: mint [command] files [options]'
100
104
 
101
- Mint.options.each do |k,v|
105
+ Mint::Commandline.options.each do |k,v|
102
106
  has_param = v[2]
103
107
 
104
108
  v[0] = "-#{v[0]}"
@@ -120,6 +124,19 @@ optparse.parse!
120
124
 
121
125
  case ARGV.first.downcase.to_sym
122
126
 
127
+ when :help
128
+ puts optparse.help
129
+
130
+ # ... if we get the install command, install the listed file to the
131
+ # scope listed, using local as the default scope
132
+ when :install
133
+ commandline_options[:local] = true
134
+ scope = [:global, :user, :local].
135
+ select {|e| commandline_options[e] }.
136
+ first
137
+
138
+ Mint::CommandLine.install ARGV.shift, scope
139
+
123
140
  # If we get the edit command, will retrieve appropriate file
124
141
  # (probably a Mint template) and shell out that file to
125
142
  # the user's favorite editor. Otherwise ...
@@ -159,6 +176,5 @@ else
159
176
  commandline_options.delete :verbose
160
177
  commandline_options.delete :simulation
161
178
 
162
- puts "ARGV = #{ARGV}"
163
179
  Mint::CommandLine.mint ARGV, commandline_options
164
180
  end
data/lib/mint/mint.rb CHANGED
@@ -4,8 +4,6 @@ require 'tilt'
4
4
  require 'helpers'
5
5
 
6
6
  module Mint
7
- VERSION = '0.1.3'
8
- MINT_DIR = Pathname.new(__FILE__).realpath.dirname + '..'
9
7
 
10
8
  # Assume that someone using an Html template has formatted it
11
9
  # in Erb and that a Css stylesheet will pass untouched through
@@ -13,18 +11,24 @@ module Mint
13
11
  Tilt.register 'html', Tilt::ERBTemplate
14
12
  Tilt.register 'css', Tilt::LessTemplate
15
13
 
14
+ def root
15
+ Pathname.new(__FILE__).realpath.dirname + '../..'
16
+ end
17
+
16
18
  # Return the an array with the Mint template path. Will first look
17
19
  # for MINT_PATH environment variable. Otherwise will use smart defaults.
18
- # Either way, earlier/higher paths take precedence.
20
+ # Either way, earlier/higher paths take precedence. And is considered to
21
+ # be the directory for "local" config options, templates, etc.
19
22
  def self.path
20
23
  mint_path = ENV['MINT_PATH'] || "#{Dir.getwd}/.mint:~/.mint:#{MINT_DIR}"
21
- path = mint_path.split(':').map {|p| Pathname.new(p).expand_path }
24
+ mint_path.split(':').map {|p| Pathname.new(p).expand_path }
22
25
  end
23
26
 
24
27
  # I want to refactor this so that Mint.path is always a Hash...
25
28
  # should take care of this in the Mint.path=() method.
26
29
  # Right now, this is a hack. It assumes a sane MINT_PATH, where the
27
- # first entry is most local and the last entry is most global.
30
+ # first entry is most local, the second is user-level,
31
+ # and the last entry is most global.
28
32
  def self.path_for_scope(scope=:local)
29
33
  case Mint.path
30
34
  when Array
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Jacobs