webmate 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README.md +138 -23
  2. data/bin/webmate +3 -3
  3. data/lib/webmate/version.rb +1 -1
  4. metadata +4 -5
  5. data/GUIDE.md +0 -115
data/README.md CHANGED
@@ -1,42 +1,147 @@
1
1
  # Webmate
2
2
 
3
- TODO: Write a gem description
3
+ Real-time web applications framework in Ruby, based on WebSockets and EventMachine.
4
4
 
5
- ## Prerequisites
6
- git
7
- mongo
8
- redis
5
+ ## Quick start
9
6
 
10
- sinatra 4.2
11
- to make this, use sinatra-contrib at least 1.4.0 version
12
- Specify in your Gemfile
13
- gem 'sinatra-contrib', git: 'git://github.com/sinatra/sinatra-contrib.git'
7
+ #### 1. Install Webmate gem
14
8
 
15
- ## Installation
9
+ $ gem install webmate
10
+
11
+ #### 2. Run Webmate server
12
+
13
+ $ webmate server
14
+
15
+ #### 3. Run Webmate console
16
+
17
+ $ webmate console
18
+
19
+ #### 4. Show available routes
20
+
21
+ $ rake routes
22
+
23
+ ## Tutorial
24
+
25
+ [Webmate Application Skeleton](https://github.com/webmaterb/webmate-app-skeleton)
26
+
27
+ ### Skeleton
16
28
 
17
- Add this line to your application's Gemfile:
29
+ Gemfile
18
30
 
19
31
  gem 'webmate'
32
+ gem 'slim'
33
+ gem 'sass', group: assets
34
+ gem 'rake'
35
+ gem 'webmate-sprockets'
20
36
 
21
- And then execute:
37
+ config.ru
22
38
 
23
- $ bundle
39
+ require './config/environment'
40
+ if configatron.assets.compile
41
+ map '/assets' do
42
+ run Sinatra::Sprockets.environment
43
+ end
44
+ end
45
+ run ExampleApp
24
46
 
25
- Or install it yourself as:
47
+ config/config.rb
26
48
 
27
- $ gem install webmate
49
+ Webmate::Application.configure do |config|
50
+ # add directory to application load paths
51
+ #config.app.load_paths << ["app/uploaders"]
52
+ config.app.cache_classes = true
53
+ config.assets.compile = false
54
+
55
+ config.websockets.namespace = 'api'
56
+ config.websockets.enabled = true
57
+ config.websockets.port = 9020
58
+ end
59
+
60
+ Webmate::Application.configure(:development) do |config|
61
+ config.app.cache_classes = false
62
+ config.assets.compile = true
63
+ config.websockets.port = 3503
64
+ end
65
+
66
+ config/application.rb
67
+
68
+ require 'digest/sha1'
69
+ require 'base64'
70
+
71
+ class ExampleApp < Webmate::Application
72
+ # do other things)
73
+ end
74
+
75
+ config/environment.rb
76
+
77
+ WEBMATE_ROOT = File.expand_path('.')
78
+ require 'webmate'
79
+
80
+ Dir[File.join(WEBMATE_ROOT, 'app', 'routes', '**', '*.rb')].each do |file|
81
+ require file
82
+ end
28
83
 
29
- ## Usage
84
+ ### Hello world
30
85
 
31
- TODO: Write usage instructions here
86
+ #### 1. Adding routes
32
87
 
33
- start server as
34
- webmate server [-p port]
88
+ # app/routes/homepage_routes.rb
89
+ ExampleApp.define_routes do
90
+ get '/', to: 'pages#index', transport: [:http]
91
+ end
35
92
 
36
- running interactive console
37
- webmate console [environment]
38
- or
39
- webmate console [-e environment]
93
+ #### 2. Adding responder for this route
94
+ # app/responders/base_reponder.rb
95
+ class BaseResponder < Webmate::Responders::Base
96
+ # Available options
97
+ # before_filter :do_something
98
+
99
+ rescue_from Webmate::Responders::ActionNotFound do
100
+ render_not_found
101
+ end
102
+ end
103
+
104
+ # app/responders/pages_reponder.rb
105
+ class PagesResponder < BaseResponder
106
+ include Webmate::Responders::Templates
107
+
108
+ def index
109
+ slim :index, layout: 'application'
110
+ end
111
+ end
112
+
113
+ # app/views/layouts/application.html.slim
114
+
115
+ div
116
+ == yield
117
+
118
+ # app/views/pages/index.html.slim
119
+
120
+ Hello World!
121
+
122
+ #### 3. MongoDB connection
123
+
124
+ # config/mongoid.yml
125
+ development:
126
+ sessions:
127
+ default:
128
+ database: deex_example
129
+ hosts:
130
+ - localhost:27017
131
+
132
+ # config/initializers/mongoid.rb
133
+ Mongoid.load!(File.join(WEBMATE_ROOT, 'config', 'mongoid.yml'))
134
+
135
+ #### 4. Models
136
+
137
+ # app/models/project.rb
138
+ class Project
139
+ include Mongoid::Document
140
+
141
+ field :name
142
+ field :description
143
+ field :status
144
+ end
40
145
 
41
146
  ## Contributing
42
147
 
@@ -45,3 +150,13 @@ running interactive console
45
150
  3. Commit your changes (`git commit -am 'Add some feature'`)
46
151
  4. Push to the branch (`git push origin my-new-feature`)
47
152
  5. Create new Pull Request
153
+
154
+ ## License
155
+
156
+ Licenced under [MIT](http://www.opensource.org/licenses/mit-license.php).
157
+
158
+ ## Thanks for using Webmate!
159
+
160
+ Hope, you'll enjoy Webmate!
161
+
162
+ Cheers, [Droid Labs](http://droidlabs.pro).
data/bin/webmate CHANGED
@@ -42,7 +42,7 @@ opt_parser.parse!
42
42
 
43
43
  command = ARGV.shift
44
44
  case command
45
- when 'server'
45
+ when 'server', 's'
46
46
  #TODO refactor to
47
47
  # require 'lib/commands/server'
48
48
  # with options
@@ -53,7 +53,7 @@ when 'server'
53
53
  cmd += ["-p", options.port.to_s]
54
54
 
55
55
  Thin::Runner.new(cmd).run!
56
- when 'console'
56
+ when 'console', 'c'
57
57
  require 'irb'
58
58
  ENV["RACK_ENV"] ||= ARGV.first || options.environment || 'development'
59
59
  puts "Running Webmate console with env: #{ENV["RACK_ENV"]}"
@@ -61,7 +61,7 @@ when 'console'
61
61
  ARGV.clear
62
62
  IRB.start
63
63
 
64
- when 'generate'
64
+ when 'generate', 'g'
65
65
  puts 'not yet implemented'
66
66
  puts opt_parser
67
67
 
@@ -1,3 +1,3 @@
1
1
  module Webmate
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
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: 2013-05-07 00:00:00.000000000 Z
12
+ date: 2013-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thin
@@ -196,7 +196,6 @@ extensions: []
196
196
  extra_rdoc_files: []
197
197
  files:
198
198
  - .gitignore
199
- - GUIDE.md
200
199
  - Gemfile
201
200
  - LICENSE.txt
202
201
  - README.md
@@ -271,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
270
  version: '0'
272
271
  segments:
273
272
  - 0
274
- hash: 3263911598223733394
273
+ hash: -655409542714730364
275
274
  required_rubygems_version: !ruby/object:Gem::Requirement
276
275
  none: false
277
276
  requirements:
@@ -280,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
279
  version: '0'
281
280
  segments:
282
281
  - 0
283
- hash: 3263911598223733394
282
+ hash: -655409542714730364
284
283
  requirements: []
285
284
  rubyforge_project:
286
285
  rubygems_version: 1.8.25
data/GUIDE.md DELETED
@@ -1,115 +0,0 @@
1
- #webmate app skeleton
2
- see working example on https://github.com/evgeniypetrov/webmate-app-skeleton
3
-
4
- ## Quick start
5
-
6
- to start application, run
7
- webmate start
8
- application will be available on localhost:3000 url
9
-
10
- to run irb/console
11
- webmate console
12
-
13
- type webmate without params to know all options
14
-
15
- show all available routes [ without assets ]
16
- rake routes k
17
-
18
- ## Tutorial
19
- ### Skeleton
20
- require files
21
-
22
- to create file, add following gem to Gemfile
23
-
24
- Gemfile
25
- gem 'webmate'
26
- gem 'slim'
27
- gem 'sass', group: assets
28
- gem 'alphasights-sinatra-sprockets', require: 'sinatra-sprockets', group: assets
29
-
30
- base required files:
31
-
32
- config.ru
33
- require './config/environment'
34
- if configatron.assets.compile
35
- map '/assets' do
36
- run Sinatra::Sprockets.environment
37
- end
38
- end
39
- run ExampleApp
40
-
41
- config/config.rb
42
- Webmate::Application.configure do |config|
43
- # add directory to application load paths
44
- #config.app.load_paths << ["app/uploaders"]
45
- config.app.cache_classes = true
46
- config.assets.compile = false
47
-
48
- config.websockets.namespace = 'api'
49
- config.websockets.enabled = true
50
- config.websockets.port = 9020
51
- end
52
-
53
- Webmate::Application.configure(:development) do |config|
54
- config.app.cache_classes = false
55
- config.assets.compile = true
56
- config.websockets.port = 3503
57
- end
58
-
59
- config/application.rb
60
- require 'digest/sha1'
61
- require 'base64'
62
-
63
- class ExampleApp < Webmate::Application
64
- # do other things)
65
- end
66
-
67
- config/environment.rb
68
- WEBMATE_ROOT = File.expand_path('.')
69
- require 'webmate'
70
-
71
- Dir[File.join(WEBMATE_ROOT, 'app', 'routes', '**', '*.rb')].each do |file|
72
- require file
73
- end
74
-
75
- ### Hello world
76
- adding route
77
- app/routes/facade_routes.rb
78
- ExampleApp.define_routes do
79
- get '/', to: 'pages#index', transport: [:http]
80
- end
81
-
82
- adding responder to this route
83
- create files in app/responders
84
- base_responder
85
- class BaseResponder < Webmate::Responders::Base
86
- # Available options
87
- # before_filter :do_something
88
-
89
- rescue_from Webmate::Responders::ActionNotFound do
90
- render_not_found
91
- end
92
- end
93
-
94
- pages_responder
95
- class PagesResponder < BaseResponder
96
- include Webmate::Responders::Templates
97
-
98
- def index
99
- slim :index, layout: 'application'
100
- end
101
- end
102
-
103
- also, required files
104
- app/views/layouts/application.html.slim
105
- app/views/pages/index.html.slim
106
-
107
- ### Assets
108
- assets will be searched in app/assets folder, so place them to
109
- app/assets/javascripts
110
- app/assets/stylesheets
111
-
112
- ### Utilities - rake task, scripts
113
- Rakefile
114
- require File.expand_path('../config/environment', __FILE__)
115
- Webmate::Application.load_tasks