html_mockup 0.6.3 → 0.6.4

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.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ doc/*
2
+ pkg/*
data/CHANGELOG.md ADDED
@@ -0,0 +1,28 @@
1
+ # Changelog
2
+
3
+ ## Version 0.6.4
4
+ * Add RsyncFinalizer to automatically upload your mockup
5
+
6
+ ## Version 0.6.3
7
+ * Add license to gemspec
8
+ * Fix default_template in gem
9
+ * Add option to allow for resolving urls in custom attributes in the extractor (via `release.extract(options_hash)`)
10
+ * Add more unified interface to finalizers and processors
11
+ * Fix error if node can't be found in Processors::Requirejs
12
+
13
+ ## Version 0.6.2
14
+ * Improved cleaner with more robust tests
15
+
16
+ ## Version 0.6.1
17
+ * Correctly pass file and linenumber to Mockupfile evaluation
18
+ * Add the tilt gem as a requirement (needed for injectors in release)
19
+ * Make the cleaner also remove directories, also make it more safe (it will never delete stuff above the build_path)
20
+
21
+ ## Version 0.6.0
22
+ * Pass command line options to underlying objets
23
+ * Update docs
24
+ * The different Processors, injections and cleanups are run in order as specified. Finalizers will always be run last in their own order.
25
+ * Replace CLI "generate" command with "new" subcommand and add support for remote git skeletons based on Thor templating.
26
+ * Add most simple mockup directory as default_template
27
+ * Requirejs processor updated so it will search for a global r.js command, a local npm r.js command and a vendored r.js command
28
+ * Minor fixes and changes
data/MIT_LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Flurin Egger, DigitPaint (http://www.digitpaint.nl)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ task :test do
2
+ ruby "test/unit/release/processors/require_js_test.rb"
3
+ ruby "test/unit/release/cleaner_test.rb"
4
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "html_mockup"
5
+ s.version = "0.6.4"
6
+
7
+ s.authors = ["Flurin Egger", "Edwin van der Graaf"]
8
+ s.email = ["info@digitpaint.nl", "flurin@digitpaint.nl"]
9
+ s.homepage = "http://github.com/digitpaint/html_mockup"
10
+ s.summary = "HTML Mockup is a set of tools to create self-containing HTML mockups."
11
+ s.licenses = ["MIT"]
12
+
13
+ s.date = Time.now.strftime("%Y-%m-%d")
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.extra_rdoc_files = [
21
+ "README.rdoc"
22
+ ]
23
+
24
+ s.rdoc_options = ["--charset=UTF-8"]
25
+
26
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
27
+
28
+ s.add_dependency("thor", ["~> 0.16.0"])
29
+ s.add_dependency("rack", [">= 1.0.0"])
30
+ s.add_dependency("tilt", [">= 0"])
31
+ end
@@ -1,10 +1,11 @@
1
1
  require 'fileutils'
2
2
 
3
- # Finalizes the release into a directory in target_path
4
- #
5
- # The directory name will have the format PREFIX-VERSION
6
- #
7
3
  module HtmlMockup::Release::Finalizers
4
+
5
+ # Finalizes the release into a directory in target_path
6
+ #
7
+ # The directory name will have the format PREFIX-VERSION
8
+ #
8
9
  class Dir < Base
9
10
  # @option options :prefix Prefix to put before the version (default = "html")
10
11
  def call(release, options = {})
@@ -0,0 +1,70 @@
1
+ require 'shellwords'
2
+
3
+ module HtmlMockup::Release::Finalizers
4
+
5
+ # Finalizes the release by uploading your mockup with rsync to a remote server
6
+ #
7
+ # @see RsyncFinalizer#initialize for options
8
+ #
9
+ class Rsync < Base
10
+
11
+ # @param Hash options The options
12
+ #
13
+ # @option options String :rsync The Rsync command to run (default is "rsync")
14
+ # @option options String :remote_path The remote path to upload to
15
+ # @option options String :host The remote host to upload to
16
+ # @option options String :username The remote username to upload to
17
+ def initialize(options = {})
18
+ @options = {
19
+ :rsync => "rsync",
20
+ :remote_path => "",
21
+ :host => "",
22
+ :username => ""
23
+ }.update(options)
24
+ end
25
+
26
+ def call(release, options = {})
27
+ options = @options.dup.update(options)
28
+
29
+ # Validate options
30
+ validate_options!(release, options)
31
+
32
+ begin
33
+ `#{@options[:rsync]} --version`
34
+ rescue Errno::ENOENT
35
+ raise RuntimeError, "Could not find rsync in #{@options[:rsync].inspect}"
36
+ end
37
+
38
+
39
+ local_path = release.build_path.to_s
40
+ remote_path = options[:remote_path]
41
+
42
+ local_path += "/" unless local_path =~ /\/\Z/
43
+ remote_path += "/" unless remote_path =~ /\/\Z/
44
+
45
+ release.log(self, "Starting upload of #{(release.build_path + "*")} to #{options[:host]}")
46
+
47
+ command = "#{options[:rsync]} -az #{Shellwords.escape(local_path)} #{Shellwords.escape(options[:username])}@#{Shellwords.escape(options[:host])}:#{Shellwords.escape(remote_path)}"
48
+
49
+ # Run r.js optimizer
50
+ output = `#{command}`
51
+
52
+ # Check if r.js succeeded
53
+ unless $?.success?
54
+ raise RuntimeError, "Rsync failed.\noutput:\n #{output}"
55
+ end
56
+
57
+ end
58
+
59
+ protected
60
+
61
+ def validate_options!(release, options)
62
+ must_have_keys = [:remote_path, :host, :username]
63
+ if (options.keys & must_have_keys).size != must_have_keys.size
64
+ release.log(self, "You must specify these options: #{(must_have_keys - options.keys).inspect}")
65
+ raise "Missing keys: #{(must_have_keys - options.keys).inspect}"
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,85 @@
1
+ # Example idea for a Mockupfile, a lot of this has to have a sensible default.
2
+
3
+ Sass::Plugin.options[:style] = :expanded
4
+ Sass::Plugin.options[:template_location] = "./html/stylesheets"
5
+ Sass::Plugin.options[:css_location] = "./html/stylesheets"
6
+
7
+ # These are defaults, but can be set here
8
+ # mockup.project.html_path = mockup.project.path + "html"
9
+ # mockup.project.partial_path = mockup.project.path + "partials"
10
+
11
+ mockup.serve(config) do |server|
12
+ server.use :sass
13
+ end
14
+
15
+ mockup.release(config) do |release|
16
+
17
+ release.target_path # The target path where releases are put
18
+ release.build_path # The path where the release gets built
19
+ release.source_path # The source for this mockup
20
+
21
+ # Extract mockup
22
+ # Pass custom config to the extractor, this is optional
23
+ # release.extract :url_attributes => %w{src href action data-main}
24
+
25
+ # Get git version
26
+ release.scm.previous # Get the previous version SCM op (looks for tags)
27
+ release.scm.version # Get the git version
28
+ release.scm.date # Get the git date
29
+
30
+ # Create custom banner
31
+ release.banner do
32
+ "bla bla bla"
33
+ end
34
+
35
+ # The default banner looks like this:
36
+ #
37
+ # =======================
38
+ # = Version : v1.0.0 =
39
+ # = Date : 2012-06-20 =
40
+ # =======================
41
+
42
+ # Sassify CSS (this are the defaults too), all options except form :match and :skip are passed to Sass.compile_file
43
+ # release.use :sass, :match => ["stylesheets/**/*.scss"], :skip => [/_.*\.scss\Z/], :style => :expanded
44
+ # The previous statement is the same as:
45
+ release.use :sass
46
+
47
+ # Run requirejs optimizer
48
+ # release.use :requirejs, {
49
+ # :build_files => {"javascripts/site.build.js" => "javascripts"},
50
+ # :rjs => release.source_path + "../vendor/requirejs/r.js",
51
+ # :node => "node"
52
+ # }
53
+ release.use :requirejs
54
+
55
+ # Minify, will not minify anything above the :delimiter
56
+ # release.use :yuicompressor, {
57
+ # :match => ["**/*.{css,js}"],
58
+ # :skip => [/javascripts\/vendor\/.*\.js\Z/, /_doc\/.*/],
59
+ # :delimiter => Regexp.escape("/* -------------------------------------------------------------------------------- */")
60
+ # }
61
+ # The previous statement is the same as:
62
+ release.use :yuicompressor
63
+
64
+
65
+ # Inject VERSION / DATE (i.e. in TOC)
66
+ r.inject({"[VERSION]" => release.scm.version, "[DATE]" => release.scm.date.strftime("%Y-%m-%d")}, :into => %w{_doc/toc.html})
67
+
68
+ # Inject Banners on everything matching the regexp in all .css files
69
+ # The banner will be commented as CSS.
70
+ release.inject({ /\/\*\s*\[BANNER\]\s*\*\// => r.banner(:comment => :css)}, :into => %w{**/*.css})
71
+
72
+ # Inject CHANGELOG
73
+ release.inject({"[CHANGELOG]" => {:file => "../CHANGELOG", :processor => 'md'}}, :into => %w{_doc/changelog.html})
74
+
75
+ # Inject NOTES
76
+ release.inject({"[NOTES]" => {:file => "../NOTES.md", :processor => 'md'}}, :into => %w{_doc/notes.html})
77
+
78
+ # Cleanup on the build
79
+ release.cleanup "**/.DS_Store"
80
+
81
+ # Finalize the release
82
+ # This is the default finalizer so not required
83
+ # release.finalize :dir
84
+
85
+ end
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This testfile is just a small testcase on how
4
+ # to do something with nested generators. It's
5
+ # just some basics and needs to be explored further.
6
+
7
+ # What we need for/from a generator:
8
+ # - It needs to be registered in our Generators::Generate class
9
+ # - It needs to be automatically loaded from:
10
+ # - The mockup: <root>/generators/<name>/<name>_generator.rb
11
+ # - The gem
12
+ # - Other gems which have been manually required (?)
13
+ # - It needs to have access to the current Mockup::Project instance
14
+ # - It needs to have the following file structure:
15
+ # - <name>
16
+ # - <name>_generator.rb
17
+ # - ...support files...
18
+
19
+ require 'rubygems'
20
+ require 'thor'
21
+ require 'thor/group'
22
+
23
+
24
+ module Generators
25
+ class Generate < Thor
26
+ end
27
+
28
+ class GeneratorBase < Thor::Group
29
+ def self.inherited(sub)
30
+ name = sub.to_s.sub(/Generator$/, "").sub(/^Generators::/,"").downcase
31
+ Generate.register sub, name, name, "Run #{name}"
32
+ end
33
+ end
34
+
35
+ class ThingGenerator < GeneratorBase
36
+ def done
37
+ puts "Yep, done the thing"
38
+ end
39
+ end
40
+
41
+ class BlingGenerator < GeneratorBase
42
+ def done
43
+ puts "Here is some bling!"
44
+ end
45
+ end
46
+ end
47
+
48
+ module CLI
49
+ class Base < Thor
50
+ register Generators::Generate, "generate", "generate [COMMAND]", "Run a generator"
51
+ end
52
+ end
53
+
54
+ CLI::Base.start
@@ -0,0 +1,42 @@
1
+ require "./lib/html_mockup/release.rb"
2
+ require "./lib/html_mockup/release/cleaner.rb"
3
+ require "test/unit"
4
+
5
+ class CleanerTest < Test::Unit::TestCase
6
+
7
+ def test_only_clean_inside_build_path_relative
8
+ path = "processors"
9
+ cleaner = HtmlMockup::Release::Cleaner.new(path)
10
+ inside_build_path = cleaner.send :is_inside_build_path, File.dirname(__FILE__), path
11
+
12
+ assert(inside_build_path, "Only delete content inside build_path")
13
+ end
14
+
15
+ def test_only_clean_inside_build_path_absolute
16
+ path = Pathname.new(File.dirname(__FILE__) + "/processors").realpath.to_s
17
+ cleaner = HtmlMockup::Release::Cleaner.new(path)
18
+ inside_build_path = cleaner.send :is_inside_build_path, File.dirname(__FILE__), path
19
+
20
+ assert(inside_build_path, "Only delete content inside build_path")
21
+ end
22
+
23
+
24
+ def test_dont_clean_outside_build_path
25
+ path = "../../../lib"
26
+ cleaner = HtmlMockup::Release::Cleaner.new(path)
27
+
28
+ assert_raise RuntimeError do
29
+ inside_build_path = cleaner.send :is_inside_build_path, File.dirname(__FILE__), path
30
+ end
31
+
32
+ end
33
+
34
+ def test_dont_fail_on_nonexistent_files
35
+ path = "bla"
36
+ cleaner = HtmlMockup::Release::Cleaner.new(path)
37
+
38
+ assert !cleaner.send(:is_inside_build_path, File.dirname(__FILE__), path), "Failed on nonexistent directories/files"
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,62 @@
1
+ require "./lib/html_mockup/release.rb"
2
+ require "./lib/html_mockup/release/processors/requirejs"
3
+ require "test/unit"
4
+
5
+ class RequireJsTest < Test::Unit::TestCase
6
+
7
+ def test_require_js_default_fallback
8
+ # When the user points the requirejs processer to a wrong file
9
+ # it should throw an RunTimeError
10
+ options = {:rjs => "s.js"}
11
+ requirejs_processor = HtmlMockup::Release::Processors::Requirejs.new(options)
12
+ rjs = options[:rjs]
13
+
14
+ rjs_command = ''
15
+
16
+ assert_raise RuntimeError do
17
+ # The file does is there - it's this one, so it should raise
18
+ rjs_command = requirejs_processor.rjs_check
19
+ end
20
+
21
+ # No command string is returned
22
+ assert_equal rjs_command, ""
23
+
24
+ end
25
+
26
+ def test_require_js_bin
27
+ # When no default require.js path is given we expect it to be r.js availble in $PATH
28
+ requirejs_processor = HtmlMockup::Release::Processors::Requirejs.new
29
+ rjs = "r.js" # Default r.js by npm
30
+
31
+ begin
32
+ `#{rjs} -v`
33
+ rescue Errno::ENOENT
34
+ assert_raise RuntimeError do
35
+ requirejs_processor.rjs_check
36
+ end
37
+ else
38
+ assert_equal requirejs_processor.rjs_check, rjs
39
+ end
40
+
41
+ end
42
+
43
+ def test_require_js_lib
44
+ # Just point options[:rjs] to a file to look if its there,
45
+ # the user is expected to point to a correct r.js file if he
46
+ # doesn't want to use the r.js shipped with npm
47
+ options = {:rjs => __FILE__}
48
+ requirejs_processor = HtmlMockup::Release::Processors::Requirejs.new(options)
49
+ rjs = options[:rjs]
50
+
51
+ rjs_command = ''
52
+
53
+ assert_nothing_raised RuntimeError do
54
+ # The file is there - it's this one in fact, so it shouldn't raise
55
+ rjs_command = requirejs_processor.rjs_check
56
+ end
57
+
58
+ assert_equal rjs_command, "node #{rjs}"
59
+
60
+ end
61
+
62
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_mockup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-23 00:00:00.000000000 Z
13
+ date: 2012-11-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
17
- requirement: &70100536874920 !ruby/object:Gem::Requirement
17
+ requirement: &70163962703500 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.16.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70100536874920
25
+ version_requirements: *70163962703500
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rack
28
- requirement: &70100536873660 !ruby/object:Gem::Requirement
28
+ requirement: &70163962703020 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70100536873660
36
+ version_requirements: *70163962703020
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: tilt
39
- requirement: &70100536872460 !ruby/object:Gem::Requirement
39
+ requirement: &70163962702540 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,15 +44,22 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70100536872460
47
+ version_requirements: *70163962702540
48
48
  description:
49
- email: flurin@digitpaint.nl
49
+ email:
50
+ - info@digitpaint.nl
51
+ - flurin@digitpaint.nl
50
52
  executables:
51
53
  - mockup
52
54
  extensions: []
53
55
  extra_rdoc_files:
54
56
  - README.rdoc
55
57
  files:
58
+ - .gitignore
59
+ - CHANGELOG.md
60
+ - MIT_LICENSE
61
+ - README.rdoc
62
+ - Rakefile
56
63
  - bin/mockup
57
64
  - examples/default_template/.gitignore
58
65
  - examples/default_template/CHANGELOG
@@ -60,6 +67,7 @@ files:
60
67
  - examples/default_template/Mockupfile
61
68
  - examples/default_template/html/.empty_directory
62
69
  - examples/default_template/partials/.empty_directory
70
+ - html_mockup.gemspec
63
71
  - lib/html_mockup/cli.rb
64
72
  - lib/html_mockup/extractor.rb
65
73
  - lib/html_mockup/generators.rb
@@ -73,6 +81,7 @@ files:
73
81
  - lib/html_mockup/release/cleaner.rb
74
82
  - lib/html_mockup/release/finalizers.rb
75
83
  - lib/html_mockup/release/finalizers/dir.rb
84
+ - lib/html_mockup/release/finalizers/rsync.rb
76
85
  - lib/html_mockup/release/finalizers/zip.rb
77
86
  - lib/html_mockup/release/injector.rb
78
87
  - lib/html_mockup/release/processors.rb
@@ -84,7 +93,10 @@ files:
84
93
  - lib/html_mockup/server.rb
85
94
  - lib/html_mockup/template.rb
86
95
  - lib/html_mockup/w3c_validator.rb
87
- - README.rdoc
96
+ - test/Mockupfile-syntax.rb
97
+ - test/generator-subcommand.rb
98
+ - test/unit/release/cleaner_test.rb
99
+ - test/unit/release/processors/require_js_test.rb
88
100
  homepage: http://github.com/digitpaint/html_mockup
89
101
  licenses:
90
102
  - MIT
@@ -111,4 +123,8 @@ rubygems_version: 1.8.15
111
123
  signing_key:
112
124
  specification_version: 3
113
125
  summary: HTML Mockup is a set of tools to create self-containing HTML mockups.
114
- test_files: []
126
+ test_files:
127
+ - test/Mockupfile-syntax.rb
128
+ - test/generator-subcommand.rb
129
+ - test/unit/release/cleaner_test.rb
130
+ - test/unit/release/processors/require_js_test.rb