piano 0.10.4 → 0.10.6
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/README.rdoc +248 -234
- data/Rakefile +1 -1
- data/bin/piano +62 -87
- data/bin/piano~ +87 -0
- data/lib/piano.rb +46 -186
- data/lib/piano/controllerloader.rb +39 -39
- data/lib/piano/routes.rb +23 -23
- data/lib/piano/version.rb +3 -3
- data/lib/sinatra/piano.rb +141 -0
- data/sample/data/index.yaml +7 -7
- data/sample/index.haml +10 -10
- data/sample/style.sass +5 -5
- metadata +22 -21
- data/Gemfile +0 -4
- data/spec/controller_spec.rb +0 -90
data/Gemfile
DELETED
data/spec/controller_spec.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
require "piano/controllerloader"
|
2
|
-
|
3
|
-
describe Piano::ControllerLoader do
|
4
|
-
context "there are some files in the folder" do
|
5
|
-
before :all do
|
6
|
-
if Dir.exist? "controllers"
|
7
|
-
puts "#{File.expand_path('controllers')} should not exist for this to run"
|
8
|
-
Process.exit!
|
9
|
-
end
|
10
|
-
|
11
|
-
FileUtils.mkdir "controllers"
|
12
|
-
File.open "controllers/demo.controller", "w" do |file|
|
13
|
-
file.write <<-HOLA
|
14
|
-
def Piano.demo_was_loaded; true; end
|
15
|
-
HOLA
|
16
|
-
end
|
17
|
-
|
18
|
-
File.open "controllers/another.rb", "w" do |file|
|
19
|
-
file.write <<-HOLA2
|
20
|
-
def Piano.wrong!; true; end
|
21
|
-
HOLA2
|
22
|
-
end
|
23
|
-
|
24
|
-
FileUtils.mkdir "controllers/recursive"
|
25
|
-
FileUtils.mkdir "controllers/recursive/very"
|
26
|
-
File.open "controllers/recursive/very/demo2.controller", "w" do
|
27
|
-
|file|
|
28
|
-
file.write <<-HOLA3
|
29
|
-
def Piano.another_was_loaded; true; end
|
30
|
-
HOLA3
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe ".folder" do
|
35
|
-
context "files" do
|
36
|
-
before :all do
|
37
|
-
Piano::ControllerLoader.folder "controllers"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should include the demo file" do
|
41
|
-
Piano.demo_was_loaded.should be
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should not include the .rb file" do
|
45
|
-
expect { Piano.wrong!
|
46
|
-
}.to raise_error(NoMethodError)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should include the in-folder file" do
|
50
|
-
Piano.another_was_loaded.should be
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should not change $LOAD_PATH" do
|
55
|
-
expect { Piano::ControllerLoader.folder "controllers"
|
56
|
-
}.to change{ $LOAD_PATH.length }.by(1)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe ".recursive" do
|
61
|
-
it "should contain the path to the demo file" do
|
62
|
-
flag = false
|
63
|
-
Piano::ControllerLoader.recursive "controllers" do |item|
|
64
|
-
flag = true if item == "controllers/demo"
|
65
|
-
end
|
66
|
-
flag.should be_true
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should not contain the path to the .rb file" do
|
70
|
-
flag = false
|
71
|
-
Piano::ControllerLoader.recursive "controllers" do |item|
|
72
|
-
flag = true if item == "controllers/another"
|
73
|
-
end
|
74
|
-
flag.should_not be_true
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should contain the path to the indented demo file" do
|
78
|
-
flag = false
|
79
|
-
Piano::ControllerLoader.recursive "controllers" do |item|
|
80
|
-
flag = true if item == "controllers/recursive/very/demo2"
|
81
|
-
end
|
82
|
-
flag.should be_true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
after :all do
|
87
|
-
FileUtils.rm_r "controllers"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|