tux 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +2 -0
- data/CHANGELOG.rdoc +6 -0
- data/README.rdoc +0 -3
- data/lib/tux/commands.rb +6 -4
- data/lib/tux/version.rb +1 -1
- data/test/commands_test.rb +46 -0
- data/test/deps.rip +2 -0
- data/test/test_helper.rb +19 -0
- metadata +39 -4
data/.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency 'ripl-rack', '>= 0.2.0'
|
18
18
|
s.add_dependency 'ripl-multi_line', '>= 0.2.4'
|
19
19
|
s.add_dependency 'sinatra', '>= 1.2.1'
|
20
|
+
s.add_development_dependency 'bacon', '>= 1.1.0'
|
21
|
+
s.add_development_dependency 'bacon-bits', '>= 0.1.0'
|
20
22
|
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
21
23
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
22
24
|
s.license = 'MIT'
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -111,6 +111,3 @@ Tux also comes with commands to give you a good overview of your app
|
|
111
111
|
Since tux is a {ripl shell}[http://github.com/cldwalker/ripl], tux is highly configurable. You can
|
112
112
|
create tux commands in the format tux-COMMAND and enhance your shell by adding ripl plugins to
|
113
113
|
~/.riplrc. Read {ripl's readme}[http://github.com/cldwalker/ripl#readme] for more.
|
114
|
-
|
115
|
-
== TODO
|
116
|
-
* Tests
|
data/lib/tux/commands.rb
CHANGED
@@ -4,16 +4,18 @@ module Tux
|
|
4
4
|
|
5
5
|
def routes
|
6
6
|
Tux.app_class.routes.inject([]) {|arr, (k,v)|
|
7
|
-
arr += v.map {|
|
8
|
-
|
7
|
+
arr += v.map {|regex,params,*|
|
8
|
+
path = params.empty? ? regex.inspect :
|
9
|
+
params.inject(regex.inspect) {|s,e| s.sub(/\([^()]+\)/, ":#{e}") }
|
10
|
+
[k, (str = path[%r{/\^(.*)\$/}, 1]) ? str.tr('\\', '') : path]
|
9
11
|
}
|
10
12
|
}
|
11
13
|
end
|
12
14
|
|
13
15
|
def settings
|
14
|
-
meths = (
|
16
|
+
meths = (Tux.app_class.methods(false) + Sinatra::Base.methods(false)).
|
15
17
|
sort.map(&:to_s).select {|e| e[/=$/] }.map {|e| e[0..-2] } - SETTINGS
|
16
|
-
meths.map {|meth| [meth, Tux.app_class.send(meth)] }
|
18
|
+
meths.map {|meth| [meth, (Tux.app_class.send(meth) rescue $!.inspect)] }
|
17
19
|
end
|
18
20
|
|
19
21
|
def app
|
data/lib/tux/version.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
describe Tux::Commands do
|
4
|
+
def ripl
|
5
|
+
@ripl ||= Object.new.extend(Tux::Commands)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#app" do
|
9
|
+
it "is an instance of the sinatra app" do
|
10
|
+
ripl.app.class.should == Tux.app_class
|
11
|
+
end
|
12
|
+
|
13
|
+
it "can call a helper method" do
|
14
|
+
ripl.app.moo('man').should == 'moo-man'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "can call render methods" do
|
18
|
+
ripl.app.respond_to?(:erb, true).should == true
|
19
|
+
ripl.app.respond_to?(:render, true).should == true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#settings" do
|
24
|
+
it "retrieves default setting" do
|
25
|
+
ripl.settings.assoc('absolute_redirects')[1].should == true
|
26
|
+
end
|
27
|
+
|
28
|
+
it "retrieves app-specific setting" do
|
29
|
+
ripl.settings.assoc('root')[1].should == 'dir'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "retrieves failing setting" do
|
33
|
+
ripl.settings.assoc('ka')[1].should =~ /boom/
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#routes" do
|
38
|
+
it "retrieves string path" do
|
39
|
+
ripl.routes.assoc('GET')[1].should == '/'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "retrieves path with params" do
|
43
|
+
ripl.routes.assoc('POST')[1].should == "/:id/:format"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/test/deps.rip
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bacon'
|
2
|
+
require 'bacon/bits'
|
3
|
+
require 'tux'
|
4
|
+
require 'sinatra/base'
|
5
|
+
|
6
|
+
class TestApp < Sinatra::Base
|
7
|
+
helpers do
|
8
|
+
def moo(str)
|
9
|
+
"moo-#{str}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
set :root, 'dir'
|
14
|
+
set :ka, lambda { raise 'boom' }
|
15
|
+
|
16
|
+
get '/' do end
|
17
|
+
|
18
|
+
post '/:id/:format' do end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gabriel Horner
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-10 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -82,6 +82,38 @@ dependencies:
|
|
82
82
|
version: 1.2.1
|
83
83
|
type: :runtime
|
84
84
|
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: bacon
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 19
|
94
|
+
segments:
|
95
|
+
- 1
|
96
|
+
- 1
|
97
|
+
- 0
|
98
|
+
version: 1.1.0
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id005
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: bacon-bits
|
103
|
+
prerelease: false
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
hash: 27
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
- 1
|
113
|
+
- 0
|
114
|
+
version: 0.1.0
|
115
|
+
type: :development
|
116
|
+
version_requirements: *id006
|
85
117
|
description: Tux dresses up sinatra in a shell. Use it to interact with your helpers, view rendering and your app's response objects. Tux also gives you commands to view your app's routes and settings.
|
86
118
|
email: gabriel.horner@gmail.com
|
87
119
|
executables:
|
@@ -97,11 +129,14 @@ files:
|
|
97
129
|
- lib/tux/runner.rb
|
98
130
|
- lib/tux/version.rb
|
99
131
|
- lib/tux.rb
|
132
|
+
- test/commands_test.rb
|
133
|
+
- test/test_helper.rb
|
100
134
|
- bin/tux
|
101
135
|
- LICENSE.txt
|
102
136
|
- CHANGELOG.rdoc
|
103
137
|
- README.rdoc
|
104
138
|
- deps.rip
|
139
|
+
- test/deps.rip
|
105
140
|
- Rakefile
|
106
141
|
- .gemspec
|
107
142
|
has_rdoc: true
|