socks 0.1.9.beta → 0.1.10.beta

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/bin/socks ADDED
@@ -0,0 +1,230 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+ require 'socks'
6
+ require 'fileutils'
7
+
8
+ program :version, Socks::VERSION
9
+ program :description, 'A Ruby-Rack-based microframework'
10
+
11
+ default_command :about
12
+
13
+ command :new do |c|
14
+ c.syntax = 'socks new [options]'
15
+ c.summary = 'Create a new Socks app'
16
+ c.description = 'Use Rack and other utilities to make a new Socks app from scratch'
17
+ c.action do |args, opt|
18
+
19
+ # Pull out the first arg in args[]
20
+ app = args[0]
21
+
22
+ # -------------------------------------------------------------------------
23
+ # File Contents |
24
+ # -------------------------------------------------------------------------
25
+
26
+ config_ru = "# config.ru is used for running rack-based applications. Please do not edit this file without proper understanding of Rack
27
+ # or some bad things may happen.
28
+
29
+
30
+ # Bundler setup
31
+ require \"bundler/setup\"
32
+ Bundler.setup
33
+
34
+ # http_router
35
+ require File.expand_path(\"../config/router.rb\", __FILE__)
36
+
37
+ # Controllers
38
+ Dir[\"../app/controllers\" + \"*.rb\"].each do |file|
39
+ require file
40
+ end
41
+
42
+ # Used so Rack can automatically get updated to file contents without
43
+ # a ten second cooldown
44
+ use Rack::Reloader, 0
45
+
46
+ # Used to run your router (app!)
47
+ # Go to config/router.rb to declare routes
48
+ run #{app.capitalize}::Router"
49
+
50
+ gemfile = "# List dependencies for your app in your Gemfile, then run the `bundle` command
51
+
52
+ source \"http://rubygems.org\"
53
+
54
+ # Socks itself!
55
+ gem \"socks\", \"~> #{Socks::VERSION}\"
56
+
57
+ # Rack HTTP
58
+ gem \"rack\"
59
+
60
+ # Startup your server with thin
61
+ gem \"thin\"
62
+
63
+ # Or use Foreman
64
+ gem \"foreman\"
65
+
66
+ # Use HttpRouter for routes (required)
67
+ gem \"http_router\"
68
+
69
+ # Mange todos, fixmes, etc. via tasks.rb with do_it
70
+ gem \"do_it\"
71
+
72
+ # Use Warden for authentication
73
+ # gem \"warden\"
74
+
75
+ group :development, :test do
76
+ # Use RSpec for tests
77
+ gem \"rspec\"
78
+
79
+ # Use Capybara to replicate the user
80
+ gem \"capybara\"
81
+ end"
82
+
83
+ rakefile = "# Socks generates many helpful Rake tasks for you!
84
+ require \"socks\"
85
+ Socks::Tasks.install"
86
+
87
+ gitignore = ".DS_Store
88
+ Gemfile.lock"
89
+
90
+ procfile = "web: bundle exec rackup config.ru -p 4000"
91
+
92
+ app_template = "require \"socks\""
93
+
94
+ router_template = "# Declare the paths to your routes here.
95
+ require \"http_router\"
96
+ require \"socks\"
97
+
98
+ module #{app.capitalize}
99
+ Router = HttpRouter.new do
100
+
101
+ # See what you can do at https://github.com/joshbuddy/http_router
102
+
103
+ end
104
+ end
105
+ "
106
+
107
+ config_template = "# Setup your main configuration here.
108
+
109
+ Socks.configure do |config|
110
+ end"
111
+
112
+ ########################
113
+ # Spec-helper template #
114
+ ########################
115
+
116
+ spec_helper = "# Default helpers for your specs are added here
117
+ require \"rspec\"
118
+ require \"rspec-socks\"
119
+ require \"rack\"
120
+ "
121
+
122
+ dotrspec = "--color
123
+ --format documentation"
124
+
125
+ tasks = "# Put app TODOS, FIXMES, and/or NOTES in here.
126
+ require \"do_it\"
127
+
128
+ app = DoIt.new do
129
+ # See what you can do at https://github.com/Beakr/do_it
130
+ end
131
+
132
+ app.list # Format list"
133
+
134
+
135
+ # -------------------------------------------------------------------------
136
+ # Creation |
137
+ # -------------------------------------------------------------------------
138
+
139
+ FileUtils.mkdir app
140
+ FileUtils.cd app
141
+ FileUtils.mkdir %w( config spec )
142
+ FileUtils.touch %w( spec/spec_helper.rb .rspec ) # Spec file(s)
143
+ FileUtils.touch %w( Dofile ) # Todo manager
144
+ FileUtils.touch %w( config/app_config.rb )
145
+
146
+ # -------------------------------------------------------------------------
147
+ # File Initialization |
148
+ # -------------------------------------------------------------------------
149
+
150
+
151
+ system("echo '#{config_ru}' >> config.ru")
152
+ system("echo '#{gemfile}' >> Gemfile")
153
+ system("echo '#{rakefile}' >> Rakefile")
154
+
155
+ system("echo '#{gitignore}' >> .gitignore")
156
+ system("echo '#{procfile}' >> Procfile")
157
+ system("echo '#{tasks}' >> Dofile")
158
+
159
+ system("echo '#{router_template}' >> config/router.rb")
160
+ system("echo '#{config_template}' >> config/app_config.rb")
161
+
162
+ system("echo '#{spec_helper}' >> spec/spec_helper.rb")
163
+ system("echo '#{dotrspec}' >> .rspec")
164
+
165
+ system("bundle")
166
+
167
+ end
168
+ end
169
+
170
+ command :controller do |c|
171
+ c.syntax = 'socks controller [options]'
172
+ c.description = 'Create a template for something'
173
+ c.action do |args, options|
174
+ cont = args[0]
175
+
176
+ cont_template = "# Specify pages in the controller
177
+
178
+ # e.g.
179
+ #
180
+ # def index
181
+ # \"This is a socks app!\"
182
+ # end
183
+ #
184
+
185
+ class #{cont.capitalize}Controller < Socks::BaseController
186
+ # ...
187
+ end
188
+ "
189
+
190
+ FileUtils.touch "app/controllers/#{cont}_controller.rb"
191
+ system("echo '#{cont_template}' >> app/controllers/#{cont}_controller.rb")
192
+
193
+ end
194
+ end
195
+
196
+ command :start do |c|
197
+ c.syntax = 'socks start [options]'
198
+ c.description = 'Startup a Rack server'
199
+ c.action do |args, options|
200
+ system('foreman start') # Startup server including code in lib/ that runs on port 4000
201
+ notify "Socks server is up"
202
+ end
203
+ end
204
+
205
+ command :test do |c|
206
+ c.syntax = 'socks test [options]'
207
+ c.description = 'Run tests with RSpec'
208
+ c.action do |args, options|
209
+ system('rspec .')
210
+ end
211
+ end
212
+
213
+ command :version do |c|
214
+ c.syntax = 'socks version [options]'
215
+ c.description = 'Display the current version (altertative to --version)'
216
+ c.action do |args, options|
217
+ Socks::VERSION
218
+ end
219
+ end
220
+
221
+ command :about do |c|
222
+ c.syntax = 'socks about [options]'
223
+ c.action do |args, options|
224
+ system("echo \"\e[32m Usage: socks new APP_NAME\"")
225
+ end
226
+ end
227
+
228
+ # -------------------------------------------------------------------------
229
+ # Helpers |
230
+ # -------------------------------------------------------------------------
data/lib/socks/router.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'socks/router_helpers'
2
2
 
3
3
  module Socks
4
+
5
+ # This class is used as helpers, misc methods, etc. for the App:Router class
6
+ # generated in your app.
4
7
  class Router
5
8
  include Socks::RouterHelpers
6
9
  end
@@ -1,9 +1,17 @@
1
1
  # General helpers for the Socks router
2
2
 
3
3
  module Socks
4
+
5
+ # This class is purely of helper methods for the Socks App::Router generated in
6
+ # router.rb of your Socks app.
4
7
  module RouterHelpers
8
+
9
+ # Takes the pain of filling in a text content-type for you
10
+ # @param [String] The string to display
11
+ # @return [text] The text rendered onto the screen
5
12
  def txt(str)
6
13
  return [200, {'Content-type' => 'text/plain'}, ["#{str}"]]
7
14
  end
15
+
8
16
  end
9
17
  end
data/lib/socks/version.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  module Socks
2
- VERSION = "0.1.9.beta"
2
+
3
+ # The current version of Socks
4
+ VERSION = "0.1.10.beta"
5
+
3
6
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: socks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9.beta
5
- prerelease: 6
4
+ version: 0.1.10.beta
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Chris Clarke
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-03 00:00:00.000000000 Z
12
+ date: 2012-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -139,13 +139,31 @@ dependencies:
139
139
  - - ! '>='
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: do_it
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
142
158
  description: An in-development web framework using Rack.
143
159
  email:
144
160
  - beakr@ninjanizr.com
145
- executables: []
161
+ executables:
162
+ - socks
146
163
  extensions: []
147
164
  extra_rdoc_files: []
148
165
  files:
166
+ - bin/socks
149
167
  - lib/socks.rb
150
168
  - lib/socks/version.rb
151
169
  - lib/socks/config.rb