tiny-rails 0.0.1

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.
@@ -0,0 +1,18 @@
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
18
+ .tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tiny-rails.gemspec
4
+ gemspec
5
+
6
+ gem 'rb-inotify', '~> 0.8.8'
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/tiny-rails/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Fabio Rehm
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.
@@ -0,0 +1,39 @@
1
+ # TinyRails
2
+
3
+ Scaffold for tiny Rails apps based on José Valim's Rails Lightweight Stack
4
+ [code](https://gist.github.com/1942658)
5
+
6
+ ## Installation
7
+
8
+ Install it using:
9
+
10
+ $ gem install tiny-rails
11
+
12
+ ## Usage
13
+
14
+ ```terminal
15
+ $ tiny-rails tiny-app
16
+ create tiny-app/application.coffee
17
+ create tiny-app/application.scss
18
+ create tiny-app/boot.rb
19
+ create tiny-app/config.ru
20
+ create tiny-app/Gemfile
21
+ create tiny-app/index.html.haml
22
+ create tiny-app/migrate
23
+ create tiny-app/models.rb
24
+ create tiny-app/server
25
+ create tiny-app/tiny_rails_controller.rb
26
+ create tiny-app/.gitignore
27
+ chmod tiny-app/migrate
28
+ chmod tiny-app/server
29
+ ```
30
+
31
+ More info coming out soon...
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new do |t|
6
+ t.pattern = "spec/**/*_spec.rb"
7
+ end
8
+ task :default => :spec
9
+ rescue LoadError; end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+
5
+ if File.exists?(File.join(File.expand_path('../../', __FILE__), '.git'))
6
+ $:.unshift(File.expand_path('../../lib', __FILE__))
7
+ end
8
+
9
+ require 'tiny-rails'
10
+ require 'tiny-rails/cli'
11
+
12
+ TinyRails::CLI.start
@@ -0,0 +1,4 @@
1
+ require "tiny-rails/version"
2
+
3
+ module TinyRails
4
+ end
@@ -0,0 +1,50 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+
4
+ module TinyRails
5
+ class CLI < Thor::Group
6
+ include Thor::Actions
7
+
8
+ argument :app_path, :required => true
9
+
10
+ def self.source_root
11
+ "#{File.expand_path('../../../templates', __FILE__)}/"
12
+ end
13
+
14
+ def self.banner
15
+ "tiny-rails #{self.arguments.map(&:usage).join(' ')} [options]"
16
+ end
17
+
18
+ def self.templates
19
+ @templates ||= %w(
20
+ application.coffee
21
+ application.scss
22
+ boot.rb
23
+ config.ru
24
+ Gemfile
25
+ index.html.haml
26
+ migrate
27
+ models.rb
28
+ server
29
+ tiny_rails_controller.rb
30
+ .gitignore
31
+ )
32
+ end
33
+
34
+ def self.executables
35
+ @executables ||= %w(
36
+ migrate
37
+ server
38
+ )
39
+ end
40
+
41
+ def scaffold
42
+ self.class.templates.each do |template|
43
+ template(template, "#{app_path}/#{template}")
44
+ end
45
+ self.class.executables.each do |script|
46
+ chmod "#{app_path}/#{script}", 0755
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,3 @@
1
+ module TinyRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe TinyRails::CLI do
4
+ before { FileUtils.rm_rf '.tmp' if Dir.exist?('.tmp') }
5
+
6
+ context 'scaffold' do
7
+ subject do
8
+ output = capture(:stdout) { described_class.start(['.tmp']) }
9
+ output.gsub(/\e\[(\d+)m/, '')
10
+ end
11
+
12
+ described_class.templates.each do |file|
13
+ it { should =~ /create\s+\.tmp\/#{Regexp.escape file}/ }
14
+ end
15
+
16
+ described_class.executables.each do |script|
17
+ it { should =~ /chmod\s+\.tmp\/#{Regexp.escape script}/ }
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,29 @@
1
+ require 'tiny-rails'
2
+ require 'tiny-rails/cli'
3
+
4
+ require 'fileutils'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+
17
+ def capture(stream)
18
+ begin
19
+ stream = stream.to_s
20
+ eval "$#{stream} = StringIO.new"
21
+ yield
22
+ result = eval("$#{stream}").string
23
+ ensure
24
+ eval("$#{stream} = #{stream.upcase}")
25
+ end
26
+
27
+ result
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ tmp/
2
+ log/
3
+ db.sqlite3
4
+ Gemfile.lock
@@ -0,0 +1,16 @@
1
+ source :rubygems
2
+
3
+ # Required by active_support
4
+ gem "tzinfo"
5
+
6
+ gem "actionpack", "~> 3.2"
7
+ gem "activemodel", "~> 3.2"
8
+ gem "activerecord", "~> 3.2"
9
+ gem "railties", "~> 3.2"
10
+
11
+ gem 'sqlite3'
12
+
13
+ gem 'jquery-rails'
14
+ gem 'haml-rails'
15
+ gem 'sass-rails'
16
+ gem 'coffee-rails'
@@ -0,0 +1,6 @@
1
+ #= require jquery
2
+
3
+ jQuery ($) ->
4
+ setTimeout ->
5
+ $('body').html('<h1 id="loaded">Page loaded!</h1>')
6
+ , 1500
@@ -0,0 +1,2 @@
1
+ body { font-size: 40px; color: blue; }
2
+ #loaded { color: green; }
@@ -0,0 +1,49 @@
1
+ $:.unshift Dir.pwd
2
+
3
+ require 'bundler'
4
+ Bundler.setup :default
5
+
6
+ require "rails"
7
+ require "rails/all"
8
+
9
+ Bundler.require :default
10
+
11
+ class TinyRailsApp < Rails::Application
12
+ routes.append do
13
+ match "/" => "tiny_rails#index"
14
+ match "/favicon.ico", :to => proc {|env| [200, {}, [""]] }
15
+ end
16
+
17
+ config.consider_all_requests_local = true
18
+
19
+ config.active_support.deprecation = :log
20
+
21
+ config.autoload_paths << config.root
22
+
23
+ config.assets.enabled = true
24
+ config.assets.debug = true
25
+ config.assets.paths << File.dirname(__FILE__)
26
+
27
+
28
+ def config.database_configuration
29
+ {
30
+ 'development' =>
31
+ {
32
+ 'adapter' => 'sqlite3',
33
+ 'database' => 'db.sqlite3',
34
+ 'pool' => 5,
35
+ 'timeout' => 5000
36
+ }
37
+ }
38
+ end
39
+
40
+ config.middleware.delete "Rack::Lock"
41
+ config.middleware.delete "ActionDispatch::Flash"
42
+ config.middleware.delete "ActionDispatch::BestStandardsSupport"
43
+ config.middleware.use Rails::Rack::LogTailer, "log/#{Rails.env}.log"
44
+
45
+ # We need a secret token for session, cookies, etc.
46
+ config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
47
+ end
48
+
49
+ TinyRailsApp.initialize!
@@ -0,0 +1,2 @@
1
+ require './boot'
2
+ run TinyRailsApp
@@ -0,0 +1,10 @@
1
+ !!! 5
2
+ %head
3
+ %title TinyRailsApp
4
+ %meta{ charset: "utf-8" }
5
+
6
+ = stylesheet_link_tag 'application'
7
+ = javascript_include_tag 'application'
8
+
9
+ %body
10
+ Loading...
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './boot'
4
+
5
+ # TODO: Alert that DB will be dropped
6
+
7
+ def drop_database(config)
8
+ case config['adapter']
9
+ when /mysql/
10
+ ActiveRecord::Base.establish_connection(config)
11
+ ActiveRecord::Base.connection.drop_database config['database']
12
+ when /sqlite/
13
+ require 'pathname'
14
+ path = Pathname.new(config['database'])
15
+ file = path.absolute? ? path.to_s : File.join(Rails.root, path)
16
+
17
+ FileUtils.rm(file)
18
+ when /postgresql/
19
+ ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
20
+ ActiveRecord::Base.connection.drop_database config['database']
21
+ end
22
+ end
23
+
24
+ ActiveRecord::Base.configurations.each_value do |config|
25
+ # Skip entries that don't have a database key
26
+ next unless config['database']
27
+ begin
28
+ drop_database(config)
29
+ rescue Exception => e
30
+ $stderr.puts "Couldn't drop #{config['database']} : #{e.inspect}"
31
+ end
32
+ end
33
+
34
+ ActiveRecord::Schema.define do
35
+ create_table "accounts" do |t|
36
+ t.string "name"
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ class SampleModel
2
+ include ActiveModel::Validations
3
+ include ActiveModel::Conversion
4
+ extend ActiveModel::Naming
5
+
6
+ attr_accessor :password
7
+
8
+ validates :password, :confirmation => true
9
+
10
+ # Required to use this model in a form builder
11
+ def persisted?
12
+ false
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './boot'
4
+
5
+ if ARGV[0] == '-v' || ARGV[0] == '--verbose'
6
+ puts ">> Starting Rails lightweight stack"
7
+ Rails.configuration.middleware.each do |middleware|
8
+ puts "use #{middleware.inspect}"
9
+ end
10
+ puts "run #{Rails.application.class.name}.routes"
11
+ end
12
+
13
+
14
+ options = {
15
+ :environment => nil,
16
+ :pid => nil,
17
+ :Port => 3000,
18
+ :Host => "0.0.0.0",
19
+ :AccessLog => [],
20
+ :app => TinyRailsApp,
21
+
22
+ # TODO:
23
+ # :server => 'thin'
24
+ }
25
+
26
+ Rack::Server.start options
@@ -0,0 +1,11 @@
1
+ class TinyRailsController < ActionController::Base
2
+ # Code reloading goodness
3
+ require_dependency 'models'
4
+
5
+ append_view_path File.dirname(__FILE__)
6
+
7
+ def index
8
+ @model = SampleModel.new
9
+ render :template => 'index'
10
+ end
11
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tiny-rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "tiny-rails"
8
+ gem.version = TinyRails::VERSION
9
+ gem.authors = ["Fabio Rehm"]
10
+ gem.email = ["fgrehm@gmail.com"]
11
+ gem.description = %q{A generator for tiny Rails apps}
12
+ gem.summary = gem.description
13
+ gem.homepage = 'http://github.com/fgrehm/tiny-rails'
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'thor', '>= 0.14.6', '< 2.0'
21
+
22
+ gem.add_development_dependency 'bundler', '~> 1.0'
23
+ gem.add_development_dependency 'rake', '~> 0.9'
24
+ gem.add_development_dependency 'rspec', '~> 2.0'
25
+ gem.add_development_dependency 'guard-rspec', '~> 2.0'
26
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Fabio Rehm
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.14.6
22
+ - - <
23
+ - !ruby/object:Gem::Version
24
+ version: '2.0'
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.14.6
33
+ - - <
34
+ - !ruby/object:Gem::Version
35
+ version: '2.0'
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ requirement: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: '1.0'
52
+ - !ruby/object:Gem::Dependency
53
+ name: rake
54
+ requirement: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ version: '0.9'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '0.9'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec
70
+ requirement: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '2.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: guard-rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ version: '2.0'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: '2.0'
100
+ description: A generator for tiny Rails apps
101
+ email:
102
+ - fgrehm@gmail.com
103
+ executables:
104
+ - tiny-rails
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - .gitignore
109
+ - .rspec
110
+ - Gemfile
111
+ - Guardfile
112
+ - LICENSE.txt
113
+ - README.md
114
+ - Rakefile
115
+ - bin/tiny-rails
116
+ - lib/tiny-rails.rb
117
+ - lib/tiny-rails/cli.rb
118
+ - lib/tiny-rails/version.rb
119
+ - spec/cli_spec.rb
120
+ - spec/spec_helper.rb
121
+ - templates/.gitignore
122
+ - templates/Gemfile
123
+ - templates/application.coffee
124
+ - templates/application.scss
125
+ - templates/boot.rb
126
+ - templates/config.ru
127
+ - templates/index.html.haml
128
+ - templates/migrate
129
+ - templates/models.rb
130
+ - templates/server
131
+ - templates/tiny_rails_controller.rb
132
+ - tiny-rails.gemspec
133
+ homepage: http://github.com/fgrehm/tiny-rails
134
+ licenses: []
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ segments:
146
+ - 0
147
+ hash: -3409797732492821246
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ segments:
155
+ - 0
156
+ hash: -3409797732492821246
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 1.8.23
160
+ signing_key:
161
+ specification_version: 3
162
+ summary: A generator for tiny Rails apps
163
+ test_files:
164
+ - spec/cli_spec.rb
165
+ - spec/spec_helper.rb