rails_lite 0.1.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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/railslite +4 -0
- data/lib/.DS_Store +0 -0
- data/lib/rails_lite.rb +6 -0
- data/lib/rails_lite/.DS_Store +0 -0
- data/lib/rails_lite/cli.rb +65 -0
- data/lib/rails_lite/version.rb +3 -0
- data/lib/scaffold/.DS_Store +0 -0
- data/lib/scaffold/Gemfile +12 -0
- data/lib/scaffold/app/controllers/albums_controller.rb +55 -0
- data/lib/scaffold/app/controllers/application_controller.rb +45 -0
- data/lib/scaffold/app/controllers/bands_controller.rb +62 -0
- data/lib/scaffold/app/controllers/notes_controller.rb +26 -0
- data/lib/scaffold/app/controllers/sessions_controller.rb +34 -0
- data/lib/scaffold/app/controllers/tracks_controller.rb +55 -0
- data/lib/scaffold/app/controllers/users_controller.rb +41 -0
- data/lib/scaffold/app/models/album.rb +14 -0
- data/lib/scaffold/app/models/application_model.rb +5 -0
- data/lib/scaffold/app/models/band.rb +7 -0
- data/lib/scaffold/app/models/note.rb +7 -0
- data/lib/scaffold/app/models/track.rb +20 -0
- data/lib/scaffold/app/models/user.rb +42 -0
- data/lib/scaffold/app/views/albums_controller/edit.html.erb +51 -0
- data/lib/scaffold/app/views/albums_controller/new.html.erb +50 -0
- data/lib/scaffold/app/views/albums_controller/show.html.erb +25 -0
- data/lib/scaffold/app/views/application.html.erb +41 -0
- data/lib/scaffold/app/views/bands_controller/edit.html.erb +16 -0
- data/lib/scaffold/app/views/bands_controller/index.html.erb +12 -0
- data/lib/scaffold/app/views/bands_controller/json.json.jbuilder +3 -0
- data/lib/scaffold/app/views/bands_controller/new.html.erb +15 -0
- data/lib/scaffold/app/views/bands_controller/show.html.erb +27 -0
- data/lib/scaffold/app/views/sessions_controller/new.html.erb +22 -0
- data/lib/scaffold/app/views/tracks_controller/edit.html.erb +60 -0
- data/lib/scaffold/app/views/tracks_controller/new.html.erb +59 -0
- data/lib/scaffold/app/views/tracks_controller/show.html.erb +56 -0
- data/lib/scaffold/app/views/users_controller/new.html.erb +22 -0
- data/lib/scaffold/app/views/users_controller/show.html.erb +4 -0
- data/lib/scaffold/bin/pry +13 -0
- data/lib/scaffold/bin/routes +10 -0
- data/lib/scaffold/bin/server +32 -0
- data/lib/scaffold/config/routes.rb +26 -0
- data/lib/scaffold/db/database.db +0 -0
- data/lib/scaffold/db/database.sql +48 -0
- data/lib/scaffold/lib/.DS_Store +0 -0
- data/lib/scaffold/lib/controller/controller_base.rb +183 -0
- data/lib/scaffold/lib/controller/controller_callbacks.rb +17 -0
- data/lib/scaffold/lib/controller/cookies/flash.rb +33 -0
- data/lib/scaffold/lib/controller/cookies/flash_now.rb +15 -0
- data/lib/scaffold/lib/controller/cookies/session.rb +29 -0
- data/lib/scaffold/lib/controller/strong_params.rb +40 -0
- data/lib/scaffold/lib/middleware/file_server.rb +42 -0
- data/lib/scaffold/lib/middleware/show_exceptions.rb +62 -0
- data/lib/scaffold/lib/middleware/static.rb +31 -0
- data/lib/scaffold/lib/middleware/templates/rescue.html.erb +49 -0
- data/lib/scaffold/lib/model/associations/assoc_options.rb +16 -0
- data/lib/scaffold/lib/model/associations/associatable.rb +120 -0
- data/lib/scaffold/lib/model/associations/belongs_to_options.rb +18 -0
- data/lib/scaffold/lib/model/associations/has_many_options.rb +17 -0
- data/lib/scaffold/lib/model/db_connection.rb +59 -0
- data/lib/scaffold/lib/model/model_base.rb +183 -0
- data/lib/scaffold/lib/model/model_callbacks.rb +46 -0
- data/lib/scaffold/lib/model/relations/relation.rb +151 -0
- data/lib/scaffold/lib/model/relations/searchable.rb +27 -0
- data/lib/scaffold/lib/model/validations/validations.rb +31 -0
- data/lib/scaffold/lib/model/validations/validator.rb +81 -0
- data/lib/scaffold/lib/router/route.rb +24 -0
- data/lib/scaffold/lib/router/router.rb +192 -0
- data/lib/scaffold/lib/utils/url_helpers.rb +96 -0
- data/lib/scaffold/public/main.css +165 -0
- data/rails_lite.gemspec +41 -0
- metadata +168 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 24a86519448b52873c72c9e48ea0cbb359c3628c0838ad4ca0ea5c51865c793e
|
4
|
+
data.tar.gz: 387288a3778af1cc88c1351291e8bb33f39289485174ee8d5a15e5db499fc21e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4bd1ecf8ede005ac6707fd5ac72a64238ed031ca0744c881139946f16e8e9e94f221ea4564e336bcfc3af891a02968fd44eb9af053a2368132aeeae32498c36d
|
7
|
+
data.tar.gz: 14657330fe9b7d75f31a4f5d85502256b3c6b4cb926c190c087252b0b7bf5a841a903283f7ca9c7f67a8bdd6ea46c9bb568af65128db43b8a0da6dccda6f6015
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rails_lite (0.1.0)
|
5
|
+
thor
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
rake (10.5.0)
|
11
|
+
thor (0.20.3)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.17)
|
18
|
+
rails_lite!
|
19
|
+
rake (~> 10.0)
|
20
|
+
|
21
|
+
BUNDLED WITH
|
22
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Jeff DeLiso
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# RailsLite
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rails_lite`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'rails_lite'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install rails_lite
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_lite.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails_lite"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/railslite
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/rails_lite.rb
ADDED
Binary file
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module RailsLite
|
5
|
+
|
6
|
+
class CLI < Thor
|
7
|
+
|
8
|
+
desc "new", "Creates a new rails lite project"
|
9
|
+
method_option aliases: "n"
|
10
|
+
def new(*words)
|
11
|
+
words = ['new', 'app'] if words.empty?
|
12
|
+
name = words.join('_')
|
13
|
+
directory = File.dirname(__FILE__)
|
14
|
+
source = File.join(directory, "..", "scaffold")
|
15
|
+
FileUtils.cp_r source, FileUtils.pwd
|
16
|
+
FileUtils.mv(File.join(FileUtils.pwd, "scaffold"), File.join(FileUtils.pwd, name))
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "server", "Starts the rails lite server"
|
20
|
+
method_option aliases: "s"
|
21
|
+
def server
|
22
|
+
root = FileUtils.pwd
|
23
|
+
file_name = File.join(root, 'bin', 'server')
|
24
|
+
if File.exist?(file_name)
|
25
|
+
system('bin/server')
|
26
|
+
else
|
27
|
+
puts "Not a rails lite directory"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "console", "Starts the rails lite console"
|
32
|
+
method_option aliases: "c"
|
33
|
+
def console
|
34
|
+
root = FileUtils.pwd
|
35
|
+
file_name = File.join(root, 'bin', 'pry')
|
36
|
+
if File.exist?(file_name)
|
37
|
+
system('bin/pry')
|
38
|
+
else
|
39
|
+
puts "Not a rails lite directory"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "routes", "Displays the current routes"
|
44
|
+
def routes
|
45
|
+
root = FileUtils.pwd
|
46
|
+
file_name = File.join(root, 'bin', 'routes')
|
47
|
+
if File.exist?(file_name)
|
48
|
+
system('bin/routes')
|
49
|
+
else
|
50
|
+
puts "Not a rails lite directory"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "dbreset", "Resets the database"
|
55
|
+
def dbreset
|
56
|
+
root = FileUtils.pwd
|
57
|
+
file_name = File.join(root, 'bin', 'routes')
|
58
|
+
if File.exist?(file_name)
|
59
|
+
system('bin/dbreset')
|
60
|
+
else
|
61
|
+
puts "Not a rails lite directory"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
Binary file
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class AlbumsController < ApplicationController
|
2
|
+
|
3
|
+
def show
|
4
|
+
@album = Album.find(params[:id])
|
5
|
+
render :show
|
6
|
+
end
|
7
|
+
|
8
|
+
def new
|
9
|
+
@band = Band.find(params[:band_id])
|
10
|
+
@album = Album.new(band_id: params[:band_id])
|
11
|
+
render :new
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@album = Album.new(album_params)
|
16
|
+
|
17
|
+
if @album.save
|
18
|
+
redirect_to album_url(@album)
|
19
|
+
else
|
20
|
+
@band = @album.band
|
21
|
+
flash.now[:errors] = @album.errors
|
22
|
+
render :new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def edit
|
27
|
+
@album = Album.find(params[:id])
|
28
|
+
render :edit
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
@album = Album.find(params[:id])
|
33
|
+
|
34
|
+
if @album.update_attributes(album_params)
|
35
|
+
redirect_to album_url(@album)
|
36
|
+
else
|
37
|
+
flash.now[:errors] = @album.errors
|
38
|
+
render :edit
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy
|
43
|
+
@album = Album.find(params[:id])
|
44
|
+
@album.destroy
|
45
|
+
redirect_to band_url(@album.band_id)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def album_params
|
51
|
+
params.require(:album).permit(:band_id, :live, :name, :year)
|
52
|
+
end
|
53
|
+
|
54
|
+
before_action :ensure_login, except: [:index]
|
55
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../../lib/controller/controller_base'
|
2
|
+
|
3
|
+
class ApplicationController < ControllerBase
|
4
|
+
|
5
|
+
def current_user
|
6
|
+
@current_user ||= User.find_by(session_token: session[:session_token])
|
7
|
+
end
|
8
|
+
|
9
|
+
def ensure_login
|
10
|
+
unless logged_in?
|
11
|
+
flash[:errors] = ['must be logged in']
|
12
|
+
redirect_to new_sessions_url
|
13
|
+
|
14
|
+
true
|
15
|
+
else
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def ensure_logout
|
21
|
+
if logged_in?
|
22
|
+
flash[:errors] = ['already logged in']
|
23
|
+
redirect_to bands_url
|
24
|
+
|
25
|
+
true
|
26
|
+
else
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def login(user)
|
32
|
+
@current_user = user
|
33
|
+
session[:session_token] = user.reset_token!
|
34
|
+
end
|
35
|
+
|
36
|
+
def logout
|
37
|
+
current_user.reset_token!
|
38
|
+
session[:session_token] = nil
|
39
|
+
@current_user = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def logged_in?
|
43
|
+
!!current_user
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class BandsController < ApplicationController
|
2
|
+
protect_from_forgery
|
3
|
+
|
4
|
+
def index
|
5
|
+
@bands = Band.all
|
6
|
+
render :index
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
@band = Band.find(params[:id])
|
11
|
+
render :show
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@band = Band.new
|
16
|
+
render :new
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@band = Band.new(band_params)
|
21
|
+
|
22
|
+
if @band.save
|
23
|
+
redirect_to band_url(@band)
|
24
|
+
else
|
25
|
+
flash.now[:errors] = @band.errors.full_messages
|
26
|
+
render :new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit
|
31
|
+
@band = Band.find(params[:id])
|
32
|
+
render :edit
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
@band = Band.find(params[:id])
|
37
|
+
if @band.update_attributes(band_params)
|
38
|
+
redirect_to band_url(@band)
|
39
|
+
else
|
40
|
+
flash.now[:errors] = @band.errors.full_messages
|
41
|
+
render :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
@band = Band.find(params[:id])
|
47
|
+
@band.destroy
|
48
|
+
redirect_to bands_url
|
49
|
+
end
|
50
|
+
|
51
|
+
def json
|
52
|
+
@bands = Band.all
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def band_params
|
58
|
+
params.require(:band).permit(:name)
|
59
|
+
end
|
60
|
+
|
61
|
+
before_action :ensure_login
|
62
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class NotesController < ApplicationController
|
2
|
+
protect_from_forgery
|
3
|
+
|
4
|
+
def create
|
5
|
+
note = Note.new(note_params)
|
6
|
+
note.user_id = current_user.id
|
7
|
+
note.save
|
8
|
+
flash[:errors] = note.errors
|
9
|
+
|
10
|
+
redirect_to track_url(note.track_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def destroy
|
14
|
+
note = Note.find(params[:id])
|
15
|
+
note.destroy
|
16
|
+
redirect_to track_url(note.track_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def note_params
|
22
|
+
params.require(:note).permit(:content, :track_id)
|
23
|
+
end
|
24
|
+
|
25
|
+
before_action :ensure_login, only: [:create, :destroy]
|
26
|
+
end
|