flash_messenger 0.0.2 → 0.1.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
  SHA1:
3
- metadata.gz: 83747bc93a115a67ff3fe2129aa21496797cb403
4
- data.tar.gz: 05ef72de26933c136281e0a4f3239b19515ea540
3
+ metadata.gz: 4191882f83afac61d731e9bb6522c12481fe4db1
4
+ data.tar.gz: 459efdc00fd2d0ad0ff50af619c13efeb6fe9178
5
5
  SHA512:
6
- metadata.gz: f20e2c6b5c28cd9f8aab2c993073f1e1ecc6a8a27bc00ef7ab42a105746d37c70d5d5a0e1fb24fd61510ef05ad6c9a6a8bd2e8ec7c00bf48c6542ffa1fca508e
7
- data.tar.gz: 8b1f82b0b667b41d5be32ecdf1b4139da95629bc2b432fd681383377c59cfb276a86de711918a45c3e7372a7e56f01c59adda6fb569ecf7441f5910173d7adf4
6
+ metadata.gz: 3fd39cf68d5cf40627881ba0f7a19afc6acca4bec5245323c484fbdb8abdde770bc333cfa5414c71887faee78b8494907b5af9d3393583917eb910dde673ab41
7
+ data.tar.gz: 51a63ec4c3bfb4d7b959cb657167cabe9221720ce75cb76c788d88630a647f99f2bc8d669c1f3445e6fd87ade91399e91f58af1cc8d102ca60aa5fccb277192d
@@ -0,0 +1 @@
1
+ ruby-2.2.4
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+
3
+ bundler_args: '--with=development --jobs=3 --retry=3 --verbose'
4
+
5
+ rvm:
6
+ - 2.2.4
7
+
8
+ sudo: false
9
+
10
+ cache:
11
+ bundler: true
12
+
13
+ git:
14
+ depth: 15
15
+
16
+ notifications:
17
+ email: false
18
+
19
+ script: bundle exec rspec spec/
20
+
21
+ matrix:
22
+ fast_finish: true
@@ -19,7 +19,7 @@
19
19
  # To learn more, please read the Rails Internationalization guide
20
20
  # available at http://guides.rubyonrails.org/i18n.html.
21
21
 
22
- en-US:
22
+ en:
23
23
  development:
24
24
  lorem_ipsum_1: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce id lobortis tortor. Nam cursus pharetra purus non elementum. Sed eu libero leo. Aliquam eget justo vel odio consectetur facilisis id a sapien. Duis pulvinar tincidunt suscipit. Quisque volutpat justo vitae fringilla lacinia. Aenean semper, nulla at mattis sagittis, purus felis aliquet lorem, sit amet suscipit dolor elit nec tellus. Pellentesque interdum nulla maximus massa elementum, at posuere augue scelerisque.
25
25
  lorem_ipsum_2: Nulla sagittis quam at est tincidunt, at consectetur leo vehicula. Vestibulum et faucibus odio. Vivamus interdum consectetur metus vitae aliquam. Integer vitae felis diam. Vestibulum consectetur dictum magna eget finibus. Integer sit amet interdum augue. Nullam ultricies malesuada odio, at tincidunt nisi semper nec. Pellentesque vitae convallis ligula. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Ut vitae risus blandit, sodales nulla at, placerat dui.
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.required_ruby_version = '>= 2.0.0'
21
21
 
22
- spec.add_dependency 'rails', '>= 4.0'
22
+ spec.add_dependency 'rails', '~> 4.2'
23
23
  spec.add_dependency 'activesupport', '>= 4.0'
24
24
 
25
25
  spec.add_development_dependency 'factory_girl'
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rspec'
28
28
  spec.add_development_dependency 'rspec-rails'
29
29
  spec.add_development_dependency 'rubocop'
30
- # spec.add_development_dependency 'sqlite3'
30
+ spec.add_development_dependency 'sqlite3'
31
31
  spec.add_development_dependency 'pry'
32
32
  end
@@ -1,9 +1,2 @@
1
1
  require 'flash_messenger/engine'
2
2
  require 'flash_messenger/controller_injection'
3
-
4
- module FlashMessenger
5
- DEFAULT_LOCALE = :'en-US'
6
- # Rails.configuration.tap do |c|
7
- # DEFAULT_LOCALE = c.flash_messenger.default_locale || c.i18n.default_locale
8
- # end
9
- end
@@ -10,5 +10,16 @@ module FlashMessenger
10
10
  g.assets false
11
11
  g.helper false
12
12
  end
13
+
14
+ initializer 'flash_messenger.default_locale' do |app|
15
+ app.config.tap do |c|
16
+ default_locale = \
17
+ c.try(:flash_messenger).try(:default_locale) ||
18
+ c.try(:i18n).try(:default_locale) ||
19
+ :en
20
+
21
+ ::FlashMessenger::DEFAULT_LOCALE = default_locale
22
+ end
23
+ end
13
24
  end
14
25
  end
@@ -58,16 +58,18 @@ module FlashMessenger
58
58
  end
59
59
 
60
60
  def match?(other)
61
- if other.is_a?(Base)
61
+ if other.is_a?(self.class)
62
62
  us = "#{self.class_name}, #{self.level}, #{self.message}"
63
63
  them = "#{self.class_name}, #{self.level}, #{self.message}"
64
- us =~ them
64
+ return us =~ them
65
65
  elsif other.is_a?(String)
66
- self.to_s =~ other
66
+ return self.to_s =~ %r(#{other})
67
67
  end
68
+
68
69
  nil
69
70
  end
70
71
 
72
+ alias_method :match, :match?
71
73
  alias_method :==, :eql?
72
74
 
73
75
  #
@@ -1,3 +1,3 @@
1
1
  module FlashMessenger
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -17,6 +17,6 @@ module Dummy
17
17
 
18
18
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
19
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
20
+ config.i18n.default_locale = :en
21
21
  end
22
22
  end
@@ -20,6 +20,10 @@ test:
20
20
  <<: *default
21
21
  database: db/test.sqlite3
22
22
 
23
+ travis:
24
+ <<: *default
25
+ database: ':memory:'
26
+
23
27
  production:
24
28
  <<: *default
25
29
  database: db/production.sqlite3
@@ -13,7 +13,7 @@ Rails.application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
16
+ config.serve_static_files = true
17
17
  config.static_cache_control = 'public, max-age=3600'
18
18
 
19
19
  # Show full error reports and disable caching.
@@ -1,61 +1,5 @@
1
1
  require 'rails_helper'
2
2
 
3
- RSpec.shared_examples 'a helper which yields message of kind' do |klass, target, *args|
4
- let(:klazz) { public_send(klass) }
5
-
6
- let(:instance) do
7
- subject.public_send(target, *(args.map { |i| public_send(i) }))
8
- end
9
-
10
- it_behaves_like 'a message instance of kind', :klazz, :instance
11
- end
12
-
13
- RSpec.shared_examples 'a message instance of kind' do |klass, target|
14
- let(:kind) { public_send(klass) }
15
- let(:victim) { public_send(target) }
16
-
17
- it "returns an instance of #{klass}" do
18
- expect(victim).to be_a(kind)
19
- end
20
-
21
- context '#serialization' do
22
- it 'serializes and deserializes properly' do
23
- expect(victim.to_session).to be_a(String)
24
-
25
- another_victim = victim.class.from_session(victim.to_session)
26
-
27
- expect(another_victim).to eq(victim)
28
- end
29
- end
30
-
31
- # Note: inherits default_message from calling context
32
- context '#message' do
33
- it 'has the expected message' do
34
- expect(victim.message).to eq(default_message)
35
- end
36
- end
37
-
38
- context '#eql?' do
39
- it 'equals another message instance with the same string' do
40
- another_victim = victim.dup
41
- expect(another_victim).to eq(victim)
42
- expect(another_victim.__id__).not_to eq(victim.__id__)
43
- end
44
- end
45
-
46
- context '#match?' do
47
- it 'matches the string value' do
48
- expect(victim).to match(victim.message)
49
- end
50
- end
51
-
52
- context '#type?' do
53
- it 'exposes its type helper properly' do
54
- expect(victim.public_send("#{victim.level}?")).to be_truthy
55
- end
56
- end
57
- end
58
-
59
3
  RSpec.describe FlashMessenger::Messages::Base do
60
4
  subject { FlashMessenger::Messages::Base }
61
5
 
@@ -116,7 +116,7 @@ RSpec.describe FlashMessenger::Storage do
116
116
 
117
117
  let(:expected_json) do
118
118
  {
119
- "locale" => "en-US",
119
+ "locale" => "en",
120
120
  "messages" => [
121
121
  {
122
122
  "i18n_params" => { "raise" => true },
@@ -19,7 +19,7 @@ Dir[File.expand_path('../../spec/support/**/*.rb', __FILE__)].each { |f| require
19
19
 
20
20
  require 'i18n'
21
21
  I18n.load_path = Dir['config/locales/**/*.yml']
22
- I18n.default_locale = :'en-US'
22
+ I18n.default_locale = :en
23
23
 
24
24
  RSpec.configure do |config|
25
25
  # rspec-expectations config goes here. You can use an alternate
@@ -24,3 +24,59 @@ RSpec.shared_examples 'a public accessor method' do |target, *args|
24
24
  expect(result).to eq(expected)
25
25
  end
26
26
  end
27
+
28
+ RSpec.shared_examples 'a helper which yields message of kind' do |klass, target, *args|
29
+ let(:klazz) { public_send(klass) }
30
+
31
+ let(:instance) do
32
+ subject.public_send(target, *(args.map { |i| public_send(i) }))
33
+ end
34
+
35
+ it_behaves_like 'a message instance of kind', :klazz, :instance
36
+ end
37
+
38
+ RSpec.shared_examples 'a message instance of kind' do |klass, target|
39
+ let(:kind) { public_send(klass) }
40
+ let(:victim) { public_send(target) }
41
+
42
+ it "returns an instance of #{klass}" do
43
+ expect(victim).to be_a(kind)
44
+ end
45
+
46
+ context '#serialization' do
47
+ it 'serializes and deserializes properly' do
48
+ expect(victim.to_session).to be_a(String)
49
+
50
+ another_victim = victim.class.from_session(victim.to_session)
51
+
52
+ expect(another_victim).to eq(victim)
53
+ end
54
+ end
55
+
56
+ # Note: inherits default_message from calling context
57
+ context '#message' do
58
+ it 'has the expected message' do
59
+ expect(victim.message).to eq(default_message)
60
+ end
61
+ end
62
+
63
+ context '#eql?' do
64
+ it 'equals another message instance with the same string' do
65
+ another_victim = victim.dup
66
+ expect(another_victim).to eq(victim)
67
+ expect(another_victim.__id__).not_to eq(victim.__id__)
68
+ end
69
+ end
70
+
71
+ context '#match?' do
72
+ it 'matches the string value' do
73
+ expect(victim).to match(victim.message)
74
+ end
75
+ end
76
+
77
+ context '#type?' do
78
+ it 'exposes its type helper properly' do
79
+ expect(victim.public_send("#{victim.level}?")).to be_truthy
80
+ end
81
+ end
82
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_messenger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Eberlin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.2'
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: '4.0'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +147,8 @@ files:
133
147
  - ".gitignore"
134
148
  - ".rspec"
135
149
  - ".rubocop.yml"
150
+ - ".ruby-version"
151
+ - ".travis.yml"
136
152
  - Gemfile
137
153
  - LICENSE.txt
138
154
  - README.rdoc
@@ -145,7 +161,7 @@ files:
145
161
  - app/models/.keep
146
162
  - app/views/.keep
147
163
  - bin/rails
148
- - config/locales/en-US.yml
164
+ - config/locales/en.yml
149
165
  - config/routes.rb
150
166
  - flash_messenger.gemspec
151
167
  - lib/flash_messenger.rb
@@ -204,7 +220,6 @@ files:
204
220
  - spec/dummy/public/favicon.ico
205
221
  - spec/dummy/spec/controllers/index_controller_spec.rb
206
222
  - spec/dummy/spec/helpers/index_helper_spec.rb
207
- - spec/examples/shared_examples.rb
208
223
  - spec/features/messages/base_spec.rb
209
224
  - spec/features/messages/nonpersistent_spec.rb
210
225
  - spec/features/messages/persistent_spec.rb
@@ -284,7 +299,6 @@ test_files:
284
299
  - spec/dummy/public/favicon.ico
285
300
  - spec/dummy/spec/controllers/index_controller_spec.rb
286
301
  - spec/dummy/spec/helpers/index_helper_spec.rb
287
- - spec/examples/shared_examples.rb
288
302
  - spec/features/messages/base_spec.rb
289
303
  - spec/features/messages/nonpersistent_spec.rb
290
304
  - spec/features/messages/persistent_spec.rb
@@ -1,27 +0,0 @@
1
-
2
- # These shared example test that a subject's accessor method is:
3
- #
4
- # A) Publicly exposed
5
- # B) Not nil
6
- # c) Result "equal" to the `let` with the same name in context
7
- #
8
- # @param [Symbol] Method name as symbol
9
- # @param [*args] Arbitrary arguments to pass to the `send` call
10
- #
11
- RSpec.shared_examples 'a public accessor method' do |target, *args|
12
- let(:result) do
13
- subject.public_send(target, *(args.map { |i| public_send(i) }))
14
- end
15
-
16
- let(:expected) do
17
- public_send(target)
18
- end
19
-
20
- it "publicly exposes ##{target}" do
21
- expect(result).not_to be_nil
22
- end
23
-
24
- it 'has expected values' do
25
- expect(result).to eq(expected)
26
- end
27
- end