rack-gen 0.3.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd67a8559e48425c20af6f84b8d0a30b20ced7c3
4
+ data.tar.gz: e4ce370582105c3aee51f38e2392d4d6dfc144be
5
+ SHA512:
6
+ metadata.gz: 6524d6dba54c49c530dc5cfe8c4b44405f20480d42f12b4ed5bd68c0420531c8bdad835ac4a4273885aaeb2f86ddb8fbb064464d5e58e981eda740c544206122
7
+ data.tar.gz: c88e9120ff5249eec27bf39768dd995e1692bc11c8838791cb517c7e21231f2a17e3ef24d92cd8e19bd302161da0242f9b241b51b2218ace3bfcb827363651e5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-generator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Steven Zeiler
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Rack::Generator
2
+
3
+ Rack Generator is used to create the most basic ruby web application using the rack framework.
4
+
5
+ Rack is the underlying technology behind popular web ruby frameworks like sinatra and rails. The gem was designed to be the perfect tool for introducing students to ruby on the web and get them started with basic html, css, and javascript
6
+
7
+ ## INSTALLATION
8
+
9
+ git clone https://github.com/stevenzeiler/rack-generator.git
10
+ gem build rack-generator.gemspec
11
+ gem install rack-generator-0.2.0.gem
12
+
13
+ ## USAGE
14
+
15
+ Generate a new rack application, which consists of three files.
16
+
17
+ rack new myappname --heroku
18
+
19
+ You will see output from several operations, which will are explained below
20
+
21
+ Initialized empty Git repository in /Users/stevenzeiler/Desktop/szrack/.git/
22
+ Fetching gem metadata from https://rubygems.org/..........
23
+ Resolving dependencies...
24
+ Using rack (1.5.2)
25
+ Using bundler (1.3.5)
26
+ Your bundle is complete!
27
+ Use `bundle show [gemname]` to see where a bundled gem is installed.
28
+ [master (root-commit) 09f1907] add most basic rack app
29
+ 4 files changed, 46 insertions(+), 0 deletions(-)
30
+ create mode 100644 Gemfile
31
+ create mode 100644 Gemfile.lock
32
+ create mode 100644 config.ru
33
+ create mode 100644 index.html
34
+ Creating evening-brushlands-9923... done, region is us
35
+ http://evening-brushlands-9923.herokuapp.com/ | git@heroku.com:evening-brushlands-9923.git
36
+ Git remote heroku added
37
+
38
+ 1. A directory is created given the name you specify in the create command. In this case it is `myappname`.
39
+
40
+ 2. A git repository is created in the project directory.
41
+
42
+ 3. Three files are copied into the project directory. These files are the mininum needed to serve a web page with ruby:
43
+
44
+ - Gemfile - bundler uses this file to download the right gems. Our rack app requires only the `rack` gem.
45
+ - config.ru - runs two commands to set up the rack server and configure public file access.
46
+ - index.html - the 'single-page' application file that represents the visual user interface.
47
+
48
+ 4. A /public directory is created from where files can be downloaded over the web.
49
+
50
+ 5. The `bundle` command is run, which downloads the required gems and creates a Gemfile.lock. The lock file is required by Heroku in order to download the proper gems.
51
+
52
+ 6. The four files and one directory are copied into the git repository.
53
+
54
+ 7. A heroku application is created and the `heroku` remote is added to git. You can now push to heroku, which happens next automatically.
55
+
56
+ 8. The rack app is pushed to heroku, where a virutal linux machine is provisioned. When the build process is finished the rack app will open in your system's default browser.
57
+
58
+
59
+ ## Running Locally
60
+
61
+ To run the application locally start a web server with rack's startup mechanism. Navigate to the project directory and run:
62
+
63
+ rackup
64
+
65
+ `Rackup` will look for a file named `config.ru` ("ru" stands for "rackup") and run its contents in hopes of finding a rack-compatible object to execute.
66
+
67
+
68
+ ## Motivation
69
+
70
+ My motivation for creating this gem was to uncomplicate the process of learning to deploy a web site using ruby and heroku. When I try to teach rails to people there is usually too much information for them to handle all at once, especially from the beginning. Rails generates so many files for you and then you must ask the students to not worry about what is going on with the majority of the files. One solution to this problem is to have the students begin with the sinatra framework, which strips out almost everything rails offers by default and makes it possible to run simple static ruby server applications. Both rails and sinatra are based on a lower-level framework that is directly responsible for handling http requests and responses. Since it is inherently valuable to start from the most fundamental principles and build increasingly complex abractions on top I like to start students off with the most basic rack server application that can be deployed to heroku.
71
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/rack ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'trollop'
4
+
5
+ opts = Trollop::options do
6
+ opt :heroku, "Create heroku app" # flag --heroku, default false
7
+ end
8
+
9
+ root = File.dirname(__FILE__)
10
+
11
+
12
+ if ARGV[0] == "new"
13
+ directory = ARGV[1]
14
+ if system "mkdir -p #{directory}/public"
15
+ system "cp #{root}/../lib/templates/config.ru #{directory}/config.ru"
16
+ system "cp #{root}/../lib/templates/index.html #{directory}/index.html"
17
+ system "cp #{root}/../lib/templates/Gemfile #{directory}/Gemfile"
18
+ system "cd #{directory} && git init && bundle install"
19
+ system "cd #{directory} && git add . && git commit -m 'add most basic rack app'"
20
+
21
+ if opts[:heroku]
22
+ system "cd #{directory} && heroku create && git push heroku master && heroku open"
23
+ end
24
+ else
25
+ puts "A directory called #{directory} already exists."
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rack'
4
+
@@ -0,0 +1,6 @@
1
+ use Rack::Static, :root => "#{File.dirname(__FILE__)}/",
2
+ :index => "index.html"
3
+
4
+ run lambda { |env|
5
+ Rack::Directory.new( "#{File.dirname(__FILE__)}/public" ).call(env)
6
+ }
@@ -0,0 +1,27 @@
1
+ <html>
2
+ <head>
3
+ <style>
4
+ body {
5
+ background-color: #aaa;
6
+ font-size: 200%;
7
+ padding:0.3em;
8
+ }
9
+ section {
10
+ background-color: #eee;
11
+ padding:2em;
12
+ margin:auto;
13
+ text-align:center;
14
+ }
15
+ </style>
16
+ </head>
17
+
18
+ <body>
19
+ <section>
20
+ <h1>Running on Rack!!</h1>
21
+ </section>
22
+ </body>
23
+
24
+ <script type="text/javascript">
25
+ console.log(document.getElementsByTagName("section")[0]);
26
+ </script>
27
+ </html>
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rack-gen"
7
+ spec.version = "0.3.0"
8
+ spec.authors = ["Steven Zeiler"]
9
+ spec.email = ["zeiler.steven@gmail.com"]
10
+ spec.description = %q{A gem to generate the most basic static web server}
11
+ spec.summary = %q{A basic rack server app generator}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib/templates"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+
23
+ spec.executables << 'rack'
24
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-gen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven Zeiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A gem to generate the most basic static web server
42
+ email:
43
+ - zeiler.steven@gmail.com
44
+ executables:
45
+ - rack
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/rack
55
+ - lib/templates/Gemfile
56
+ - lib/templates/config.ru
57
+ - lib/templates/index.html
58
+ - rack-generator.gemspec
59
+ homepage: ''
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib/templates
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: A basic rack server app generator
83
+ test_files: []