userlist-rails 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4ac0764bfdecbc381ea029d3fa9e8e2b04aa7f668eff35f7f54d14b7e20d1e9
4
- data.tar.gz: 31e4be6a0b8fe3b5a7cf172b9a07af9e6e5dac7a9edd38751b39416ddee8ad9e
3
+ metadata.gz: 68ee452ebc6c542be2b06dcf5ab4e7126f1cfdd0088ddc7708dcf1f219bc32fc
4
+ data.tar.gz: 3f24039dbd0f67ca37b1149aac2f6503a1e58e191b91302a36e3e4cda2087701
5
5
  SHA512:
6
- metadata.gz: 3053ce85e9cc0d218dec274d0a11b5e0fb9caac714b999a2e3a0995946b17ae5f0180159fd978ecc91c890230cf8c744d3e9ddcfe67f1b035eb19c610ce49bbd
7
- data.tar.gz: 0a426f64b71938dfea7112c62d96b97e568a47db3a8f1780571ad3612d0f7f39e8cc8c6f2511a5344b95785ad4efe18e8a5f9e912c886a9f2587601716bf2b46
6
+ metadata.gz: a2cf9f06f634611f304ba6c42ef840178f1add57063c0148b7bc1b791167ce18b60b6f69e6df759262c50a16864761873db52e41fee15ee7e37a1111d4ba0121
7
+ data.tar.gz: b1723c2aa4205c30ddeca3080addb0c5330bf428ee9f3990867da01531bf05d215bfa65f4538c91ea7307c85e6e9bfc0832826df57cc762e4c725f34f4c8966f
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.2
2
+ TargetRubyVersion: 2.3
3
3
  Exclude:
4
4
  - 'bin/*'
5
5
  - 'Guardfile'
@@ -32,13 +32,10 @@ Layout/ElseAlignment:
32
32
  Lint/AssignmentInCondition:
33
33
  Enabled: false
34
34
 
35
- Lint/EndAlignment:
36
- EnforcedStyleAlignWith: start_of_line
37
-
38
35
  Layout/AccessModifierIndentation:
39
36
  EnforcedStyle: outdent
40
37
 
41
- Layout/AlignParameters:
38
+ Layout/ParameterAlignment:
42
39
  EnforcedStyle: with_fixed_indentation
43
40
 
44
41
  Style/FrozenStringLiteralComment:
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2
4
3
  - 2.3
5
4
  - 2.4
6
5
  - 2.5
7
6
  - 2.6
7
+ - 2.7
@@ -6,7 +6,8 @@ module Userlist
6
6
  DEFAULT_CONFIGURATION = {
7
7
  user_model: nil,
8
8
  company_model: nil,
9
- auto_discover: true
9
+ auto_discover: true,
10
+ script_url: 'https://js.userlist.com/v1'
10
11
  }.freeze
11
12
 
12
13
  def default_config
@@ -18,13 +19,11 @@ module Userlist
18
19
  end
19
20
 
20
21
  def user_model
21
- model = super
22
- model && model.to_s.constantize
22
+ super&.to_s&.constantize
23
23
  end
24
24
 
25
25
  def company_model
26
- model = super
27
- model && model.to_s.constantize
26
+ super&.to_s&.constantize
28
27
  end
29
28
 
30
29
  Userlist::Config.send(:prepend, self)
@@ -0,0 +1,33 @@
1
+ module Userlist
2
+ module Rails
3
+ module Helpers
4
+ def userlist_script_tag(*args)
5
+ config = Userlist.config
6
+ logger = Userlist.logger
7
+
8
+ options = args.extract_options!
9
+
10
+ user = args.first
11
+ user ||= current_user if respond_to?(:current_user)
12
+ user ||= Userlist::Rails.current_user
13
+
14
+ options[:async] = true
15
+
16
+ if user
17
+ identifier = user.userlist_identifier
18
+
19
+ options[:data] ||= {}
20
+ options[:data][:userlist] = Userlist::Token.generate(identifier)
21
+ end
22
+
23
+ script_tag = javascript_tag('window.userlist=window.userlist||function(){(userlist.q=userlist.q||[]).push(arguments)};')
24
+ include_tag = javascript_include_tag(config.script_url, options)
25
+
26
+ script_tag + include_tag
27
+ rescue Userlist::Error => e
28
+ logger.error(e.message)
29
+ raw("<!-- #{e.class}: #{e.message} -->") unless ::Rails.env.production?
30
+ end
31
+ end
32
+ end
33
+ end
@@ -9,6 +9,8 @@ require 'userlist/rails/company'
9
9
  require 'userlist/rails/extensions/resource'
10
10
  require 'userlist/rails/extensions/event'
11
11
 
12
+ require 'userlist/rails/helpers'
13
+
12
14
  module Userlist
13
15
  module Rails
14
16
  class Railtie < ::Rails::Railtie
@@ -26,9 +28,15 @@ module Userlist
26
28
  end
27
29
  end
28
30
 
31
+ initializer 'userlist.helpers' do
32
+ ActiveSupport.on_load :action_view do
33
+ include Userlist::Rails::Helpers
34
+ end
35
+ end
36
+
29
37
  initializer 'userlist.extensions' do
30
- Userlist::Push::Resource.send(:prepend, Userlist::Rails::Extensions::Resource)
31
- Userlist::Push::Event.send(:prepend, Userlist::Rails::Extensions::Event)
38
+ Userlist::Push::Resource.prepend(Userlist::Rails::Extensions::Resource)
39
+ Userlist::Push::Event.prepend(Userlist::Rails::Extensions::Event)
32
40
  end
33
41
 
34
42
  initializer 'userlist.models' do
@@ -1,5 +1,5 @@
1
1
  module Userlist
2
2
  module Rails
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -4,6 +4,8 @@ require 'userlist/rails/railtie'
4
4
  require 'userlist/rails/extensions/resource'
5
5
  require 'userlist/rails/extensions/event'
6
6
 
7
+ require 'userlist/rails/helpers'
8
+
7
9
  module Userlist
8
10
  module Rails
9
11
  def self.with_current_user(user)
@@ -19,12 +19,16 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency 'activesupport', '>= 3.0'
23
- spec.add_dependency 'railties', '>= 3.0'
24
- spec.add_dependency 'userlist', '~> 0.3'
22
+ spec.required_ruby_version = '>= 2.3'
25
23
 
24
+ spec.add_dependency 'activesupport', '>= 5.0'
25
+ spec.add_dependency 'railties', '>= 5.0'
26
+ spec.add_dependency 'userlist', '~> 0.4'
27
+
28
+ spec.add_development_dependency 'actionpack', '>= 5.0'
26
29
  spec.add_development_dependency 'bundler', '>= 1.15'
27
- spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
28
31
  spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'rspec-rails', '~> 3.0'
29
33
  spec.add_development_dependency 'webmock', '~> 1.22'
30
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: userlist-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benedikt Deicke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-27 00:00:00.000000000 Z
11
+ date: 2020-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,42 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '5.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.0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '5.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: userlist
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.3'
47
+ version: '0.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.3'
54
+ version: '0.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: actionpack
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,20 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '10.0'
89
+ version: '12.3'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 12.3.3
76
93
  type: :development
77
94
  prerelease: false
78
95
  version_requirements: !ruby/object:Gem::Requirement
79
96
  requirements:
80
97
  - - "~>"
81
98
  - !ruby/object:Gem::Version
82
- version: '10.0'
99
+ version: '12.3'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 12.3.3
83
103
  - !ruby/object:Gem::Dependency
84
104
  name: rspec
85
105
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +114,20 @@ dependencies:
94
114
  - - "~>"
95
115
  - !ruby/object:Gem::Version
96
116
  version: '3.0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rspec-rails
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '3.0'
97
131
  - !ruby/object:Gem::Dependency
98
132
  name: webmock
99
133
  requirement: !ruby/object:Gem::Requirement
@@ -134,6 +168,7 @@ files:
134
168
  - lib/userlist/rails/config.rb
135
169
  - lib/userlist/rails/extensions/event.rb
136
170
  - lib/userlist/rails/extensions/resource.rb
171
+ - lib/userlist/rails/helpers.rb
137
172
  - lib/userlist/rails/importer.rb
138
173
  - lib/userlist/rails/logger.rb
139
174
  - lib/userlist/rails/railtie.rb
@@ -152,14 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
187
  requirements:
153
188
  - - ">="
154
189
  - !ruby/object:Gem::Version
155
- version: '0'
190
+ version: '2.3'
156
191
  required_rubygems_version: !ruby/object:Gem::Requirement
157
192
  requirements:
158
193
  - - ">="
159
194
  - !ruby/object:Gem::Version
160
195
  version: '0'
161
196
  requirements: []
162
- rubygems_version: 3.0.3
197
+ rubygems_version: 3.0.4
163
198
  signing_key:
164
199
  specification_version: 4
165
200
  summary: Rails integration for Userlist.io