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 CHANGED
@@ -1,3 +1,7 @@
1
+ - 0.0.7.beta
2
+ * Got server running
3
+ * Cleaned up app structure
4
+
1
5
  - 0.0.5.alpha
2
6
  * Executable created
3
7
  * README creation and testing
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
@@ -3,6 +3,7 @@ require "bundler/gem_tasks"
3
3
  require "rspec/core/rake_task"
4
4
 
5
5
  task :default => [ :spec ]
6
+ task :test => [ :spec ]
6
7
 
7
8
  desc 'Run RSpec tests'
8
9
  RSpec::Core::RakeTask.new
data/TODO.md ADDED
@@ -0,0 +1,7 @@
1
+ TODO
2
+ ====
3
+
4
+ * Make Rack actually render route contents
5
+ * Add templates for erb, markdown, possibly HAML, etc.
6
+ * Add assets with CSS or SASS support and Javascript and possibly Coffeescript
7
+ support
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 'bundler'
29
+ require \"bundler/setup\"
31
30
  Bundler.setup
32
- Bundler.require
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 for automatically getting stylesheet and javascript data into
39
- # your markup templates, as well as running the app.
40
- run Rack::Cascade.new([Rack::File.new('assets'), #{app.capitalize}])"
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
- # gem \"foreman\"
62
+ gem \"foreman\"
57
63
 
58
- # Use Usher for routes (required)
59
- gem 'usher'
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( views assets app )
78
- FileUtils.touch "#{app}.rb"
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('rackup -Ilib -p 4000') # Startup server including code in lib/ that runs on port 4000
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
@@ -1,3 +1,3 @@
1
1
  module Socks
2
- VERSION = "0.0.5.alpha"
2
+ VERSION = "0.0.7.beta"
3
3
  end
data/lib/socks.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "socks/version"
2
+ require "socks/base_controller"
2
3
  require "socks/templates"
3
4
 
4
5
  module Socks
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
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  # Rack HTTP
19
19
  gem.add_dependency "rack"
20
- gem.add_dependency "usher"
20
+ gem.add_dependency "http_router"
21
21
 
22
22
  gem.add_development_dependency "rake"
23
23
  gem.add_development_dependency "rspec"
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.5.alpha
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-28 00:00:00.000000000 Z
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: usher
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: []