socks 0.0.5.alpha → 0.0.7.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/TODO.md +7 -0
- data/bin/socks +62 -13
- data/lib/socks/base_controller.rb +20 -0
- data/lib/socks/version.rb +1 -1
- data/lib/socks.rb +1 -0
- data/skel/config_ru +17 -0
- data/socks.gemspec +1 -1
- metadata +6 -3
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -41,6 +41,10 @@ $ socks start
|
|
41
41
|
|
42
42
|
See LICENSE (MIT).
|
43
43
|
|
44
|
+
## TODO
|
45
|
+
|
46
|
+
See TODO.md
|
47
|
+
|
44
48
|
## Thanks
|
45
49
|
|
46
50
|
I'd like to thank [Sickill](https://github.com/sickill) for his amazing Rack web framework tutorial. Without it, it would be a much harder time getting Socks to work!
|
data/Rakefile
CHANGED
data/TODO.md
ADDED
data/bin/socks
CHANGED
@@ -24,20 +24,26 @@ command :new do |c|
|
|
24
24
|
config_ru = "# config.ru is used for running rack-based applications. Please do not edit this file without proper understanding of Rack
|
25
25
|
# or some bad things may happen.
|
26
26
|
|
27
|
-
require \"#{app}\"
|
28
27
|
|
29
28
|
# Bundler setup
|
30
|
-
require
|
29
|
+
require \"bundler/setup\"
|
31
30
|
Bundler.setup
|
32
|
-
|
31
|
+
|
32
|
+
# http_router
|
33
|
+
require File.expand_path(\"../config/router.rb\", __FILE__)
|
34
|
+
|
35
|
+
# Controllers
|
36
|
+
Dir[\"#{app}/app/controllers\" + \"*.rb\"].each do |file|
|
37
|
+
require file
|
38
|
+
end
|
33
39
|
|
34
40
|
# Used so Rack can automatically get updated to file contents without
|
35
41
|
# a ten second cooldown
|
36
42
|
use Rack::Reloader, 0
|
37
43
|
|
38
|
-
# Used
|
39
|
-
#
|
40
|
-
run
|
44
|
+
# Used to run your router (app!)
|
45
|
+
# Go to config/router.rb to declare routes
|
46
|
+
run #{app.capitalize}::Router"
|
41
47
|
|
42
48
|
gemfile = "# List dependencies for your app in your Gemfile, then run the `bundle` command
|
43
49
|
|
@@ -53,10 +59,10 @@ gem \"rack\"
|
|
53
59
|
gem \"thin\"
|
54
60
|
|
55
61
|
# Or use Foreman
|
56
|
-
|
62
|
+
gem \"foreman\"
|
57
63
|
|
58
|
-
# Use
|
59
|
-
gem
|
64
|
+
# Use HttpRouter for routes (required)
|
65
|
+
gem \"http_router\"
|
60
66
|
|
61
67
|
# Use Warden for authentication
|
62
68
|
# gem \"warden\"
|
@@ -66,17 +72,28 @@ gem \"rspec\""
|
|
66
72
|
|
67
73
|
gitignore = ".DS_Store"
|
68
74
|
|
75
|
+
procfile = "web: bundle exec rackup config.ru -p 4000"
|
76
|
+
|
69
77
|
app_template = "require \"socks\""
|
70
78
|
|
79
|
+
router_template = "# Declare the paths to your routes here.
|
80
|
+
require \"http_router\"
|
81
|
+
module #{app.capitalize}
|
82
|
+
Router = HttpRouter.new do
|
83
|
+
# See what you can do at https://github.com/joshbuddy/http_router
|
84
|
+
end
|
85
|
+
end
|
86
|
+
"
|
87
|
+
|
71
88
|
# -------------------------------------------------------------------------
|
72
89
|
# Creation |
|
73
90
|
# -------------------------------------------------------------------------
|
74
91
|
|
75
92
|
FileUtils.mkdir app
|
76
93
|
FileUtils.cd app
|
77
|
-
FileUtils.mkdir %w(
|
78
|
-
FileUtils.
|
79
|
-
FileUtils.touch %w( config.ru Gemfile .gitignore )
|
94
|
+
FileUtils.mkdir %w( app config )
|
95
|
+
FileUtils.mkdir %w( app/controllers app/views ) # Sub-dirs
|
96
|
+
FileUtils.touch %w( config.ru Gemfile .gitignore Procfile )
|
80
97
|
|
81
98
|
# -------------------------------------------------------------------------
|
82
99
|
# File Initialization |
|
@@ -86,9 +103,38 @@ gem \"rspec\""
|
|
86
103
|
system("echo '#{config_ru}' >> config.ru")
|
87
104
|
system("echo '#{gemfile}' >> Gemfile")
|
88
105
|
system("echo '#{gitignore}' >> .gitignore")
|
106
|
+
system("echo '#{procfile}' >> Procfile")
|
89
107
|
|
90
108
|
system("echo '#{app_template}' >> #{app}.rb")
|
91
109
|
|
110
|
+
system("echo '#{router_template}' >> config/router.rb")
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
command :controller do |c|
|
116
|
+
c.syntax = 'socks controller [options]'
|
117
|
+
c.description = 'Create a template for something'
|
118
|
+
c.action do |args, options|
|
119
|
+
cont = args[0]
|
120
|
+
|
121
|
+
cont_template = "# Specify pages in the controller
|
122
|
+
|
123
|
+
# e.g.
|
124
|
+
#
|
125
|
+
# def index
|
126
|
+
# \"This is a socks app!\"
|
127
|
+
# end
|
128
|
+
#
|
129
|
+
|
130
|
+
class #{cont.capitalize}Controller < Socks::BaseController
|
131
|
+
# ...
|
132
|
+
end
|
133
|
+
"
|
134
|
+
|
135
|
+
FileUtils.touch "app/controllers/#{cont}_controller.rb"
|
136
|
+
system("echo '#{cont_template}' >> app/controllers/#{cont}_controller.rb")
|
137
|
+
|
92
138
|
end
|
93
139
|
end
|
94
140
|
|
@@ -96,7 +142,7 @@ command :start do |c|
|
|
96
142
|
c.syntax = 'socks start [options]'
|
97
143
|
c.description = 'Startup a Rack server'
|
98
144
|
c.action do |args, options|
|
99
|
-
system('
|
145
|
+
system('foreman start') # Startup server including code in lib/ that runs on port 4000
|
100
146
|
end
|
101
147
|
end
|
102
148
|
|
@@ -108,3 +154,6 @@ command :version do |c|
|
|
108
154
|
end
|
109
155
|
end
|
110
156
|
|
157
|
+
# -------------------------------------------------------------------------
|
158
|
+
# Helpers |
|
159
|
+
# -------------------------------------------------------------------------
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rack'
|
2
|
+
|
3
|
+
module Socks
|
4
|
+
class BaseController
|
5
|
+
def call(env)
|
6
|
+
@request = Rack::Request.new(env)
|
7
|
+
@response = Rack::Response.new
|
8
|
+
resp_text = self.send(env['x-rack.action-name'])
|
9
|
+
@response.write(resp_text)
|
10
|
+
@respone.finish
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.action(name)
|
14
|
+
lambda do |env|
|
15
|
+
env['x-rack.action-name'] = name
|
16
|
+
self.new.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/socks/version.rb
CHANGED
data/lib/socks.rb
CHANGED
data/skel/config_ru
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# config.ru is used for running rack-based applications. Please do not edit this file without proper understanding of Rack
|
2
|
+
# or some bad things may happen.
|
3
|
+
|
4
|
+
require \"#{app}\"
|
5
|
+
|
6
|
+
# Bundler setup
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup
|
9
|
+
Bundler.require
|
10
|
+
|
11
|
+
# Used so Rack can automatically get updated to file contents without
|
12
|
+
# a ten second cooldown
|
13
|
+
use Rack::Reloader, 0
|
14
|
+
|
15
|
+
# Used for automatically getting stylesheet and javascript data into
|
16
|
+
# your markup templates, as well as running the app.
|
17
|
+
run Rack::Cascade.new([Rack::File.new('assets'), #{app.capitalize}])
|
data/socks.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7.beta
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: http_router
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
@@ -123,10 +123,13 @@ files:
|
|
123
123
|
- LICENSE
|
124
124
|
- README.md
|
125
125
|
- Rakefile
|
126
|
+
- TODO.md
|
126
127
|
- bin/socks
|
127
128
|
- lib/socks.rb
|
129
|
+
- lib/socks/base_controller.rb
|
128
130
|
- lib/socks/templates.rb
|
129
131
|
- lib/socks/version.rb
|
132
|
+
- skel/config_ru
|
130
133
|
- socks.gemspec
|
131
134
|
homepage: ''
|
132
135
|
licenses: []
|