Skip to content

Commit 67e0efa

Browse files
committed
Version 4.0.1
1 parent fcdad73 commit 67e0efa

22 files changed

Lines changed: 177 additions & 54 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ test/dummy/tmp/
66
test/dummy/.sass-cache
77
Gemfile.lock
88
.idea/
9-
*.gem
9+
*.gem
10+
coverage/

.rubocop.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
require:
2+
- rubocop-performance
3+
4+
AllCops:
5+
TargetRubyVersion: 2.3
6+
7+
Layout/SpaceInsideHashLiteralBraces:
8+
EnforcedStyle: no_space
9+
10+
Metrics/BlockLength:
11+
Max: 36
12+
Exclude:
13+
- spec/**/*.rb
14+
15+
Metrics/BlockNesting:
16+
Max: 2
17+
18+
Layout/LineLength:
19+
AllowURI: true
20+
Enabled: false
21+
22+
Metrics/MethodLength:
23+
CountComments: false
24+
Max: 10
25+
26+
Metrics/ModuleLength:
27+
Max: 100
28+
29+
Metrics/ParameterLists:
30+
Max: 5
31+
CountKeywordArgs: true
32+
33+
Style/CollectionMethods:
34+
Enabled: true
35+
PreferredMethods:
36+
collect: 'map'
37+
collect!: 'map!'
38+
inject: 'reduce'
39+
find: 'detect'
40+
find_all: 'select'
41+
delete: 'gsub'
42+
43+
Style/Documentation:
44+
Enabled: false
45+
46+
Layout/DotPosition:
47+
EnforcedStyle: trailing
48+
49+
Layout/AccessModifierIndentation:
50+
Enabled: false
51+
52+
Style/TrailingCommaInArrayLiteral:
53+
EnforcedStyleForMultiline: 'no_comma'
54+
55+
Style/TrailingCommaInHashLiteral:
56+
EnforcedStyleForMultiline: 'no_comma'

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ language: ruby
22
sudo: false
33
cache: bundler
44
rvm:
5-
- 2.5.5
6-
- 2.6.3
5+
- 2.5.7
6+
- 2.6.5
77

88
before_install:
9-
- gem update --system
10-
- gem install bundler
9+
- gem update bundler
1110

1211
env:
13-
- 'TEST_RAILS_VERSION="~> 5.0.7"'
1412
- 'TEST_RAILS_VERSION="~> 5.1.6"'
1513
- 'TEST_RAILS_VERSION="~> 5.2.3"'
1614
- 'TEST_RAILS_VERSION="~> 6.0.0"'

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 4.0.1 (23-Dec-19)
4+
5+
* Updated dependencies, tested against more recent Rubies and Rails
6+
* Updated Gemfile for Bundler 2
7+
* Added Rubocop and SimpleCov
8+
39
## 4.0.0 (20-Aug-19)
410

511
Updated:

Gemfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
source "https://rubygems.org"
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
24

35
gemspec
46

57
group :test do
6-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
7-
end
8+
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
9+
end

Rakefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
begin
24
require 'bundler/setup'
35
rescue LoadError
@@ -14,9 +16,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
1416
rdoc.rdoc_files.include('lib/**/*.rb')
1517
end
1618

17-
18-
19-
2019
Bundler::GemHelper.install_tasks
2120

2221
require 'rake/testtask'
@@ -28,5 +27,4 @@ Rake::TestTask.new(:test) do |t|
2827
t.verbose = false
2928
end
3029

31-
3230
task default: :test

angular_rails_csrf.gemspec

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
$:.push File.expand_path("../lib", __FILE__)
1+
# frozen_string_literal: true
2+
3+
$LOAD_PATH.push File.expand_path('lib', __dir__)
24

35
# Maintain your gem's version:
4-
require "angular_rails_csrf/version"
6+
require 'angular_rails_csrf/version'
57

68
# Describe your gem and declare its dependencies:
79
Gem::Specification.new do |s|
8-
s.name = "angular_rails_csrf"
10+
s.name = 'angular_rails_csrf'
911
s.version = AngularRailsCsrf::VERSION
1012
s.authors = ['James Sanders', 'Ilya Bodrov']
1113
s.email = ['sanderjd@gmail.com', 'golosizpru@gmail.com']
@@ -19,13 +21,18 @@ Gem::Specification.new do |s|
1921

2022
s.required_ruby_version = '>= 2.3.0'
2123

22-
s.add_development_dependency 'rake', '~> 12.0'
24+
s.add_development_dependency 'rake', '~> 13.0'
2325
s.add_development_dependency 'test-unit', '~> 3.2'
2426
if ENV['TEST_RAILS_VERSION'].nil?
25-
s.add_development_dependency 'rails', '6.0.0'
27+
s.add_development_dependency 'rails', '6.0.2.1'
2628
else
2729
s.add_development_dependency 'rails', ENV['TEST_RAILS_VERSION'].to_s
2830
end
2931

3032
s.add_runtime_dependency 'railties', '>= 3', '< 7'
33+
34+
s.add_development_dependency 'codecov', '~> 0.1'
35+
s.add_development_dependency 'rubocop', '~> 0.60'
36+
s.add_development_dependency 'rubocop-performance', '~> 1.5'
37+
s.add_development_dependency 'simplecov', '~> 0.16'
3138
end

lib/angular_rails_csrf.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# frozen_string_literal: true
2+
13
require 'angular_rails_csrf/railtie'

lib/angular_rails_csrf/concern.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module AngularRailsCsrf
24
module Concern
35
extend ActiveSupport::Concern
@@ -7,12 +9,12 @@ module Concern
79
end
810

911
def set_xsrf_token_cookie
10-
if protect_against_forgery? && !respond_to?(:__exclude_xsrf_token_cookie?)
11-
config = Rails.application.config
12-
domain = config.respond_to?(:angular_rails_csrf_domain) ? config.angular_rails_csrf_domain : nil
13-
cookie_name = config.respond_to?(:angular_rails_csrf_cookie_name) ? config.angular_rails_csrf_cookie_name : 'XSRF-TOKEN'
14-
cookies[cookie_name] = { value: form_authenticity_token, domain: domain }
15-
end
12+
return unless protect_against_forgery? && !respond_to?(:__exclude_xsrf_token_cookie?)
13+
14+
config = Rails.application.config
15+
domain = config.respond_to?(:angular_rails_csrf_domain) ? config.angular_rails_csrf_domain : nil
16+
cookie_name = config.respond_to?(:angular_rails_csrf_cookie_name) ? config.angular_rails_csrf_cookie_name : 'XSRF-TOKEN'
17+
cookies[cookie_name] = {value: form_authenticity_token, domain: domain}
1618
end
1719

1820
def verified_request?
@@ -25,7 +27,7 @@ def verified_request?
2527

2628
module ClassMethods
2729
def exclude_xsrf_token_cookie
28-
self.class_eval do
30+
class_eval do
2931
def __exclude_xsrf_token_cookie?
3032
true
3133
end

lib/angular_rails_csrf/railtie.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'angular_rails_csrf/concern'
24

35
module AngularRailsCsrf

0 commit comments

Comments
 (0)