modularize_sinatra 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -1,24 +1,78 @@
1
- # ModularizeSinatra
1
+ # Modularize Sinatra
2
2
 
3
- TODO: Write a gem description
3
+ Modularized Code Generator for Sinatra. Gem available on [rubygems](https://rubygems.org/gems/modularize_sinatra)
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ $ gem install modularize_sinatra
8
8
 
9
- gem 'modularize_sinatra'
9
+ ## Usage
10
10
 
11
- And then execute:
11
+ To generate the skeleton structure with custom controller:
12
12
 
13
- $ bundle
13
+ modularize_sinatra myapp -C user
14
14
 
15
- Or install it yourself as:
15
+ To Start the app:
16
+
17
+ rackup -p 9000
16
18
 
17
- $ gem install modularize_sinatra
19
+ It will generate a default index page for you, which can be accessed at:
20
+
21
+ http://localhost:9292/
18
22
 
19
- ## Usage
23
+ You'll get the following directory structure with above command:
24
+
25
+ .
26
+ |-- Gemfile
27
+ |-- Gemfile.lock
28
+ |-- Rakefile
29
+ |-- config
30
+ | `-- environment.rb
31
+ |-- config.ru
32
+ |-- lib
33
+ | |-- app.rb
34
+ | |-- controllers
35
+ | | `-- user.rb
36
+ | `-- views
37
+ | `-- users
38
+ | `-- index.erb
39
+ |-- my_app.rb
40
+ |-- public
41
+ |-- script
42
+ | |-- destroy
43
+ | `-- generate
44
+ |-- spec
45
+ | |-- controllers
46
+ | | `-- controller_spec.rb
47
+ | |-- spec_helper.rb
48
+ | `-- support
49
+ `-- tmp
50
+
51
+ Without the `-C` paramter( **not recommended** ), it will generate a default controller for you called `Ping` and will create the following route:
52
+
53
+ GET http://localhost:9292/ping
54
+ > Ahoy! from Myapp 2013-04-07 00:33:58 +0530
20
55
 
21
- TODO: Write usage instructions here
56
+ **You can remove the defult scripts `destroy, generate` generated in script folder.**
57
+
58
+ Currently `rspec` is configured by default. Hope to release support for other frameworks in future versions.
59
+
60
+ To Run specs:
61
+
62
+ bundle exec rake
63
+
64
+ ## TODO
65
+
66
+ 1. Support for active record.
67
+ 2. More testing frameworks.
68
+ 3. Remove default scripts generated.
69
+ 4. Refactoring
70
+
71
+ ## Authors
72
+
73
+ * [about.me](http://about.me/goyalankit)
74
+ * [@_goyalankit](http://twitter.com/_goyalankit)
75
+ * [more projects](http://goyalankit.com/labs)
22
76
 
23
77
  ## Contributing
24
78
 
@@ -27,3 +81,4 @@ TODO: Write usage instructions here
27
81
  3. Commit your changes (`git commit -am 'Added some feature'`)
28
82
  4. Push to the branch (`git push origin my-new-feature`)
29
83
  5. Create new Pull Request
84
+
@@ -43,6 +43,8 @@ class ModularizeSinatraGenerator < RubiGen::Base
43
43
  else
44
44
  m.template "lib/controllers/controller.rb", "lib/controllers/#{controller_name}.rb"
45
45
  m.template "spec/controllers/controller_spec.rb", "spec/controllers/controller_spec.rb"
46
+ m.directory "lib/views/#{controller_name.pluralize}"
47
+ m.template "lib/views/index.erb", "lib/views/#{controller_name.pluralize}/index.erb"
46
48
  end
47
49
 
48
50
  m.dependency "install_rubigen_scripts", [destination_root, 'modularize_sinatra'], :shebang => options[:shebang], :collision => :force
@@ -79,6 +81,7 @@ EOS
79
81
  BASEDIRS = %w(
80
82
  config
81
83
  lib/controllers
84
+ lib/views
82
85
  public
83
86
  spec/controllers
84
87
  spec/support
@@ -1,8 +1,12 @@
1
1
  class <%= module_name %>::Controllers::<%= controller_module_name %> < Sinatra::Base
2
2
 
3
- # add your own routes TODO
4
- # get '/' do
5
- # end
3
+ #set view directory as /views/<%= controller_name.pluralize %> for this controller views
4
+ set :views, File.join(root, '../views/<%= controller_name.pluralize %>' )
5
+
6
+ # add your own routes TODO
7
+ get '/' do
8
+ erb :index
9
+ end
6
10
 
7
11
  end
8
12
 
@@ -0,0 +1,34 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+
3
+ <html xmlns="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <style> body { background: #474747 url(bg.png); } h2 { font: 70px Tahoma, Helvetica, Arial, Sans-Serif; text-align: center; color: #222; text-shadow: 0px 2px 3px #555; }
7
+
8
+ pre {
9
+ width: 500px; margin: 0 auto; background: #222; padding: 20px;
10
+ font-size: 22px; color: #555; text-shadow: 0px 2px 3px #171717;
11
+ -webkit-box-shadow: 0px 2px 3px #555;
12
+ -moz-box-shadow: 0px 2px 3px #555;
13
+ -webkit-border-radius: 10px;
14
+ -moz-border-radius: 10px;
15
+ }
16
+
17
+ a{
18
+ text-decoration: none;
19
+ }
20
+
21
+ </style>
22
+ <title>Modularized Sinatra</title>
23
+ <a href="http://modularize-sinatra.goyalankit.com"><h2> Modularized Sinatra </h2></a>
24
+ </head>
25
+ <body>
26
+ <pre>
27
+ Sample Page. Add your own
28
+ Gem Created by: <a href="http://github.com/goyalankit">Ankit Goyal</a>
29
+ </pre>
30
+ </body>
31
+
32
+ </html>
33
+
34
+
@@ -1,3 +1,3 @@
1
1
  module ModularizeSinatra
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ankit Goyal
@@ -67,6 +67,7 @@ files:
67
67
  - lib/modularize_sinatra/templates/lib/app.rb
68
68
  - lib/modularize_sinatra/templates/lib/controllers/controller.rb
69
69
  - lib/modularize_sinatra/templates/lib/controllers/ping.rb
70
+ - lib/modularize_sinatra/templates/lib/views/index.erb
70
71
  - lib/modularize_sinatra/templates/module.rb
71
72
  - lib/modularize_sinatra/templates/spec/controllers/controller_spec.rb
72
73
  - lib/modularize_sinatra/templates/spec/controllers/ping_spec.rb