vanity-routes 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/.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 vanity-routes.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Nick Soto
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,29 @@
1
+ Vanity Routes
2
+ =============
3
+
4
+ Create a VanityRoutes Table and Model:
5
+ --------------------------------------
6
+
7
+ class CreateVanityRoutes < ActiveRecord::Migration
8
+ def change
9
+ create_table :vanity_routes do |t|
10
+ t.string :path
11
+ t.integer :show_id
12
+ end
13
+ end
14
+ end
15
+
16
+
17
+ class VanityRoute < ActiveRecord::Base
18
+ end
19
+
20
+
21
+ Create a VanityRoutes initializer:
22
+ ----------------------------------
23
+
24
+ Vanity::Setup.config do |c|
25
+ c.controller = "messages" #controller that handles the route
26
+ end
27
+
28
+
29
+ [TODO] create table and model from generator
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ module VanityRoutes
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../config", __FILE__)
5
+ desc "Installs VanityRoutes Config Files"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,18 @@
1
+ require "vanity-routes/version"
2
+ require "vanity-routes/setup"
3
+ require "vanity-routes/errors"
4
+ require "vanity-routes/overrides"
5
+
6
+ module Vanity
7
+ module Routes
8
+ class Engine < Rails::Engine
9
+ initializer 'my_engine.vanity_routes', after: :add_routing_paths do |app|
10
+ raise Vanity::NoConfigurationError if Vanity::Setup.opts.controller.nil?
11
+ raise Vanity::NoVanityRoutesTableError if !ActiveRecord::Base.connection.table_exists? "vanity_routes"
12
+
13
+ ActionDispatch::Routing::RouteSet.send(:include, Vanity::Overrides)
14
+ app.routes_reloader.paths << File.expand_path('../vanity-routes/routes.rb',__FILE__)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module Vanity
2
+ class NoConfigurationError < StandardError
3
+ end
4
+
5
+ class NoVanityRoutesTableError < StandardError
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module Vanity
2
+ module Overrides
3
+ def vanity_draw(&block)
4
+ clear! unless @disable_clear_and_finalize
5
+ eval_block(block)
6
+ finalize! unless @disable_clear_and_finalize
7
+ nil
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ "#{Rails.application.class.parent_name}::Application".constantize.routes.vanity_draw do
2
+ VanityRoute.find_each do |route|
3
+ get route.path, to: "#{Vanity::Setup.opts.controller}#show", id: route.id
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ module Vanity
2
+ module Setup
3
+ @@opts ||= OpenStruct.new
4
+
5
+ def self.config
6
+ yield @@opts if block_given?
7
+ end
8
+
9
+ def self.opts
10
+ @@opts
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Vanity
2
+ module Routes
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vanity-routes/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "vanity-routes"
8
+ gem.version = Vanity::Routes::VERSION
9
+ gem.authors = ["Nick Soto"]
10
+ gem.email = ["nickesoto@gmail.com"]
11
+ gem.description = "vanity routes"
12
+ gem.summary = "it makes vanity routes"
13
+ gem.homepage = ""
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
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vanity-routes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nick Soto
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-19 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: vanity routes
15
+ email:
16
+ - nickesoto@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/generators/vanity-routes/config/vanity-routes.rb
27
+ - lib/generators/vanity-routes/install/install_generator.rb
28
+ - lib/vanity-routes.rb
29
+ - lib/vanity-routes/errors.rb
30
+ - lib/vanity-routes/overrides.rb
31
+ - lib/vanity-routes/routes.rb
32
+ - lib/vanity-routes/setup.rb
33
+ - lib/vanity-routes/version.rb
34
+ - vanity-routes.gemspec
35
+ homepage: ''
36
+ licenses: []
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.24
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: it makes vanity routes
59
+ test_files: []