piano 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,11 +1,12 @@
1
1
  = Piano
2
2
 
3
- Out-of-the-box sinatra server for fast website sketching using haml and sass.
3
+ Out-of-the-box sinatra server for fast website sketching using haml and sass and coffee-script.
4
+
5
+ The magic triplet, one command away!
4
6
 
5
7
  == Installation
6
- CHECK
7
8
 
8
- sudo gem install <git-repo>
9
+ gem install piano
9
10
 
10
11
  == Usage
11
12
 
@@ -13,23 +14,44 @@ CHECK
13
14
 
14
15
  Piano will start a Sinatra server based in the same folder where you run the command, in the port given. If no port is given, piano will start in the default Sinatra port, 4567.
15
16
 
16
- Haml(http://haml-lang.com/) <tt>.haml</tt> files and Sass (http://sass-lang.com/) <tt>.sass</tt> files in the base folder will automatically be mapped to urls.
17
+ Haml(http://haml-lang.com) <tt>.haml</tt> files and Sass (http://sass-lang.com) <tt>.sass</tt> and CoffeeScript (http://github.com/josh/ruby-coffee-script) <tt>.coffee</tt> files in the base folder will automatically be mapped to urls.
17
18
 
18
19
  yoursite.com/users => server/folder/users.haml
19
20
  yoursite.com/style.css => server/folder/style.sass
21
+ yoursite.com/app.js => server/folder/app.coffee
20
22
 
21
23
  Other files (images, plain text files, etc) will be loaded from the <tt>server/folder/public</tt> as is default behavior in Sinatra.
22
24
 
25
+ == Candies for the kidz
26
+
27
+ Piano features two convenience helpers to include stylesheets and javascripts: <tt>style("style.css")</tt> and <tt>script("app.js")</tt>.
28
+
29
+ You can use them in your haml templates like this:
30
+
31
+ !!! 5
32
+ %html
33
+ %head
34
+ %title Out-of-the-box is pretty awesome!
35
+ = style "style.css"
36
+ = script "app.js"
37
+
38
+ Code is poetry.
39
+
23
40
  == Gem dependencies
24
41
 
25
- * Sinatra (http://sinatrarb.com/)
26
- * Haml (http://haml-lang.com/)
27
- * Sass (http://sass-lang.com/)
42
+ * sinatra (http://sinatrarb.com)
43
+ * haml (http://haml-lang.com)
44
+ * sass (http://sass-lang.com)
45
+ * coffee-script (http://github.com/josh/ruby-coffee-script)
28
46
 
29
47
  == Desired (future) features
30
48
 
31
49
  * Online source files edition.
32
50
 
51
+ == Tips
52
+
53
+ Not really suitable for production use, since any empty URL will return a full path disclosure of the file the Piano intended to load.
54
+
33
55
  = License
34
56
 
35
57
  (The MIT License)
data/lib/piano.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "sinatra/base"
2
2
  require "haml"
3
3
  require "sass"
4
+ require "coffee-script"
4
5
 
5
6
  class Piano < Sinatra::Base
6
7
  set :root, File.expand_path(Dir.pwd)
@@ -10,12 +11,17 @@ class Piano < Sinatra::Base
10
11
  try_haml :index
11
12
  end
12
13
 
13
- get "/:something.css" do |something|
14
+ get %r{/(.+?).css} do |something|
14
15
  content_type :css
15
16
  sass something.to_sym
16
17
  end
17
18
 
18
- get "/:something" do |something|
19
+ get %r{/(.+?).js} do |something|
20
+ content_type :js
21
+ coffee something.to_sym
22
+ end
23
+
24
+ get %r{/(.+)$} do |something|
19
25
  try_haml something.to_sym
20
26
  end
21
27
 
@@ -37,10 +43,7 @@ class Piano < Sinatra::Base
37
43
  def sass(template)
38
44
  begin
39
45
  dir = File.expand_path(Dir.pwd)
40
- data = ""
41
- File.open "#{dir}/#{template.to_s}.sass" do |file|
42
- data = file.read
43
- end
46
+ data = File.read "#{dir}/#{template.to_s}.sass"
44
47
  return Sass.compile(data, :syntax => :sass)
45
48
  rescue Exception => error
46
49
  if error.message =~ /No such file or directory/
@@ -52,6 +55,30 @@ class Piano < Sinatra::Base
52
55
  end
53
56
  end
54
57
  end
58
+
59
+ def coffee(template)
60
+ begin
61
+ dir = File.expand_path(Dir.pwd)
62
+ data = File.read "#{dir}/#{template.to_s}.coffee"
63
+ return CoffeeScript.compile(data)
64
+ rescue Exception => error
65
+ if error.message =~ /No such file or directory/
66
+ path = File.expand_path(Dir.pwd)
67
+ response = "<h1>You have still to put something here.</h1><p>This is <em>#{path}/#{template.to_s}.coffee</em></p><blockquote>Good luck!</blockquote>"
68
+ return response
69
+ else
70
+ raise error
71
+ end
72
+ end
73
+ end
74
+
75
+ def style(path)
76
+ "<link rel='stylesheet' type='text/css' href='#{path}' />"
77
+ end
78
+
79
+ def script(path)
80
+ "<script type='text/javascript' src='#{path}'></script>"
81
+ end
55
82
  end
56
83
 
57
84
  end
data/lib/piano/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Piano
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
data/piano.gemspec CHANGED
@@ -8,14 +8,15 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Xavier Via"]
10
10
  s.email = ["xavierviacanel@gmail.com"]
11
- s.homepage = ""
12
- s.summary = %q{Out-of-the-box sinatra server for web site sketching using haml + sass}
13
- s.description = %q{Out-of-the-box sinatra server for web site sketching using haml + sass}
11
+ s.homepage = "http://github.com/xaviervia/piano"
12
+ s.summary = %q{Out-of-the-box sinatra server for web site sketching using haml + sass + coffee-script}
13
+ s.description = %q{Out-of-the-box sinatra server for web site sketching using haml + sass + coffee-script}
14
14
 
15
15
  s.rubyforge_project = "piano"
16
- s.add_dependency "sinatra"
17
- s.add_dependency "haml"
18
- s.add_dependency "sass"
16
+ s.add_dependency "sinatra", ">= 1.2.6"
17
+ s.add_dependency "haml", ">= 3.1.1"
18
+ s.add_dependency "sass", ">= 3.1.1"
19
+ s.add_dependency "coffee-script", ">= 2.2.0"
19
20
 
20
21
  s.files = `git ls-files`.split("\n")
21
22
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,43 +9,55 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-05-07 00:00:00.000000000 -03:00
12
+ date: 2011-05-08 00:00:00.000000000 -03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra
17
- requirement: &20307744 !ruby/object:Gem::Requirement
17
+ requirement: &22065996 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: 1.2.6
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *20307744
25
+ version_requirements: *22065996
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: haml
28
- requirement: &20307456 !ruby/object:Gem::Requirement
28
+ requirement: &22065696 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 3.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *20307456
36
+ version_requirements: *22065696
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sass
39
- requirement: &20307204 !ruby/object:Gem::Requirement
39
+ requirement: &22065420 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
- version: '0'
44
+ version: 3.1.1
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *20307204
47
+ version_requirements: *22065420
48
+ - !ruby/object:Gem::Dependency
49
+ name: coffee-script
50
+ requirement: &21335700 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: 2.2.0
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: *21335700
48
59
  description: Out-of-the-box sinatra server for web site sketching using haml + sass
60
+ + coffee-script
49
61
  email:
50
62
  - xavierviacanel@gmail.com
51
63
  executables:
@@ -62,7 +74,7 @@ files:
62
74
  - lib/piano/version.rb
63
75
  - piano.gemspec
64
76
  has_rdoc: true
65
- homepage: ''
77
+ homepage: http://github.com/xaviervia/piano
66
78
  licenses: []
67
79
  post_install_message:
68
80
  rdoc_options: []
@@ -85,5 +97,6 @@ rubyforge_project: piano
85
97
  rubygems_version: 1.5.2
86
98
  signing_key:
87
99
  specification_version: 3
88
- summary: Out-of-the-box sinatra server for web site sketching using haml + sass
100
+ summary: Out-of-the-box sinatra server for web site sketching using haml + sass +
101
+ coffee-script
89
102
  test_files: []