cloudflare_localizable 0.1.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7d39c3be36591f5cf59b7bd0ec5744f4313b9cd4
4
- data.tar.gz: 2b2dcc0c64c7c359a6f7f71e4211a160f80ff51c
2
+ SHA256:
3
+ metadata.gz: 9d6007461042c4f48b203ba0329c5425f9a77bf5047ad18664dea26f58d924ce
4
+ data.tar.gz: df71329ae0f016a4402896f82234bd45e8e4885fd7cb4451e05cfd31e57270ba
5
5
  SHA512:
6
- metadata.gz: 7a8d7405719b275221a2e765c737f6df9b90390f9bf3cfecf331619834baf507a265a19bb16623ea3975cffc62e24032cb3a790905254391b30316be1c278b01
7
- data.tar.gz: 911068764308d62232e42925a6d465fef537f9a91041030f69f0fc414ee4b6f19b5d5226d42903ddc6ebc2e3ff8237e73a7db02bba319911ce5e28b10788a906
6
+ metadata.gz: ca1987748c2dc9ba972fa599ae28e8497647cd600011b90d09d77f699dfae7dba472b6d1bd8a082c7f62b173e06bdfa233eb8c0cb697b6714d8ee9cd851d5331
7
+ data.tar.gz: 8c9130523bede2ad4a1694b6adb002ab11a71644992b5f10c90d4eebd931043f4764fabc4f8e1bb248ce2097f4c4e11651bdfadba40bc0c2a7848cc6ed10b175
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
1
  --format documentation
2
2
  --color
3
+ --order rand
4
+ --require spec_helper
@@ -0,0 +1,13 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - spec/*
7
+
8
+ Metrics/ModuleLength:
9
+ Exclude:
10
+ - lib/cloudflare_localizable/country_list.rb
11
+
12
+ Style/ExpandPathArguments:
13
+ Enabled: false
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.5.0
@@ -1,7 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.2.2
3
+ - 2.1.0
6
4
  - 2.2.3
7
- before_install: gem install bundler -v 1.10.6
5
+ - 2.3.1
6
+ - 2.4.3
7
+ - 2.5.0
8
+ before_install: gem install bundler -v 1.16.1
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in cloudflare_localizable.gemspec
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # frozen_string_literal: true
4
+
3
5
  require 'bundler/setup'
4
6
  require 'cloudflare_localizable'
5
7
 
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
 
@@ -21,8 +22,9 @@ Gem::Specification.new do |spec|
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ['lib']
23
24
 
25
+ spec.add_development_dependency 'actionpack', '~> 4.2', '>= 4.2.5'
24
26
  spec.add_development_dependency 'bundler', '~> 1.10'
25
27
  spec.add_development_dependency 'rake', '~> 10.0'
26
28
  spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
27
- spec.add_development_dependency 'actionpack', '~> 4.2', '>= 4.2.5'
29
+ spec.add_development_dependency 'rubocop', '~> 0.54.0'
28
30
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cloudflare_localizable/version'
2
4
  require 'cloudflare_localizable/country'
3
5
 
4
- # This module can be included in any Rails controller that needs country
5
- # information. You get a helper method called cf_country to be used whenever you
6
- # need to know the country of the user.
6
+ # This module can be included in any Rails controller that needs country information. You get a
7
+ # helper method called cf_country to be used whenever you need to know the country of the user.
7
8
  #
8
9
  # === Example
9
10
  #
@@ -16,7 +17,7 @@ require 'cloudflare_localizable/country'
16
17
  # end
17
18
  # end
18
19
  module CloudFlareLocalizable
19
- CF_HEADER = 'HTTP_CF_IPCOUNTRY'.freeze
20
+ CF_HEADER = 'HTTP_CF_IPCOUNTRY'
20
21
 
21
22
  def self.included(base)
22
23
  base.send(:helper_method, :cf_country)
@@ -24,6 +25,6 @@ module CloudFlareLocalizable
24
25
 
25
26
  # Returns the real name of the country, based on the country code.
26
27
  def cf_country
27
- @_cf_country ||= Country.find(request.headers[CF_HEADER] || 'XX')
28
+ @cf_country ||= Country.find(request.headers[CF_HEADER] || 'XX')
28
29
  end
29
30
  end
@@ -1,16 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'cloudflare_localizable/country_list'
2
4
 
3
5
  module CloudFlareLocalizable
6
+ # This class represents a country, and stores name and code for the countries.
7
+ #
8
+ # === Example
9
+ #
10
+ # country = Country.find('BB')
11
+ # country.code # => "BB"
12
+ # country.name # => "Barbados"
4
13
  class Country
5
14
  attr_accessor :name, :code
6
15
 
7
16
  def self.find(code)
8
- record = CF_COUNTRIES.find { |country| country[:code] == code }
17
+ record = CF_COUNTRIES.find { |country| country[:code] == code } || {}
9
18
 
10
- new(record[:code], record[:name])
19
+ new(record.fetch(:code, 'XX'), record.fetch(:name, 'Unknown'))
11
20
  end
12
21
 
13
- def initialize(code, name)
22
+ def initialize(code = 'XX', name = 'Unknown')
14
23
  self.code = code
15
24
  self.name = name
16
25
  end
@@ -1,4 +1,5 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  module CloudFlareLocalizable
3
4
  # Countries
4
5
  CF_COUNTRIES = [
@@ -252,5 +253,5 @@ module CloudFlareLocalizable
252
253
  { code: 'ZM', name: 'Zambia' },
253
254
  { code: 'ZW', name: 'Zimbabwe' },
254
255
  { code: 'XX', name: 'Unknown' }
255
- ]
256
+ ].freeze
256
257
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CloudFlareLocalizable
2
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
3
5
  end
metadata CHANGED
@@ -1,15 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudflare_localizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2018-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.2.5
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.2.5
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: bundler
15
35
  requirement: !ruby/object:Gem::Requirement
@@ -59,25 +79,19 @@ dependencies:
59
79
  - !ruby/object:Gem::Version
60
80
  version: 3.4.0
61
81
  - !ruby/object:Gem::Dependency
62
- name: actionpack
82
+ name: rubocop
63
83
  requirement: !ruby/object:Gem::Requirement
64
84
  requirements:
65
85
  - - "~>"
66
86
  - !ruby/object:Gem::Version
67
- version: '4.2'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 4.2.5
87
+ version: 0.54.0
71
88
  type: :development
72
89
  prerelease: false
73
90
  version_requirements: !ruby/object:Gem::Requirement
74
91
  requirements:
75
92
  - - "~>"
76
93
  - !ruby/object:Gem::Version
77
- version: '4.2'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 4.2.5
94
+ version: 0.54.0
81
95
  description: |-
82
96
  If you're using CloudFlare you can easily get the location of your requests
83
97
  based on a special header that CloudFlare attaches to every request.
@@ -89,6 +103,7 @@ extra_rdoc_files: []
89
103
  files:
90
104
  - ".gitignore"
91
105
  - ".rspec"
106
+ - ".rubocop.yml"
92
107
  - ".ruby-version"
93
108
  - ".travis.yml"
94
109
  - Gemfile
@@ -122,9 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
137
  version: '0'
123
138
  requirements: []
124
139
  rubyforge_project:
125
- rubygems_version: 2.4.5.1
140
+ rubygems_version: 2.7.3
126
141
  signing_key:
127
142
  specification_version: 4
128
143
  summary: Localize your requests with CloudFlare.
129
144
  test_files: []
130
- has_rdoc: