piano 0.5.1
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 +5 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bin/piano +9 -0
- data/lib/piano.rb +57 -0
- data/lib/piano/version.rb +3 -0
- data/piano.gemspec +24 -0
- metadata +88 -0
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/piano
ADDED
data/lib/piano.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
require "haml"
|
3
|
+
require "sass"
|
4
|
+
|
5
|
+
class Piano < Sinatra::Base
|
6
|
+
set :root, File.expand_path(Dir.pwd)
|
7
|
+
set :views, File.expand_path(Dir.pwd)
|
8
|
+
|
9
|
+
get "/" do
|
10
|
+
try_haml :index
|
11
|
+
end
|
12
|
+
|
13
|
+
get "/:something.css" do |something|
|
14
|
+
content_type :css
|
15
|
+
sass something.to_sym
|
16
|
+
end
|
17
|
+
|
18
|
+
get "/:something" do |something|
|
19
|
+
try_haml something.to_sym
|
20
|
+
end
|
21
|
+
|
22
|
+
helpers do
|
23
|
+
def try_haml(template)
|
24
|
+
begin
|
25
|
+
return haml template
|
26
|
+
rescue Exception => error
|
27
|
+
if error.message =~ /No such file or directory/
|
28
|
+
path = File.expand_path(Dir.pwd)
|
29
|
+
response = "<h1>You have still to put something here.</h1><p>This is <em>#{path}/#{template.to_sym}.haml</em></p><blockquote>Good luck!</blockquote>"
|
30
|
+
return response
|
31
|
+
else
|
32
|
+
raise error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def sass(template)
|
38
|
+
begin
|
39
|
+
dir = File.expand_path(Dir.pwd)
|
40
|
+
data = ""
|
41
|
+
File.open "#{dir}/#{template.to_s}.sass" do |file|
|
42
|
+
data = file.read
|
43
|
+
end
|
44
|
+
return Sass.compile(data, :syntax => :sass)
|
45
|
+
rescue Exception => error
|
46
|
+
if error.message =~ /No such file or directory/
|
47
|
+
path = File.expand_path(Dir.pwd)
|
48
|
+
response = "<h1>You have still to put something here.</h1><p>This is <em>#{path}/#{template.to_s}.sass</em></p><blockquote>Good luck!</blockquote>"
|
49
|
+
return response
|
50
|
+
else
|
51
|
+
raise error
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/piano.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "piano/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "piano"
|
7
|
+
s.version = Piano::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Xavier Via"]
|
10
|
+
s.email = ["xavierviacanel@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Write a gem summary}
|
13
|
+
s.description = %q{Write a gem description}
|
14
|
+
|
15
|
+
s.rubyforge_project = "piano"
|
16
|
+
s.add_dependency "sinatra"
|
17
|
+
s.add_dependency "haml"
|
18
|
+
s.add_dependency "sass"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: piano
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Xavier Via
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-05-06 00:00:00.000000000 -03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sinatra
|
17
|
+
requirement: &20821008 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *20821008
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: haml
|
28
|
+
requirement: &20820756 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *20820756
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: sass
|
39
|
+
requirement: &20820492 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *20820492
|
48
|
+
description: Write a gem description
|
49
|
+
email:
|
50
|
+
- xavierviacanel@gmail.com
|
51
|
+
executables:
|
52
|
+
- piano
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- Rakefile
|
59
|
+
- bin/piano
|
60
|
+
- lib/piano.rb
|
61
|
+
- lib/piano/version.rb
|
62
|
+
- piano.gemspec
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: ''
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project: piano
|
84
|
+
rubygems_version: 1.5.2
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Write a gem summary
|
88
|
+
test_files: []
|