current_domain 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f1f419cf7392240c684f72be31a34a5aa09a3081
4
+ data.tar.gz: e9f38edee46a2022383909f757fcd818ecbc5779
5
+ SHA512:
6
+ metadata.gz: bcb4cba719a7a71770effedc11903a854e9a9f29daffd55a60ef12d8c0afaeeef522b2f7e5a870c82db3ce79f5252ae8919c84992dc31686868d5d36f0cb7241
7
+ data.tar.gz: acdd1bfb50c98882536434c80860f9a55ead3082135831aeb6f5f30bd6a9e7681766bb1932896332d83e1d506191f2edb3be9688f812fc583334e20ab8417956
data/.cane ADDED
@@ -0,0 +1 @@
1
+ --no-doc
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/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --order random
2
+ --colour
3
+ --backtrace
4
+ --format progress
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Documentation:
2
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 2.2.0
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'rake'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Andrew Gridnev
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,32 @@
1
+ # CurrentDomain
2
+
3
+ [![Build Status](https://travis-ci.org/andrewgr/current_domain.png)](https://travis-ci.org/andrewgr/current_domain)
4
+ [![Code Climate](https://codeclimate.com/github/andrewgr/current_domain/badges/gpa.svg)](https://codeclimate.com/github/andrewgr/current_domain)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'current_domain'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install current_domain
19
+
20
+ ## Usage
21
+
22
+ TODO
23
+
24
+ ## Contributing
25
+
26
+ Your contribution is welcome.
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'cane/rake_task'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new('spec')
7
+
8
+ task default: :spec
9
+
10
+ desc 'Run cane to check quality metrics'
11
+ Cane::RakeTask.new(:quality) do |cane|
12
+ cane.abc_max = 10
13
+ cane.no_style = true
14
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../lib/current_domain/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ['Andrei Gridnev']
5
+ gem.email = ['andrew.gridnev@gmail.com']
6
+ gem.summary = 'Gets current domain of a Rails web app'
7
+ gem.description = 'Adds current_domain helper method to ActionController::Base'
8
+ gem.homepage = 'https://github.com/andrewgr/current_domain/'
9
+ gem.license = 'MIT'
10
+
11
+ gem.files = `git ls-files`.split($ORS)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^spec/})
14
+ gem.name = 'current_domain'
15
+ gem.require_paths = ['lib']
16
+ gem.version = CurrentDomain::VERSION
17
+
18
+ gem.add_runtime_dependency 'activesupport', '~> 4'
19
+
20
+ gem.add_development_dependency 'rspec', '~> 3'
21
+ gem.add_development_dependency 'actionpack', '~> 4'
22
+ gem.add_development_dependency 'rubocop', '~> 0.30'
23
+ gem.add_development_dependency 'cane', '~> 2.6', '>= 2.6.1'
24
+ gem.add_development_dependency 'shoulda', '~> 3.5'
25
+ gem.add_development_dependency 'shoulda-matchers', '~> 2.8', '>= 2.8.0'
26
+ end
@@ -0,0 +1,21 @@
1
+ module CurrentDomain
2
+ module Controllers
3
+ module Helpers
4
+ extend ActiveSupport::Concern
5
+
6
+ def current_domain
7
+ @current_domain ||= find_domain(request.host)
8
+ end
9
+
10
+ included do
11
+ helper_method :current_domain
12
+ end
13
+
14
+ private
15
+
16
+ def find_domain(host)
17
+ host
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module CurrentDomain
2
+ # Gem version
3
+ VERSION = '0.1'
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'active_support'
2
+ require 'current_domain/version'
3
+ require 'current_domain/controllers/helpers'
4
+
5
+ ActiveSupport.on_load(:action_controller) do
6
+ include CurrentDomain::Controllers::Helpers
7
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe CurrentDomain::Controllers::Helpers do
4
+ describe '#current_domain' do
5
+ context 'default method for finding current domain is used' do
6
+ class A < ActionController::Base
7
+ include CurrentDomain::Controllers::Helpers
8
+ end
9
+
10
+ let(:controller) { A.new }
11
+
12
+ before do
13
+ allow(controller).to receive_message_chain(:request, :host)
14
+ .and_return('host.name')
15
+ end
16
+
17
+ it 'returns request host name' do
18
+ expect(controller.current_domain).to eq('host.name')
19
+ end
20
+ end
21
+
22
+ context 'custom method for finding current domain is used' do
23
+ class B < ActionController::Base
24
+ include CurrentDomain::Controllers::Helpers
25
+
26
+ def find_domain(_host)
27
+ 'domain'
28
+ end
29
+ end
30
+
31
+ let(:controller) { B.new }
32
+
33
+ before do
34
+ allow(controller).to receive_message_chain(:request, :host)
35
+ .and_return('host.name')
36
+ end
37
+
38
+ it 'returns custom domain object' do
39
+ expect(controller.current_domain).to eq(controller.find_domain(''))
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,2 @@
1
+ require 'current_domain'
2
+ require 'action_controller'
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: current_domain
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Andrei Gridnev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionpack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.30'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.30'
69
+ - !ruby/object:Gem::Dependency
70
+ name: cane
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.6'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 2.6.1
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '2.6'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 2.6.1
89
+ - !ruby/object:Gem::Dependency
90
+ name: shoulda
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.5'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.5'
103
+ - !ruby/object:Gem::Dependency
104
+ name: shoulda-matchers
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '2.8'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 2.8.0
113
+ type: :development
114
+ prerelease: false
115
+ version_requirements: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '2.8'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 2.8.0
123
+ description: Adds current_domain helper method to ActionController::Base
124
+ email:
125
+ - andrew.gridnev@gmail.com
126
+ executables: []
127
+ extensions: []
128
+ extra_rdoc_files: []
129
+ files:
130
+ - ".cane"
131
+ - ".gitignore"
132
+ - ".rspec"
133
+ - ".rubocop.yml"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - LICENSE
137
+ - README.md
138
+ - Rakefile
139
+ - current_domain.gemspec
140
+ - lib/current_domain.rb
141
+ - lib/current_domain/controllers/helpers.rb
142
+ - lib/current_domain/version.rb
143
+ - spec/current_domain/controllers/helpers_spec.rb
144
+ - spec/spec_helper.rb
145
+ homepage: https://github.com/andrewgr/current_domain/
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.2.2
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: Gets current domain of a Rails web app
169
+ test_files:
170
+ - spec/current_domain/controllers/helpers_spec.rb
171
+ - spec/spec_helper.rb