tau 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -2
- data/bin/tau +2 -11
- data/features/builder.feature +41 -0
- data/features/cli.feature +22 -0
- data/features/making_projects.feature +14 -2
- data/features/step_definitions/cli.rb +14 -0
- data/features/step_definitions/fs.rb +20 -10
- data/lib/tau/builder.rb +34 -0
- data/lib/tau/cli.rb +35 -0
- data/lib/tau/projecter.rb +30 -30
- data/lib/tau/renderer.rb +55 -0
- data/lib/tau/version.rb +1 -1
- data/tau.gemspec +1 -1
- metadata +36 -16
data/README.md
CHANGED
@@ -62,12 +62,26 @@ written in sass or scss. For example if you have **code/js/script.coffee**
|
|
62
62
|
script and **code/js/style.sass** spreadsheet you can include it to html by
|
63
63
|
lines:
|
64
64
|
```html
|
65
|
-
<script src='js/script.js'
|
66
|
-
<link rel="stylesheet" href="css/style.css"
|
65
|
+
<script src='js/script.js'></script>
|
66
|
+
<link rel="stylesheet" href="css/style.css">
|
67
67
|
```
|
68
68
|
Anytime you change any file you can see updated version in browser. You don't
|
69
69
|
need to compile anything by hand.
|
70
70
|
|
71
|
+
### Building project
|
72
|
+
|
73
|
+
If you want to compile all files for releasing it in internet you don't need do
|
74
|
+
it by hand. `tau build` command compiles all sass, haml and other files and put
|
75
|
+
them into **build/** directory. Any files from **img** directory and not a haml, sass
|
76
|
+
or coffee-script files will copied without any changes. For example:
|
77
|
+
```
|
78
|
+
code/index.haml -> build/index.html
|
79
|
+
code/js/script.coffee -> build/js/script.js
|
80
|
+
code/img/logo.png -> build/img/logo.png
|
81
|
+
code/humans.txt -> build/humans.txt
|
82
|
+
etc...
|
83
|
+
```
|
84
|
+
|
71
85
|
License
|
72
86
|
-------
|
73
87
|
|
data/bin/tau
CHANGED
@@ -1,13 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'tau/
|
3
|
-
require 'tau/projecter'
|
2
|
+
require 'tau/cli'
|
4
3
|
|
5
|
-
Tau::
|
6
|
-
if ARGV.first == "new"
|
7
|
-
project_name = ARGV[1]
|
8
|
-
begin
|
9
|
-
Tau::Projecter.new_project(Dir.pwd, project_name)
|
10
|
-
rescue Exception => e
|
11
|
-
puts e.message
|
12
|
-
end
|
13
|
-
end
|
4
|
+
Tau::Cli.start
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Feature: Builder
|
2
|
+
In order to avoid compiling all files by hand
|
3
|
+
As a web developer
|
4
|
+
I want tau compile all files for me
|
5
|
+
|
6
|
+
Background: making project
|
7
|
+
Given I successfully run `tau new project2build`
|
8
|
+
And I cd to "project2build"
|
9
|
+
|
10
|
+
Scenario: building project
|
11
|
+
Given a file named "code/hamltest.haml" with:
|
12
|
+
"""
|
13
|
+
%h1 Hello, world!
|
14
|
+
%strong I'm tau ;)
|
15
|
+
"""
|
16
|
+
And a file named "code/js/coffeetest.coffee" with:
|
17
|
+
"""
|
18
|
+
square = (x) -> x * x
|
19
|
+
cube = (x) -> square(x) * x
|
20
|
+
"""
|
21
|
+
And a file named "code/css/sasstest.sass" with:
|
22
|
+
"""
|
23
|
+
$blue: #3bbfce
|
24
|
+
.content-navigation
|
25
|
+
border-color: $blue
|
26
|
+
color: darken($blue, 9%)
|
27
|
+
"""
|
28
|
+
And a file named "code/css/scsstest.scss" with:
|
29
|
+
"""
|
30
|
+
$blue: #3bbfce;
|
31
|
+
.content-navigation {
|
32
|
+
border-color: $blue;
|
33
|
+
color:
|
34
|
+
darken($blue, 9%);
|
35
|
+
}
|
36
|
+
"""
|
37
|
+
When I successfully run `tau build`
|
38
|
+
Then I should see file "build/hamltest.html" compiled from haml in "code/hamltest.haml"
|
39
|
+
And I should see file "build/js/coffeetest.js" compiled from coffee-script in "code/js/coffeetest.coffee"
|
40
|
+
And I should see file "build/css/sasstest.css" compiled from sass in "code/css/sasstest.sass"
|
41
|
+
And I should see file "build/css/scsstest.css" compiled from scss in "code/css/scsstest.scss"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: Cli
|
2
|
+
As a tau user
|
3
|
+
I should be able to see usage information
|
4
|
+
|
5
|
+
Scenario: viewing help by default
|
6
|
+
When I run `tau`
|
7
|
+
Then I should see usage information
|
8
|
+
|
9
|
+
Scenario: viewing help
|
10
|
+
When I run `tau --help`
|
11
|
+
Then I should see usage information
|
12
|
+
|
13
|
+
Scenario: tau commands should be described
|
14
|
+
When I run `tau --help`
|
15
|
+
Then I should see commands described:
|
16
|
+
| help |
|
17
|
+
| new |
|
18
|
+
| server |
|
19
|
+
|
20
|
+
Scenario: viewing version of tau
|
21
|
+
When I run `tau -v`
|
22
|
+
Then I should see version
|
@@ -4,5 +4,17 @@ Feature: Making new projects
|
|
4
4
|
I want tau make project for me
|
5
5
|
|
6
6
|
Scenario: making new project by tau
|
7
|
-
When I successfully run `tau new
|
8
|
-
|
7
|
+
When I successfully run `tau new test_project`
|
8
|
+
Then there should be right project directory "test_project"
|
9
|
+
|
10
|
+
Scenario: making project with dot in project name
|
11
|
+
When I successfully run `tau new .test.project.`
|
12
|
+
Then there should be right project directory ".test.project."
|
13
|
+
|
14
|
+
Scenario: making project with cyrillic name
|
15
|
+
When I successfully run `tau new тест`
|
16
|
+
Then there should be right project directory "тест"
|
17
|
+
|
18
|
+
Scenario: making project with "-" symbol in project name
|
19
|
+
When I successfully run `tau new -test-project-`
|
20
|
+
Then there should be right project directory "-test-project-"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Then /^I should see usage information$/ do
|
2
|
+
step %q(the output should match /tau\s+[\w\s\[\]]+#[\w \.]+/)
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should see commands described:$/ do |commands|
|
6
|
+
commands.raw.each do |command|
|
7
|
+
command = command.first
|
8
|
+
step "the output should match /tau #{command}\\s+[\\w\\s\\[\\]]+#[\\w \\.]+/"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^I should see version$/ do
|
13
|
+
step %q(the output should match /\d\.\d\.\d/)
|
14
|
+
end
|
@@ -1,10 +1,20 @@
|
|
1
|
-
Then /^there should be right project directory "(.*)"$/ do |project_dir|
|
2
|
-
tau_dirs = ['/code', 'code/js', 'code/css', 'code/img'].map { |dir| "#{project_dir}/#{dir}" }
|
3
|
-
check_directory_presence(tau_dirs, true)
|
4
|
-
tau_files = ['tau.
|
5
|
-
check_file_presence(tau_files, true)
|
6
|
-
end
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
Then /^there should be right project directory "(.*)"$/ do |project_dir|
|
2
|
+
tau_dirs = ['/code', 'code/js', 'code/css', 'code/img'].map { |dir| "#{project_dir}/#{dir}" }
|
3
|
+
check_directory_presence(tau_dirs, true)
|
4
|
+
tau_files = ['tau.yml'].map { |file| "#{project_dir}/#{file}" }
|
5
|
+
check_file_presence(tau_files, true)
|
6
|
+
end
|
7
|
+
|
8
|
+
Then /^I should see file "(.*)" compiled from (haml|sass|scss|coffee-script) in "(.*)"$/ do |compiled_file, lang, src_file|
|
9
|
+
compiled_file_content = nil
|
10
|
+
src_file_content = nil
|
11
|
+
in_current_dir do
|
12
|
+
compiled_file_content = File.read compiled_file
|
13
|
+
src_file_content = File.read src_file
|
14
|
+
end
|
15
|
+
compiled_file_content.should == render(src_file_content, lang)
|
16
|
+
end
|
17
|
+
|
18
|
+
Given /^I'm on sandbox project directory$/ do
|
19
|
+
@dirs = [SANDBOX_PROJECT_DIR]
|
20
|
+
end
|
data/lib/tau/builder.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'tau/projecter'
|
2
|
+
require 'tau/renderer'
|
3
|
+
|
4
|
+
module Tau
|
5
|
+
class Builder
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def build
|
9
|
+
raise "You are not in the project directory" unless Projecter.project_dir?(Dir.pwd)
|
10
|
+
|
11
|
+
FileUtils.rm_rf('build')
|
12
|
+
Dir['code/**/*'].each do |filename|
|
13
|
+
if File.directory?(filename)
|
14
|
+
FileUtils.mkdir_p filename.sub('code/', 'build/')
|
15
|
+
elsif not Renderer.need_render? filename
|
16
|
+
FileUtils.cp filename, destination_for(filename)
|
17
|
+
else
|
18
|
+
Renderer.render_to_file destination_for(filename), filename
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def destination_for(filename)
|
26
|
+
filename.sub('code/', 'build/').sub(/\.sass$/, '.css')
|
27
|
+
.sub(/\.scss$/, '.css')
|
28
|
+
.sub(/\.haml$/, '.html')
|
29
|
+
.sub(/\.coffee$/, '.js')
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/tau/cli.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'tau/projecter'
|
3
|
+
require 'tau/server'
|
4
|
+
require 'tau/version'
|
5
|
+
require 'tau/builder'
|
6
|
+
|
7
|
+
module Tau
|
8
|
+
class Cli < Thor
|
9
|
+
map '-v' => :version
|
10
|
+
|
11
|
+
desc "new PROJECT_NAME", "Making new project"
|
12
|
+
def new(project_name)
|
13
|
+
begin
|
14
|
+
Tau::Projecter.new_project(Dir.pwd, project_name)
|
15
|
+
rescue Exception => e
|
16
|
+
puts e.message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc :server, "Starting server for development"
|
21
|
+
def server
|
22
|
+
Tau::Server.start
|
23
|
+
end
|
24
|
+
|
25
|
+
desc :build, "Building project"
|
26
|
+
def build
|
27
|
+
Tau::Builder.build
|
28
|
+
end
|
29
|
+
|
30
|
+
desc :version, "Show tau version"
|
31
|
+
def version
|
32
|
+
puts "Tau #{Tau::VERSION}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/tau/projecter.rb
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
module Tau
|
2
|
-
class Projecter
|
3
|
-
def self.new_project(directory, project_name)
|
4
|
-
Dir.chdir(directory)
|
5
|
-
|
6
|
-
raise "This already is the project directory" if project_dir?(directory)
|
7
|
-
raise "Wrong project name" unless project_name =~
|
8
|
-
raise "Directory exists" if Dir.exist?(project_name)
|
9
|
-
|
10
|
-
Dir.mkdir(project_name)
|
11
|
-
Dir.chdir(project_name) do
|
12
|
-
puts("\tcreate\tcode")
|
13
|
-
Dir.mkdir('code')
|
14
|
-
puts("\tcreate\tcode/js")
|
15
|
-
Dir.mkdir('code/js')
|
16
|
-
puts("\tcreate\tcode/css")
|
17
|
-
Dir.mkdir('code/css')
|
18
|
-
puts("\tcreate\tcode/img")
|
19
|
-
Dir.mkdir('code/img')
|
20
|
-
puts("\tcreate\ttau.yaml")
|
21
|
-
File.new('tau.
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.project_dir?(directory)
|
26
|
-
Dir.chdir(directory)
|
27
|
-
Dir.exist?('code') and File.exist?('tau.
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
module Tau
|
2
|
+
class Projecter
|
3
|
+
def self.new_project(directory, project_name)
|
4
|
+
Dir.chdir(directory)
|
5
|
+
|
6
|
+
raise "This already is the project directory" if project_dir?(directory)
|
7
|
+
raise "Wrong project name" unless project_name =~ /^[[:word:]\.-]+$/
|
8
|
+
raise "Directory exists" if Dir.exist?(project_name)
|
9
|
+
|
10
|
+
Dir.mkdir(project_name)
|
11
|
+
Dir.chdir(project_name) do
|
12
|
+
puts("\tcreate\tcode")
|
13
|
+
Dir.mkdir('code')
|
14
|
+
puts("\tcreate\tcode/js")
|
15
|
+
Dir.mkdir('code/js')
|
16
|
+
puts("\tcreate\tcode/css")
|
17
|
+
Dir.mkdir('code/css')
|
18
|
+
puts("\tcreate\tcode/img")
|
19
|
+
Dir.mkdir('code/img')
|
20
|
+
puts("\tcreate\ttau.yaml")
|
21
|
+
File.new('tau.yml', 'w')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.project_dir?(directory)
|
26
|
+
Dir.chdir(directory)
|
27
|
+
Dir.exist?('code') and File.exist?('tau.yml')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/tau/renderer.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Tau
|
2
|
+
class Renderer
|
3
|
+
class << self
|
4
|
+
|
5
|
+
def render(content, lang)
|
6
|
+
return sass content if lang == :sass
|
7
|
+
return scss content if lang == :scss
|
8
|
+
return haml content if lang == :haml
|
9
|
+
return coffee content if lang == :coffee
|
10
|
+
end
|
11
|
+
|
12
|
+
def render_file(filename)
|
13
|
+
raise "File is not exist" unless File.exist?(filename)
|
14
|
+
|
15
|
+
content = File.read filename
|
16
|
+
return content unless need_render?(filename)
|
17
|
+
return sass content if filename.end_with?('.sass')
|
18
|
+
return scss content if filename.end_with?('.scss')
|
19
|
+
return haml content if filename.end_with?('.haml')
|
20
|
+
return coffee content if filename.end_with?('.coffee')
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_to_file(dst_filename, filename)
|
24
|
+
File.write dst_filename, render_file(filename)
|
25
|
+
end
|
26
|
+
|
27
|
+
def need_render?(filename)
|
28
|
+
return true if filename.end_with?('.sass') or
|
29
|
+
filename.end_with?('.scss') or
|
30
|
+
filename.end_with?('.haml') or
|
31
|
+
filename.end_with?('.coffee')
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def sass(content)
|
38
|
+
Sass::Engine.new(content).render
|
39
|
+
end
|
40
|
+
|
41
|
+
def scss(content)
|
42
|
+
Sass::Engine.new(content, syntax: :scss).render
|
43
|
+
end
|
44
|
+
|
45
|
+
def haml(content)
|
46
|
+
Haml::Engine.new(content).render
|
47
|
+
end
|
48
|
+
|
49
|
+
def coffee(content)
|
50
|
+
CoffeeScript.compile(content)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/tau/version.rb
CHANGED
data/tau.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_development_dependency dependecy
|
21
21
|
end
|
22
22
|
|
23
|
-
['sinatra', 'sass', 'coffee-script', 'haml'].each do |dependecy|
|
23
|
+
['sinatra', 'sass', 'coffee-script', 'haml', 'thor'].each do |dependecy|
|
24
24
|
s.add_dependency dependecy
|
25
25
|
end
|
26
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tau
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
16
|
-
requirement: &
|
16
|
+
requirement: &10883440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10883440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: aruba
|
27
|
-
requirement: &
|
27
|
+
requirement: &10940900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10940900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: childprocess
|
38
|
-
requirement: &
|
38
|
+
requirement: &10939680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10939680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sinatra
|
49
|
-
requirement: &
|
49
|
+
requirement: &10937760 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10937760
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: sass
|
60
|
-
requirement: &
|
60
|
+
requirement: &10936900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *10936900
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: coffee-script
|
71
|
-
requirement: &
|
71
|
+
requirement: &10999060 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *10999060
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: haml
|
82
|
-
requirement: &
|
82
|
+
requirement: &10998500 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,18 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *10998500
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: thor
|
93
|
+
requirement: &10997880 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *10997880
|
91
102
|
description: tau provide you write web pages on haml, stylesheets on sass and scripts
|
92
103
|
on coffee.
|
93
104
|
email:
|
@@ -102,14 +113,20 @@ files:
|
|
102
113
|
- README.md
|
103
114
|
- Rakefile
|
104
115
|
- bin/tau
|
116
|
+
- features/builder.feature
|
117
|
+
- features/cli.feature
|
105
118
|
- features/making_projects.feature
|
106
119
|
- features/server.feature
|
120
|
+
- features/step_definitions/cli.rb
|
107
121
|
- features/step_definitions/fs.rb
|
108
122
|
- features/step_definitions/network.rb
|
109
123
|
- features/support/cukegem.rb
|
110
124
|
- features/support/env.rb
|
111
125
|
- lib/tau.rb
|
126
|
+
- lib/tau/builder.rb
|
127
|
+
- lib/tau/cli.rb
|
112
128
|
- lib/tau/projecter.rb
|
129
|
+
- lib/tau/renderer.rb
|
113
130
|
- lib/tau/server.rb
|
114
131
|
- lib/tau/version.rb
|
115
132
|
- tau.gemspec
|
@@ -138,8 +155,11 @@ signing_key:
|
|
138
155
|
specification_version: 3
|
139
156
|
summary: Tool for web designers want to use haml, sass, coffee-script and others.
|
140
157
|
test_files:
|
158
|
+
- features/builder.feature
|
159
|
+
- features/cli.feature
|
141
160
|
- features/making_projects.feature
|
142
161
|
- features/server.feature
|
162
|
+
- features/step_definitions/cli.rb
|
143
163
|
- features/step_definitions/fs.rb
|
144
164
|
- features/step_definitions/network.rb
|
145
165
|
- features/support/cukegem.rb
|