charleston 0.1.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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +66 -0
- data/VERSION +1 -0
- data/bin/charleston +12 -0
- data/charleston.gemspec +93 -0
- data/lib/charleston/checks.rb +17 -0
- data/lib/charleston/generator.rb +14 -0
- data/lib/charleston/tasks/css.rake +9 -0
- data/lib/charleston/tasks/directories.rake +8 -0
- data/lib/charleston/tasks/html.rake +9 -0
- data/lib/charleston/tasks/image.rake +12 -0
- data/lib/charleston/tasks/js.rake +9 -0
- data/lib/charleston/tasks.rb +8 -0
- data/lib/charleston/template/Rakefile +5 -0
- data/lib/charleston/template/javascripts/example.coffee +3 -0
- data/lib/charleston/template/pages/index.haml +84 -0
- data/lib/charleston/template/stylesheets/screen.sass +50 -0
- data/lib/charleston/transform.rb +51 -0
- data/lib/charleston.rb +10 -0
- data/test/fixture/pages/about.haml +0 -0
- data/test/fixture/pages/contact.html +0 -0
- data/test/fixture/pages/dev.html +0 -0
- data/test/fixture/pages/index.haml +0 -0
- data/test/helper.rb +14 -0
- data/test/test_charleston.rb +38 -0
- data/test/test_checks.rb +26 -0
- data/test/test_transform.rb +57 -0
- metadata +189 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Bryce Kerley
|
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/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= charleston
|
2
|
+
|
3
|
+
static HTML generator with HAML, SASS, and CoffeeScript
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Bryce Kerley. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "charleston"
|
8
|
+
gem.summary = %Q{Static HTML site framework}
|
9
|
+
gem.description = <<-EOD.lines.map{|l|l.strip}.join(' ')
|
10
|
+
Charleston is a framework to build static HTML/CSS/JavaScript sites with
|
11
|
+
any combination of HTML, HAML, CSS, SASS, JavaScript, and CoffeeScript,
|
12
|
+
that's easy to put together and maintain.
|
13
|
+
EOD
|
14
|
+
gem.email = "bkerley@brycekerley.net"
|
15
|
+
gem.homepage = "http://github.com/bkerley/charleston"
|
16
|
+
gem.authors = ["Bryce Kerley"]
|
17
|
+
gem.executables = %w{ charleston }
|
18
|
+
|
19
|
+
gem.add_runtime_dependency "rake", "~> 0.8"
|
20
|
+
gem.add_runtime_dependency 'haml', '~> 3.0'
|
21
|
+
# uncomment this for sass 3.1 when it comes out
|
22
|
+
# gem.add_runtime_dependency 'sass', '~> 3.1'
|
23
|
+
|
24
|
+
gem.add_development_dependency "shoulda", "~> 2.11"
|
25
|
+
gem.add_development_dependency "yard", "~> 0.6"
|
26
|
+
gem.add_development_dependency "mocha", "~> 0.9"
|
27
|
+
gem.add_development_dependency "fakefs", "~> 0.2"
|
28
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
29
|
+
end
|
30
|
+
Jeweler::GemcutterTasks.new
|
31
|
+
rescue LoadError
|
32
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rake/testtask'
|
36
|
+
Rake::TestTask.new(:test) do |test|
|
37
|
+
test.libs << 'lib' << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
require 'rcov/rcovtask'
|
44
|
+
Rcov::RcovTask.new do |test|
|
45
|
+
test.libs << 'test'
|
46
|
+
test.pattern = 'test/**/test_*.rb'
|
47
|
+
test.verbose = true
|
48
|
+
end
|
49
|
+
rescue LoadError
|
50
|
+
task :rcov do
|
51
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
task :test => :check_dependencies
|
56
|
+
|
57
|
+
task :default => :test
|
58
|
+
|
59
|
+
begin
|
60
|
+
require 'yard'
|
61
|
+
YARD::Rake::YardocTask.new
|
62
|
+
rescue LoadError
|
63
|
+
task :yardoc do
|
64
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
65
|
+
end
|
66
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/charleston
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
first_arg = ARGV.first
|
4
|
+
|
5
|
+
if first_arg == "--help"
|
6
|
+
$stderr.puts "Usage: charleston project_name"
|
7
|
+
$stderr.puts
|
8
|
+
$stderr.puts "Creates a project called project_name in the project_name directory."
|
9
|
+
else
|
10
|
+
require File.join(File.dirname(__FILE__), %w{ .. lib charleston})
|
11
|
+
Charleston.create_project first_arg
|
12
|
+
end
|
data/charleston.gemspec
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{charleston}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Bryce Kerley"]
|
12
|
+
s.date = %q{2010-10-11}
|
13
|
+
s.default_executable = %q{charleston}
|
14
|
+
s.description = %q{Charleston is a framework to build static HTML/CSS/JavaScript sites with any combination of HTML, HAML, CSS, SASS, JavaScript, and CoffeeScript, that's easy to put together and maintain.}
|
15
|
+
s.email = %q{bkerley@brycekerley.net}
|
16
|
+
s.executables = ["charleston"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/charleston",
|
29
|
+
"charleston.gemspec",
|
30
|
+
"lib/charleston.rb",
|
31
|
+
"lib/charleston/checks.rb",
|
32
|
+
"lib/charleston/generator.rb",
|
33
|
+
"lib/charleston/tasks.rb",
|
34
|
+
"lib/charleston/tasks/css.rake",
|
35
|
+
"lib/charleston/tasks/directories.rake",
|
36
|
+
"lib/charleston/tasks/html.rake",
|
37
|
+
"lib/charleston/tasks/image.rake",
|
38
|
+
"lib/charleston/tasks/js.rake",
|
39
|
+
"lib/charleston/template/Rakefile",
|
40
|
+
"lib/charleston/template/javascripts/example.coffee",
|
41
|
+
"lib/charleston/template/pages/index.haml",
|
42
|
+
"lib/charleston/template/stylesheets/screen.sass",
|
43
|
+
"lib/charleston/transform.rb",
|
44
|
+
"test/fixture/pages/about.haml",
|
45
|
+
"test/fixture/pages/contact.html",
|
46
|
+
"test/fixture/pages/dev.html",
|
47
|
+
"test/fixture/pages/index.haml",
|
48
|
+
"test/helper.rb",
|
49
|
+
"test/test_charleston.rb",
|
50
|
+
"test/test_checks.rb",
|
51
|
+
"test/test_transform.rb"
|
52
|
+
]
|
53
|
+
s.homepage = %q{http://github.com/bkerley/charleston}
|
54
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
55
|
+
s.require_paths = ["lib"]
|
56
|
+
s.rubygems_version = %q{1.3.7}
|
57
|
+
s.summary = %q{Static HTML site framework}
|
58
|
+
s.test_files = [
|
59
|
+
"test/helper.rb",
|
60
|
+
"test/test_charleston.rb",
|
61
|
+
"test/test_checks.rb",
|
62
|
+
"test/test_transform.rb"
|
63
|
+
]
|
64
|
+
|
65
|
+
if s.respond_to? :specification_version then
|
66
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
67
|
+
s.specification_version = 3
|
68
|
+
|
69
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
70
|
+
s.add_runtime_dependency(%q<rake>, ["~> 0.8"])
|
71
|
+
s.add_runtime_dependency(%q<haml>, ["~> 3.0"])
|
72
|
+
s.add_development_dependency(%q<shoulda>, ["~> 2.11"])
|
73
|
+
s.add_development_dependency(%q<yard>, ["~> 0.6"])
|
74
|
+
s.add_development_dependency(%q<mocha>, ["~> 0.9"])
|
75
|
+
s.add_development_dependency(%q<fakefs>, ["~> 0.2"])
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<rake>, ["~> 0.8"])
|
78
|
+
s.add_dependency(%q<haml>, ["~> 3.0"])
|
79
|
+
s.add_dependency(%q<shoulda>, ["~> 2.11"])
|
80
|
+
s.add_dependency(%q<yard>, ["~> 0.6"])
|
81
|
+
s.add_dependency(%q<mocha>, ["~> 0.9"])
|
82
|
+
s.add_dependency(%q<fakefs>, ["~> 0.2"])
|
83
|
+
end
|
84
|
+
else
|
85
|
+
s.add_dependency(%q<rake>, ["~> 0.8"])
|
86
|
+
s.add_dependency(%q<haml>, ["~> 3.0"])
|
87
|
+
s.add_dependency(%q<shoulda>, ["~> 2.11"])
|
88
|
+
s.add_dependency(%q<yard>, ["~> 0.6"])
|
89
|
+
s.add_dependency(%q<mocha>, ["~> 0.9"])
|
90
|
+
s.add_dependency(%q<fakefs>, ["~> 0.2"])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Charleston
|
2
|
+
module Checks
|
3
|
+
def self.haml_available?
|
4
|
+
available? 'haml'
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.available?(executable)
|
8
|
+
path_entries.detect do |e|
|
9
|
+
FileTest.executable? File.join(e, 'haml')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.path_entries
|
14
|
+
ENV['PATH'].split(':')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Charleston
|
2
|
+
class Generator
|
3
|
+
def initialize(directory_name)
|
4
|
+
@target_directory = directory_name
|
5
|
+
|
6
|
+
enumerate_and_populate_directory
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def enumerate_and_populate_directory
|
11
|
+
FileUtils::cp_r File.join(File.dirname(__FILE__), 'template'), @target_directory
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
@css_transform = Charleston::Transform.new 'stylesheets', '*.css', 'stylesheets', '*.css' do |input, output|
|
2
|
+
FileUtils.cp input, output
|
3
|
+
end
|
4
|
+
@css_transform.generates 'css'
|
5
|
+
|
6
|
+
@sass_transform = Charleston::Transform.new 'stylesheets', '*.sass', 'stylesheets', '*.css' do |input, output|
|
7
|
+
sh 'sass', input, output
|
8
|
+
end
|
9
|
+
@sass_transform.generates 'sass'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
@html_transform = Charleston::Transform.new 'pages', '*.html', '', '*.html' do |input, output|
|
2
|
+
FileUtils.cp input, output
|
3
|
+
end
|
4
|
+
@html_transform.generates 'html'
|
5
|
+
|
6
|
+
@haml_transform = Charleston::Transform.new 'pages', '*.haml', '', '*.html' do |input, output|
|
7
|
+
sh 'haml', input, output
|
8
|
+
end
|
9
|
+
@haml_transform.generates 'haml'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
@images = Rake::FileList['images/*']
|
2
|
+
@image_output = @images.map{ |i| "output/#{i}" }
|
3
|
+
|
4
|
+
@images.zip(@image_output) do |a|
|
5
|
+
input, output = a
|
6
|
+
file output => [input, 'output/images'] do
|
7
|
+
cp input, output
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Copy over images'
|
12
|
+
task 'generate:images' => %w{ output/images } + @image_output
|
@@ -0,0 +1,9 @@
|
|
1
|
+
@js_transform = Charleston::Transform.new 'javascripts', '*.js', 'javascripts', '*.js' do |input, output|
|
2
|
+
FileUtils.cp input, output
|
3
|
+
end
|
4
|
+
@js_transform.generates 'javascript'
|
5
|
+
|
6
|
+
@cs_transform = Charleston::Transform.new 'javascripts', '*.coffee', 'javascripts', '*.js' do |input, output|
|
7
|
+
sh "coffee -cp #{input} > #{output}"
|
8
|
+
end
|
9
|
+
@cs_transform.generates 'coffeescript'
|
@@ -0,0 +1,84 @@
|
|
1
|
+
!!! 5
|
2
|
+
%head
|
3
|
+
%title Welcome to Charleston
|
4
|
+
%link(rel='stylesheet' type='text/css' href='stylesheets/screen.css')
|
5
|
+
%body
|
6
|
+
.gutter
|
7
|
+
.welcome
|
8
|
+
%h1 Welcome to Charleston
|
9
|
+
:markdown
|
10
|
+
Charleston is a framework to build static HTML/CSS/JavaScript sites with
|
11
|
+
any combination of HTML, HAML, CSS, SASS, JavaScript, and CoffeeScript,
|
12
|
+
that's easy to put together and maintain.
|
13
|
+
%h2 Let's get started!
|
14
|
+
:markdown
|
15
|
+
1. I'm assuming you've run `charleston my_project` and are now looking
|
16
|
+
at a sample page.
|
17
|
+
2. Edit `pages/index.haml`, and create new HTML or HAML files in the `pages`
|
18
|
+
directory to make new pages.
|
19
|
+
2. Edit `stylesheets/screen.sass`, and create new CSS or SASS files in
|
20
|
+
the `stylesheets` directory to make new stylesheets.
|
21
|
+
3. Edit and create JavaScript or CoffeeScript files in the `javascripts`
|
22
|
+
directory to make new script files.
|
23
|
+
4. Add images to the `images` directory if you want.
|
24
|
+
3. When you want to build the site, run `rake` and it will be created
|
25
|
+
in the `output` directory.
|
26
|
+
%h2 Where to Put Files
|
27
|
+
%table#where_to_put
|
28
|
+
%thead
|
29
|
+
%tr
|
30
|
+
%th Class
|
31
|
+
%th Format
|
32
|
+
%th Inputs
|
33
|
+
%th Outputs
|
34
|
+
%tbody
|
35
|
+
%tr
|
36
|
+
%td Page
|
37
|
+
%td HTML
|
38
|
+
%td.in pages/*.html
|
39
|
+
%td.out output/*.html
|
40
|
+
%tr
|
41
|
+
%td Page
|
42
|
+
%td HAML
|
43
|
+
%td.in pages/*.haml
|
44
|
+
%td.out output/*.html
|
45
|
+
%tr
|
46
|
+
%td Stylesheet
|
47
|
+
%td CSS
|
48
|
+
%td.in stylesheets/*.css
|
49
|
+
%td.out output/stylesheets/*.css
|
50
|
+
%tr
|
51
|
+
%td Stylesheet
|
52
|
+
%td SASS
|
53
|
+
%td.in stylesheets/*.sass
|
54
|
+
%td.out output/stylesheets/*.css
|
55
|
+
%tr
|
56
|
+
%td Script
|
57
|
+
%td JavaScript
|
58
|
+
%td.in javascripts/*.js
|
59
|
+
%td.out output/javascripts/*.js
|
60
|
+
%tr
|
61
|
+
%td Script
|
62
|
+
%td CoffeeScript
|
63
|
+
%td.in javascripts/*.coffee
|
64
|
+
%td.out output/javascripts/*.js
|
65
|
+
%tr
|
66
|
+
%td Image
|
67
|
+
%td Any format
|
68
|
+
%td.in images/*
|
69
|
+
%td.out output/images/*
|
70
|
+
%h2 What Not To Do
|
71
|
+
:markdown
|
72
|
+
* Don't make any direct edits to the "output" directory. These files
|
73
|
+
get clobbered when you update the source files.
|
74
|
+
%h2 More information
|
75
|
+
:markdown
|
76
|
+
Source code is available and forkable on the
|
77
|
+
[Charleston Github repository](http://github.com/bkerley/charleston).
|
78
|
+
Thanks in advance for your contributions and well-tested patches.
|
79
|
+
|
80
|
+
Charleston is Copyright © 2010 by Bryce Kerley. Please see the
|
81
|
+
license included with this software, or in the [Charleston Github
|
82
|
+
repository](http://github.com/bkerley/charleston/blob/master/LICENSE).
|
83
|
+
%script(type='text/javascript' src='http://prototypejs.org/assets/2010/5/13/prototype.js')
|
84
|
+
%script(type='text/javascript' src='javascripts/example.js')
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$accent_color: #b1dd8f
|
2
|
+
$welcome_color: #222
|
3
|
+
$background_color: #111
|
4
|
+
$foreground_color: white
|
5
|
+
$dark_accent_color: darken($accent_color, 50%)
|
6
|
+
|
7
|
+
$body_font: "Avenir LT Std", Avenir, "Helvetica Neue", Helvetica, sans-serif, Arial
|
8
|
+
$code_font: Inconsolata, Menlo, "Droid Sans Mono", Consolas, "Bitstream Vera Sans Mono", "Lucida Sans Typewriter", "Lucida Console", mono, Courier, "Courier New"
|
9
|
+
|
10
|
+
body
|
11
|
+
background-color: $background_color
|
12
|
+
color: $foreground_color
|
13
|
+
font-family: $body_font
|
14
|
+
font-size: 1.2em
|
15
|
+
h1, h2, h3, h4, h5, h6
|
16
|
+
color: $accent_color
|
17
|
+
font-weight: 900
|
18
|
+
code
|
19
|
+
font-family: $code_font
|
20
|
+
background-color: $dark_accent_color
|
21
|
+
padding: 0 4px
|
22
|
+
table
|
23
|
+
thead
|
24
|
+
tr
|
25
|
+
background-color: $accent_color
|
26
|
+
color: $background_color
|
27
|
+
th
|
28
|
+
padding-top: 4px
|
29
|
+
font-weight: 100
|
30
|
+
tbody
|
31
|
+
td
|
32
|
+
padding: 2px 4px
|
33
|
+
&.in, &.out
|
34
|
+
font-family: $code_font
|
35
|
+
&.gigantic
|
36
|
+
font-size: 4em
|
37
|
+
|
38
|
+
a:link, a:visited
|
39
|
+
color: $accent_color
|
40
|
+
a:hover
|
41
|
+
text-decoration: none
|
42
|
+
|
43
|
+
div.gutter
|
44
|
+
width: 800px
|
45
|
+
margin: 0px auto
|
46
|
+
padding: 10px
|
47
|
+
div.welcome
|
48
|
+
background-color: $welcome_color
|
49
|
+
padding: 10px
|
50
|
+
margin: -10px
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Charleston
|
2
|
+
class Transform
|
3
|
+
def initialize(source_directory, source_pattern,
|
4
|
+
destination_directory, destination_pattern,
|
5
|
+
&transformation)
|
6
|
+
@source_dir = source_directory
|
7
|
+
@source_pat = source_pattern
|
8
|
+
@dest_dir = destination_directory
|
9
|
+
@dest_pat = destination_pattern
|
10
|
+
@transformation = transformation
|
11
|
+
|
12
|
+
find_sources
|
13
|
+
target_destinations
|
14
|
+
write_rules
|
15
|
+
end
|
16
|
+
|
17
|
+
def generates(rule_name)
|
18
|
+
desc "Transform #{@source_dir}/#{@source_pat} into output/#{@dest_dir}/#{@dest_pat}"
|
19
|
+
task "generate:#{rule_name}" => @destinations
|
20
|
+
task 'generate:all' => "generate:#{rule_name}"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def find_sources
|
25
|
+
@sources = ::Rake::FileList[File.join(@source_dir, @source_pat)]
|
26
|
+
end
|
27
|
+
|
28
|
+
def target_destinations
|
29
|
+
src_extension = find_extension_in_pattern(@source_pat)
|
30
|
+
dest_extension = find_extension_in_pattern(@dest_pat)
|
31
|
+
@destinations = @sources.map do |s|
|
32
|
+
File.expand_path(
|
33
|
+
s.sub(@source_dir, File.join('output', @dest_dir)).
|
34
|
+
sub(src_extension, dest_extension))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def write_rules
|
39
|
+
@sources.zip(@destinations) do |p|
|
40
|
+
input, output = p
|
41
|
+
file output => [input, 'output', File.join('output', @dest_dir)] do
|
42
|
+
@transformation.call input, output
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def find_extension_in_pattern(pattern)
|
48
|
+
pattern.sub(/\*\./, '')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/charleston.rb
ADDED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'mocha'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
require 'charleston'
|
9
|
+
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
end
|
12
|
+
|
13
|
+
# do this last
|
14
|
+
require 'fakefs'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestCharleston < Test::Unit::TestCase
|
4
|
+
context 'the Charleston module' do
|
5
|
+
subject { Charleston }
|
6
|
+
context 'create_project module method' do
|
7
|
+
subject { Charleston.method(:create_project) }
|
8
|
+
should 'take one argument' do
|
9
|
+
assert_equal 1, subject.arity
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when called with a directory name' do
|
13
|
+
setup do
|
14
|
+
@directory_name = "directory name"
|
15
|
+
@template_directory = File.expand_path(File.join(File.dirname(__FILE__), *%w{ .. lib charleston template}))
|
16
|
+
FakeFS::FileSystem.clone @template_directory
|
17
|
+
subject.call(@directory_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'create the directory' do
|
21
|
+
assert File.directory?(@directory_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
before_should 'create a generator with the directory name' do
|
25
|
+
Charleston::Generator.expects(:new).once.with("directory name")
|
26
|
+
end
|
27
|
+
|
28
|
+
before_should 'copy the template' do
|
29
|
+
FileUtils.expects(:cp_r).once.with do |from, to|
|
30
|
+
from_right = File.expand_path(from) == @template_directory
|
31
|
+
to_right = to == @directory_name
|
32
|
+
from_right && to_right
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/test/test_checks.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestChecks < Test::Unit::TestCase
|
4
|
+
context 'the Charleston::Checks module' do
|
5
|
+
subject { Charleston::Checks }
|
6
|
+
context 'haml_available? module method' do
|
7
|
+
subject { Charleston::Checks.method(:haml_available?) }
|
8
|
+
should 'take no arguments' do
|
9
|
+
assert subject.arity < 1
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'when invoked' do
|
13
|
+
setup do
|
14
|
+
subject.call
|
15
|
+
end
|
16
|
+
|
17
|
+
before_should 'check a haml' do
|
18
|
+
fake_path = stub
|
19
|
+
fake_path.expects(:split).with(':').returns ['/tmp/test/bin']
|
20
|
+
ENV.expects(:[]).with('PATH').returns fake_path
|
21
|
+
FileTest.expects(:executable?).with('/tmp/test/bin/haml').returns true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestTransform < Test::Unit::TestCase
|
4
|
+
context 'the Charleston::Transform class' do
|
5
|
+
subject { Charleston::Transform }
|
6
|
+
context 'new method' do
|
7
|
+
subject { Charleston::Transform.method(:new)}
|
8
|
+
should 'work with four arguments' do
|
9
|
+
assert_nothing_raised do
|
10
|
+
Charleston::Transform.new('pages', '*.haml', '', '*.html'){ }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'called with a directory full of hamls' do
|
15
|
+
setup do
|
16
|
+
@fixture_directory = File.expand_path(File.join(File.dirname(__FILE__), 'fixture'))
|
17
|
+
FakeFS::FileSystem.clone @fixture_directory
|
18
|
+
FakeFS::FileSystem.chdir @fixture_directory
|
19
|
+
@transform = Charleston::Transform.new(File.join(@fixture_directory, 'pages'), '*.haml', '', '*.html'){ }
|
20
|
+
end
|
21
|
+
|
22
|
+
before_should 'make file rules for index and about' do
|
23
|
+
%w{ index about }.each do |f|
|
24
|
+
Charleston::Transform.any_instance.expects(:file).at_least_once.with do |args|
|
25
|
+
output = args.keys.first
|
26
|
+
input = args[output]
|
27
|
+
next false if args.length > 1
|
28
|
+
next false unless output =~ Regexp.new("output/#{f}\\\.html$")
|
29
|
+
next false unless input.include? 'output' #directory
|
30
|
+
next false unless input.detect{ |v| v =~ Regexp.new("pages/#{f}\\\.haml$")}
|
31
|
+
true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when asked to register rules' do
|
37
|
+
setup do
|
38
|
+
@transform.generates 'haml'
|
39
|
+
end
|
40
|
+
|
41
|
+
before_should 'make a "generate:haml" rule and add it to the generate:all rule' do
|
42
|
+
@transform.expects(:task).with do |args|
|
43
|
+
task = args.keys.first
|
44
|
+
depends = args[task]
|
45
|
+
next false unless args.length == 1
|
46
|
+
next false unless task == 'generate:haml'
|
47
|
+
next false unless depends.detect{ |v| v =~ /output\/index\.html$/ }
|
48
|
+
next false unless depends.detect{ |v| v =~ /output\/about\.html$/ }
|
49
|
+
true
|
50
|
+
end
|
51
|
+
@transform.expects(:task).with('generate:all'=>'generate:haml')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: charleston
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Bryce Kerley
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-11 00:00:00 -04:00
|
19
|
+
default_executable: charleston
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 8
|
33
|
+
version: "0.8"
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: haml
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 7
|
45
|
+
segments:
|
46
|
+
- 3
|
47
|
+
- 0
|
48
|
+
version: "3.0"
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: shoulda
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 21
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 11
|
63
|
+
version: "2.11"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: yard
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 7
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
- 6
|
78
|
+
version: "0.6"
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: mocha
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 25
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
- 9
|
93
|
+
version: "0.9"
|
94
|
+
type: :development
|
95
|
+
version_requirements: *id005
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: fakefs
|
98
|
+
prerelease: false
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 15
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
- 2
|
108
|
+
version: "0.2"
|
109
|
+
type: :development
|
110
|
+
version_requirements: *id006
|
111
|
+
description: Charleston is a framework to build static HTML/CSS/JavaScript sites with any combination of HTML, HAML, CSS, SASS, JavaScript, and CoffeeScript, that's easy to put together and maintain.
|
112
|
+
email: bkerley@brycekerley.net
|
113
|
+
executables:
|
114
|
+
- charleston
|
115
|
+
extensions: []
|
116
|
+
|
117
|
+
extra_rdoc_files:
|
118
|
+
- LICENSE
|
119
|
+
- README.rdoc
|
120
|
+
files:
|
121
|
+
- .document
|
122
|
+
- .gitignore
|
123
|
+
- LICENSE
|
124
|
+
- README.rdoc
|
125
|
+
- Rakefile
|
126
|
+
- VERSION
|
127
|
+
- bin/charleston
|
128
|
+
- charleston.gemspec
|
129
|
+
- lib/charleston.rb
|
130
|
+
- lib/charleston/checks.rb
|
131
|
+
- lib/charleston/generator.rb
|
132
|
+
- lib/charleston/tasks.rb
|
133
|
+
- lib/charleston/tasks/css.rake
|
134
|
+
- lib/charleston/tasks/directories.rake
|
135
|
+
- lib/charleston/tasks/html.rake
|
136
|
+
- lib/charleston/tasks/image.rake
|
137
|
+
- lib/charleston/tasks/js.rake
|
138
|
+
- lib/charleston/template/Rakefile
|
139
|
+
- lib/charleston/template/javascripts/example.coffee
|
140
|
+
- lib/charleston/template/pages/index.haml
|
141
|
+
- lib/charleston/template/stylesheets/screen.sass
|
142
|
+
- lib/charleston/transform.rb
|
143
|
+
- test/fixture/pages/about.haml
|
144
|
+
- test/fixture/pages/contact.html
|
145
|
+
- test/fixture/pages/dev.html
|
146
|
+
- test/fixture/pages/index.haml
|
147
|
+
- test/helper.rb
|
148
|
+
- test/test_charleston.rb
|
149
|
+
- test/test_checks.rb
|
150
|
+
- test/test_transform.rb
|
151
|
+
has_rdoc: true
|
152
|
+
homepage: http://github.com/bkerley/charleston
|
153
|
+
licenses: []
|
154
|
+
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options:
|
157
|
+
- --charset=UTF-8
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
hash: 3
|
166
|
+
segments:
|
167
|
+
- 0
|
168
|
+
version: "0"
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
hash: 3
|
175
|
+
segments:
|
176
|
+
- 0
|
177
|
+
version: "0"
|
178
|
+
requirements: []
|
179
|
+
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 1.3.7
|
182
|
+
signing_key:
|
183
|
+
specification_version: 3
|
184
|
+
summary: Static HTML site framework
|
185
|
+
test_files:
|
186
|
+
- test/helper.rb
|
187
|
+
- test/test_charleston.rb
|
188
|
+
- test/test_checks.rb
|
189
|
+
- test/test_transform.rb
|