divert 0.5 → 0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19ba83102da9deec2da4776d4cd65e2bd09d807d
4
- data.tar.gz: 08ba81f4a1f86b5ec78f348ff62d9570939a7900
3
+ metadata.gz: 8a6b356e7733eb5fef053ad4a60b3ebf58a31847
4
+ data.tar.gz: 07a9684e435a664ffe825062d992ab298e16961e
5
5
  SHA512:
6
- metadata.gz: 268837fac9ff0217fe83ab34a20944afb7703077ae261c0647fb95b44ff45c4e8771dc9341ae82ab624cd63175391edb5d7514e3aacd4986336afcb324f5475a
7
- data.tar.gz: cb975dc753c11f3900cbba57cb336209ae36060793746091a3ccdf3c95d3b92edf9838135422f474fa70402669a350f4d85643159202e9ce4822321cebec0ad8
6
+ metadata.gz: 427b1fefa5431599cd797d083c5f9a9afc60ed14549ca1577658038d1b8c2a8010c9d925f5df2c0e817d21c89506d0311180560336c28d3f62121800f1252eb2
7
+ data.tar.gz: 33e13a6cc622b1a3adc2ad5eec7b556afcae9286013f3e9306e8e974ffa971646ce8590216749f6f43498d175c3e2dafabcf51e0a6d7ae04a299dc6a8a70cb5c
data/README.rdoc CHANGED
@@ -3,7 +3,7 @@
3
3
  This project rocks and uses MIT-LICENSE.
4
4
 
5
5
  Currently, in order to use:
6
- gem 'divert', :git => 'ssh://git@vcs.hhd.com.au/var/git/repos/divert.git'
6
+ gem 'divert'
7
7
 
8
8
  Install the migrations with
9
9
  rake divert:install:migrations
@@ -1,16 +1,8 @@
1
1
  module Divert
2
2
  class Redirect < ActiveRecord::Base
3
- ANTISLASH = /^\/|\/\s*$/
4
-
5
- # Attribute accessibility
6
- attr_accessible :active, :hither, :hits, :thither
7
-
8
3
  # Validations
9
4
  validates :hither, presence:true
10
5
 
11
- # Callbacks
12
- before_save :check_slashes
13
-
14
6
  # Instance Methods
15
7
  def name
16
8
  "\"#{hither}\" > \"#{thither}\""
@@ -18,26 +10,17 @@ module Divert
18
10
 
19
11
  def hit
20
12
  return nil unless active
21
- self.increment! :hits unless self.thither
22
- self.thither
13
+ increment! :hits unless thither
14
+ thither
23
15
  end
24
16
 
25
17
  # Class Methods
26
18
  def self.hit path
27
- find_or_create_by_hither(
28
- path.gsub ANTISLASH,
29
- :hither => path, :hits => 0
30
- ).hit
19
+ path.chomp! '/'
20
+ find_or_create_by(hither: path).hit
31
21
  end
32
22
 
33
23
  # Scopes
34
24
  scope :active, :conditions => {:active => true}
35
-
36
- private
37
-
38
- def check_slashes
39
- self.hither = self.hither.gsub ANTISLASH, ''
40
- self.thither = "/#{self.thither}" unless self.thither.match /^\// unless self.thither.nil?
41
- end
42
25
  end
43
26
  end
@@ -3,8 +3,8 @@ class CreateDivertRedirects < ActiveRecord::Migration
3
3
  create_table :divert_redirects do |t|
4
4
  t.string :hither
5
5
  t.string :thither
6
- t.integer :hits
7
- t.boolean :active, :default => true
6
+ t.integer :hits, default: 0
7
+ t.boolean :active, default: true
8
8
 
9
9
  t.timestamps
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Divert
2
- VERSION = "0.5"
2
+ VERSION = "0.6"
3
3
  end
data/lib/divert.rb CHANGED
@@ -24,7 +24,7 @@ end
24
24
 
25
25
  class ActionDispatch::Routing::Mapper
26
26
  def divert_with controller
27
- match ":action" => "static"
28
- match '*path' => "#{controller}#action_missing", :format => false
27
+ get ':action' => controller.to_s
28
+ get '*path' => "#{controller}#action_missing", :format => false
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: divert
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Butler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.2'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,43 +108,43 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.2.0
111
+ rubygems_version: 2.2.2
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Easily handle 404s and redirects with your rails app.
115
115
  test_files:
116
- - test/dummy/config.ru
116
+ - test/divert_test.rb
117
+ - test/dummy/app/assets/javascripts/application.js
118
+ - test/dummy/app/assets/stylesheets/application.css
119
+ - test/dummy/app/controllers/application_controller.rb
120
+ - test/dummy/app/helpers/application_helper.rb
121
+ - test/dummy/app/views/layouts/application.html.erb
122
+ - test/dummy/config/application.rb
123
+ - test/dummy/config/boot.rb
124
+ - test/dummy/config/database.yml
125
+ - test/dummy/config/environment.rb
126
+ - test/dummy/config/environments/development.rb
127
+ - test/dummy/config/environments/production.rb
128
+ - test/dummy/config/environments/test.rb
129
+ - test/dummy/config/initializers/backtrace_silencers.rb
130
+ - test/dummy/config/initializers/inflections.rb
117
131
  - test/dummy/config/initializers/mime_types.rb
132
+ - test/dummy/config/initializers/secret_token.rb
118
133
  - test/dummy/config/initializers/session_store.rb
119
- - test/dummy/config/initializers/inflections.rb
120
134
  - test/dummy/config/initializers/wrap_parameters.rb
121
- - test/dummy/config/initializers/backtrace_silencers.rb
122
- - test/dummy/config/initializers/secret_token.rb
123
- - test/dummy/config/environments/production.rb
124
- - test/dummy/config/environments/test.rb
125
- - test/dummy/config/environments/development.rb
126
135
  - test/dummy/config/locales/en.yml
127
136
  - test/dummy/config/routes.rb
128
- - test/dummy/config/environment.rb
129
- - test/dummy/config/application.rb
130
- - test/dummy/config/boot.rb
131
- - test/dummy/config/database.yml
132
- - test/dummy/app/assets/stylesheets/application.css
133
- - test/dummy/app/assets/javascripts/application.js
134
- - test/dummy/app/helpers/application_helper.rb
135
- - test/dummy/app/views/layouts/application.html.erb
136
- - test/dummy/app/controllers/application_controller.rb
137
- - test/dummy/script/rails
138
- - test/dummy/Rakefile
137
+ - test/dummy/config.ru
139
138
  - test/dummy/public/404.html
140
- - test/dummy/public/favicon.ico
141
139
  - test/dummy/public/422.html
142
140
  - test/dummy/public/500.html
141
+ - test/dummy/public/favicon.ico
142
+ - test/dummy/Rakefile
143
143
  - test/dummy/README.rdoc
144
- - test/divert_test.rb
145
- - test/integration/navigation_test.rb
144
+ - test/dummy/script/rails
145
+ - test/fixtures/divert/redirects.yml
146
146
  - test/functional/divert/redirects_controller_test.rb
147
+ - test/integration/navigation_test.rb
147
148
  - test/test_helper.rb
148
- - test/fixtures/divert/redirects.yml
149
149
  - test/unit/divert/redirect_test.rb
150
150
  - test/unit/helpers/divert/redirects_helper_test.rb