simplerb 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19849c1f73fdbd96fadb77b33b646879b59ad2fd
4
- data.tar.gz: b7f7f739403ef1851547724c1e22366bc2c6d79d
3
+ metadata.gz: 46c7ce1b03cdef23e4ee698a85f86c12f457093d
4
+ data.tar.gz: a4239b86260c53d388695b601541329095d879d4
5
5
  SHA512:
6
- metadata.gz: fbb2e1461af5cbc3c29008a2e2ff728b67d0795278c4e873efbc99acac2354e8caa771b1e048208e4575a53bf5ae4accca4e136fec83f4304f238796256f3569
7
- data.tar.gz: 014e89bbd3a386f33a274290b45979a3438b59dd75ab549f5ab5f44cda93104972aa4f4ae9850e307a4ef2b6a509e929d61bc94135b545698f307b2ce3be4615
6
+ metadata.gz: 1b8c1a7343b42977c5f86bf8639a641c0e5c9b3bbec7e6527df0e4229492e4f2e8b1fdad394301af32464b1f9fd2d37ce6f4a61ca092b2d1d5de1b3f9fc9cdb6
7
+ data.tar.gz: d9993023779de032c5b1fa17e74d839c115c84baa80f839edcd65565fb6f50b68fe2a7cf99e7deb68f95a3090b1ad7fbaa54f45f94bdb068ab8337ba874d3db6
@@ -0,0 +1,52 @@
1
+ # Simplerb
2
+
3
+ A super simple framework for creating dynamic websites with Ruby and ERB.
4
+ Basically PHP-style web development in Ruby. The main purpose is to teach web
5
+ development to beginners.
6
+
7
+
8
+ # Installation
9
+
10
+ Just install the gem by running `gem install simplerb`
11
+
12
+
13
+ # Getting Started
14
+
15
+ To create a new project called `hello_world`, run this from the console:
16
+
17
+ ```
18
+ simplerb new hello_world
19
+ ```
20
+
21
+ This will create a directory called `hello_world` with some files and
22
+ subdirectories in it:
23
+
24
+ ```
25
+ - hello_world
26
+ \_ views
27
+ |_ public
28
+ |_ config.ru
29
+ ```
30
+
31
+ Now you can start the server by running `simplerb server`. Open your browser and
32
+ visit `http://localhost:9292`: if everything is up and running you should now
33
+ see a page with some greetings.
34
+
35
+
36
+ # Adding pages
37
+
38
+ You can add pages by creating `erb` files in the `views` directory. For example,
39
+ try creating a file `views/hello.erb` containing the text "Hello, World!". Now,
40
+ if you visit `http://localhost:9292/hello`, you should see that text.
41
+
42
+ If you want to reuse a part of a page (a "partial") in multiple pages, just
43
+ extract it into a separate file with a name starting with an underscore (e.g.
44
+ `_my_shared_content`). Then, within a page, call `<%= partial 'my_shared_content' %>`
45
+ to render the partial.
46
+
47
+
48
+ # Static files
49
+
50
+ Any static file that you put in the `public` folder will be served at the
51
+ corresponding URL, so if you create a file `public/styles/my_style.css`,
52
+ it will be served at `http://localhost:9292/styles/my_style.css`.
@@ -8,7 +8,7 @@ module Simplerb
8
8
  send verb.to_sym, '/*' do
9
9
  path = params[:splat].first
10
10
  views = view_files('[^_]*.erb')
11
- if views.include? File.join(settings.views, "#{path}.erb")
11
+ if views.include? File.join(settings.views, "#{path}.erb")
12
12
  erb path.to_sym
13
13
  elsif views.include? File.join(settings.views, path, 'index.erb')
14
14
  erb File.join(path, 'index').to_sym
@@ -24,8 +24,14 @@ module Simplerb
24
24
  end
25
25
 
26
26
  def partial(partial)
27
- if view_files('_*.erb').include? File.join(settings.views, "_#{partial}.erb")
28
- erb "_#{partial}".to_sym, layout: false
27
+ # Put underscore in last path component
28
+ file_path = partial.gsub(/(.*)\//, '\1/_')
29
+ full_path = File.join(settings.views, "#{file_path}.erb")
30
+
31
+ if view_files('_*.erb').include? full_path
32
+ erb file_path.to_sym, layout: false
33
+ else
34
+ raise "Couldn't find partial '#{partial}' at path '#{full_path}'"
29
35
  end
30
36
  end
31
37
 
@@ -24,8 +24,7 @@ module Simplerb
24
24
  option :port, desc: 'specify the port', type: :numeric, default: 9292, aliases: [:p]
25
25
  option :server, desc: 'specify the webserver', type: :string, default: 'webrick', aliases: [:s]
26
26
  def server
27
- system "rackup -p #{options[:port]} -s #{options[:server]}"
28
- rescue Interrupt
27
+ exec "rackup -p #{options[:port]} -s #{options[:server]}"
29
28
  end
30
29
 
31
30
  def self.source_root
@@ -1,3 +1,3 @@
1
1
  module Simplerb
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Ongaro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -62,6 +62,7 @@ executables:
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
+ - README.md
65
66
  - bin/simplerb
66
67
  - lib/simplerb.rb
67
68
  - lib/simplerb/cli.rb