tux 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +22 -0
- data/CHANGELOG.rdoc +2 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +79 -0
- data/Rakefile +35 -0
- data/bin/tux +7 -0
- data/deps.rip +3 -0
- data/lib/tux.rb +19 -0
- data/lib/tux/commands.rb +48 -0
- data/lib/tux/runner.rb +5 -0
- data/lib/tux/version.rb +3 -0
- metadata +127 -0
data/.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless Object.const_defined?(:Gem)
|
3
|
+
require File.dirname(__FILE__) + "/lib/tux/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "tux"
|
7
|
+
s.version = Tux::VERSION
|
8
|
+
s.authors = ["Gabriel Horner"]
|
9
|
+
s.email = "gabriel.horner@gmail.com"
|
10
|
+
s.homepage = "http://github.com/cldwalker/tux"
|
11
|
+
s.summary = "Sinatra dressed for interactive ruby - a sinatra shell"
|
12
|
+
s.description = "Tux dresses up sinatra for interactive use. 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."
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.rubyforge_project = 'tagaholic'
|
15
|
+
s.executables = ['tux']
|
16
|
+
s.add_dependency 'ripl', '>= 0.3.4'
|
17
|
+
s.add_dependency 'ripl-rack', '>= 0.1.0'
|
18
|
+
s.add_dependency 'sinatra', '>= 1.2.1'
|
19
|
+
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
20
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
21
|
+
s.license = 'MIT'
|
22
|
+
end
|
data/CHANGELOG.rdoc
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2011 Gabriel Horner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
== Description
|
2
|
+
Tux dresses up sinatra for interactive use. Use it to interact with your helpers, view rendering and
|
3
|
+
your app's response objects. Tux also gives you commands to view your app's routes and settings.
|
4
|
+
|
5
|
+
== Install
|
6
|
+
Install the gem with:
|
7
|
+
|
8
|
+
gem install tux
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
|
12
|
+
To interact with your helpers:
|
13
|
+
|
14
|
+
$ tux.uri
|
15
|
+
>> app.my_helper_method
|
16
|
+
...
|
17
|
+
|
18
|
+
To interact with any built-in sinatra methods i.e. request and response specific helper
|
19
|
+
methods:
|
20
|
+
|
21
|
+
# depends on request
|
22
|
+
>> app.uri '/'
|
23
|
+
=> "http://:/"
|
24
|
+
|
25
|
+
# depends on response
|
26
|
+
>> app.headers
|
27
|
+
=> {"Content-Type"=>"text/html"}
|
28
|
+
|
29
|
+
For the above to work, tux sets up default empty request and response objects. To try the helpers
|
30
|
+
with your own requests and responses:
|
31
|
+
|
32
|
+
>> app.request = Sinatra::Request.new({})
|
33
|
+
>> app.response = Sinatra::Response.new
|
34
|
+
|
35
|
+
To interact with your views:
|
36
|
+
|
37
|
+
>> app.erb :my_template
|
38
|
+
=> 'template rendered'
|
39
|
+
|
40
|
+
Tux also comes with commands to give you a good overview of your app
|
41
|
+
|
42
|
+
$ tux
|
43
|
+
>> routes
|
44
|
+
HEAD "/"
|
45
|
+
HEAD /book/:id
|
46
|
+
GET "/"
|
47
|
+
GET /book/:id
|
48
|
+
|
49
|
+
>> settings
|
50
|
+
absolute_redirects true
|
51
|
+
add_charset [/^text\//, "application/javascript", "application/xml",
|
52
|
+
"application/xhtml+xml"]
|
53
|
+
app_file "./sample.rb"
|
54
|
+
bind "0.0.0.0"
|
55
|
+
default_encoding "utf-8"
|
56
|
+
dump_errors true
|
57
|
+
empty_path_info nil
|
58
|
+
environment :development
|
59
|
+
lock false
|
60
|
+
logging false
|
61
|
+
method_override false
|
62
|
+
port 4567
|
63
|
+
prefixed_redirects false
|
64
|
+
public "/my/path/public"
|
65
|
+
raise_errors false
|
66
|
+
reload_templates true
|
67
|
+
root "/my/path"
|
68
|
+
run false
|
69
|
+
running false
|
70
|
+
server ["thin", "mongrel", "webrick"]
|
71
|
+
session_secret "XXX"
|
72
|
+
sessions false
|
73
|
+
show_exceptions true
|
74
|
+
static true
|
75
|
+
views "/my/path/views"
|
76
|
+
|
77
|
+
== TODO
|
78
|
+
* Better integration with ripl-rack
|
79
|
+
* Tests
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
def gemspec
|
5
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Build the gem"
|
9
|
+
task :gem=>:gemspec do
|
10
|
+
sh "gem build .gemspec"
|
11
|
+
FileUtils.mkdir_p 'pkg'
|
12
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install the gem locally"
|
16
|
+
task :install => :gem do
|
17
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Generate the gemspec"
|
21
|
+
task :generate do
|
22
|
+
puts gemspec.to_ruby
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Validate the gemspec"
|
26
|
+
task :gemspec do
|
27
|
+
gemspec.validate
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run tests'
|
31
|
+
task :test do |t|
|
32
|
+
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
data/bin/tux
ADDED
data/deps.rip
ADDED
data/lib/tux.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'tux/commands'
|
2
|
+
require 'tux/version'
|
3
|
+
|
4
|
+
module Tux
|
5
|
+
def self.app_class
|
6
|
+
@app_class ||= begin
|
7
|
+
klasses = objects(Class).select {|e| e.superclass == Sinatra::Base }
|
8
|
+
raise "No Sinatra application found" if klasses.empty?
|
9
|
+
klasses.size == 1 ? klasses[0] : (klasses - [Sinatra::Application])[0]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def self.objects(klass)
|
15
|
+
objs = []
|
16
|
+
ObjectSpace.each_object(klass) {|e| objs.push(e) }
|
17
|
+
objs
|
18
|
+
end
|
19
|
+
end
|
data/lib/tux/commands.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'ripl'
|
2
|
+
|
3
|
+
module Tux
|
4
|
+
module Commands
|
5
|
+
SETTINGS = %w{methodoverride inline_templates}
|
6
|
+
|
7
|
+
def routes
|
8
|
+
Tux.app_class.routes.inject([]) {|arr, (k,v)|
|
9
|
+
arr += v.map {|e|
|
10
|
+
[k, (str = e[0].inspect[%r{/\^(.*)\$/}, 1]) ? str.tr('\\', '') : e[0]]
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def settings
|
16
|
+
meths = (class << Tux.app_class; self; end).instance_methods(false).
|
17
|
+
sort.map(&:to_s).select {|e| e[/=$/] }.map {|e| e[0..-2] } - SETTINGS
|
18
|
+
meths.map {|meth| [meth, Tux.app_class.send(meth)] }
|
19
|
+
end
|
20
|
+
|
21
|
+
def app
|
22
|
+
@app ||= begin
|
23
|
+
obj = Tux.app_class.new!
|
24
|
+
obj.request = Sinatra::Request.new({})
|
25
|
+
obj.response = Sinatra::Response.new
|
26
|
+
obj
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module CommandsFormatted
|
32
|
+
def self.format(arr)
|
33
|
+
arr = arr.map {|e| [e[0], e[1].inspect] }
|
34
|
+
max1 = arr.map {|e| e[0].length }.max
|
35
|
+
max2 = arr.map {|e| e[1].length }.max
|
36
|
+
arr.map {|k,v| "%-*s %-*s" % [max1, k, max2, v] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def routes
|
40
|
+
puts CommandsFormatted.format(super)
|
41
|
+
end
|
42
|
+
|
43
|
+
def settings
|
44
|
+
puts CommandsFormatted.format(super)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
Ripl::Commands.include Tux::CommandsFormatted, Tux::Commands
|
data/lib/tux/runner.rb
ADDED
data/lib/tux/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tux
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gabriel Horner
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-04 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ripl
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 3
|
33
|
+
- 4
|
34
|
+
version: 0.3.4
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: ripl-rack
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 27
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 1
|
49
|
+
- 0
|
50
|
+
version: 0.1.0
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: sinatra
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 29
|
62
|
+
segments:
|
63
|
+
- 1
|
64
|
+
- 2
|
65
|
+
- 1
|
66
|
+
version: 1.2.1
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
description: Tux dresses up sinatra for interactive use. 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.
|
70
|
+
email: gabriel.horner@gmail.com
|
71
|
+
executables:
|
72
|
+
- tux
|
73
|
+
extensions: []
|
74
|
+
|
75
|
+
extra_rdoc_files:
|
76
|
+
- README.rdoc
|
77
|
+
- LICENSE.txt
|
78
|
+
files:
|
79
|
+
- lib/tux/commands.rb
|
80
|
+
- lib/tux/runner.rb
|
81
|
+
- lib/tux/version.rb
|
82
|
+
- lib/tux.rb
|
83
|
+
- bin/tux
|
84
|
+
- LICENSE.txt
|
85
|
+
- CHANGELOG.rdoc
|
86
|
+
- README.rdoc
|
87
|
+
- deps.rip
|
88
|
+
- Rakefile
|
89
|
+
- .gemspec
|
90
|
+
has_rdoc: true
|
91
|
+
homepage: http://github.com/cldwalker/tux
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
hash: 23
|
114
|
+
segments:
|
115
|
+
- 1
|
116
|
+
- 3
|
117
|
+
- 6
|
118
|
+
version: 1.3.6
|
119
|
+
requirements: []
|
120
|
+
|
121
|
+
rubyforge_project: tagaholic
|
122
|
+
rubygems_version: 1.3.7
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: Sinatra dressed for interactive ruby - a sinatra shell
|
126
|
+
test_files: []
|
127
|
+
|