everett 0.2.2 → 0.3.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: 2020c2867e74578114203161f55406734f7de0c1
4
- data.tar.gz: 10a86170f32232631d56b5422032501019e3afa4
3
+ metadata.gz: 76ba4a01771b029f28c60867e66b3068f99753df
4
+ data.tar.gz: 04db4ea215cf000b6c3dd4ad46fb53a23050e4d7
5
5
  SHA512:
6
- metadata.gz: ef55d9c3d72f24c36ca2dd6ab634c30f94b57647ff9e46a590f4c17375f3d405f3994adda4d1d8ed5b6e10017d8c61e74c5a1c7c1ec4fe75f450d7bc0f5dc399
7
- data.tar.gz: 2d93e2ead15ba80352d72734cdb52a4ea06a5119308b576ae93f3af96f664f0e613992a58e42aa3c68633edf85a2e06539e6749821acca2eae1f103e3f82ef94
6
+ metadata.gz: bbd0e301693328ff85c1e3a26c18e0ffde43dec2926590f84c87b6c667095723e19721a8984f1d78dff52d7b56e1bd88e73ac1eb480c02068a31413110b993f8
7
+ data.tar.gz: b7d672ae6882bc1983b1637ee2e94b25c06dfd0d43715c2bf62917d10b22c01cbd7d8cf95785b7e25ef94aef8a42c2f78949f9006bb3ac0ccf02c3b17bed37a2
@@ -1,4 +1,7 @@
1
1
  # CHANGELOG
2
+ ## [0.3.0](https://github.com/yasaichi/everett/releases/tag/v0.3.0) (May 4, 2017)
3
+ * [Implement generators to create a new observer and its test](https://github.com/yasaichi/everett/pull/5)
4
+
2
5
  ## [0.2.2](https://github.com/yasaichi/everett/releases/tag/v0.2.2) (December 27, 2016)
3
6
  * [Fix bug of after\_{create,update,destroy}\_commit callbacks](https://github.com/yasaichi/everett/pull/3)
4
7
  * Minor fix on README
@@ -1,4 +1,4 @@
1
- Copyright 2016 yasaichi
1
+ Copyright 2016 Yuichi Goto
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Code Climate](https://codeclimate.com/github/yasaichi/everett/badges/gpa.svg)](https://codeclimate.com/github/yasaichi/everett)
5
5
  [![Test Coverage](https://codeclimate.com/github/yasaichi/everett/badges/coverage.svg)](https://codeclimate.com/github/yasaichi/everett/coverage)
6
6
 
7
- Everett is a substitute for `ActiveRecord::Observer` on Rails 5.
7
+ Everett is a substitute for Active Record Observer on Rails 5.
8
8
 
9
9
  ## Installation
10
10
  Put this in your Gemfile:
@@ -29,18 +29,18 @@ You can put them anywhere, for example `app/observers/contact_observer.rb`:
29
29
  ```ruby
30
30
  class ContactObserver < Everett::Observer
31
31
  def after_create(contact)
32
- Rails.logger.info('New contact added!')
32
+ Rails.logger.info('New contact has been added!')
33
33
  end
34
34
 
35
35
  def after_destroy(contact)
36
- Rails.logger.info("Contact with an id of #{contact.id} was destroyed!")
36
+ Rails.logger.info("Contact with an id of #{contact.id} has been destroyed!")
37
37
  end
38
38
  end
39
39
  ```
40
40
 
41
41
  This observer prints a log message when specific callbacks are triggered.
42
42
 
43
- Just like `ActiveRecord::Observer`, the convention is to name observers after the class they observe.
43
+ Just like Active Record Observer, the convention is to name observers after the class they observe.
44
44
  If you need to change this, or want to use one observer for several classes, use `observe`:
45
45
 
46
46
  ```ruby
@@ -75,7 +75,7 @@ end
75
75
  This observer sends an email after a record has been created.
76
76
 
77
77
  ## Migration from rails-observers
78
- Since Everett is highly compatible with `ActiveRecord::Observer`,
78
+ Since Everett is highly compatible with Active Record Observer,
79
79
  you can easily migrate from [rails-observers](https://github.com/rails/rails-observers).
80
80
  All you need to do is as follows:
81
81
 
@@ -104,7 +104,7 @@ You should follow the steps below.
104
104
 
105
105
  1. [Fork the repository](https://help.github.com/articles/fork-a-repo/)
106
106
  2. Create a feature branch: `git checkout -b add-new-feature`
107
- 3. Commit your changes: `git commit -am 'add new feature'`
107
+ 3. Commit your changes: `git commit -am 'Add new feature'`
108
108
  4. Push the branch: `git push origin add-new-feature`
109
109
  4. [Send us a pull request](https://help.github.com/articles/about-pull-requests/)
110
110
 
@@ -1,3 +1,3 @@
1
1
  module Everett
2
- VERSION = "0.2.2".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
@@ -1,8 +1,8 @@
1
1
  Description:
2
- Create a Everett initializer
2
+ Creates an Everett initializer.
3
3
 
4
4
  Example:
5
- rails generate everett:install
5
+ `rails generate everett:install`
6
6
 
7
7
  This will create:
8
8
  config/initializers/everett.rb
@@ -1,7 +1,9 @@
1
+ require "rails/generators/base"
2
+
1
3
  module Everett
2
4
  module Generators
3
5
  class InstallGenerator < ::Rails::Generators::Base
4
- source_root File.expand_path("../templates", __FILE__)
6
+ source_root ::File.expand_path("../templates", __FILE__)
5
7
 
6
8
  def copy_initializer_file
7
9
  template "everett.rb", "config/initializers/everett.rb"
@@ -0,0 +1,10 @@
1
+ Description:
2
+ Stubs out a new observer. Pass the observer name, either CamelCased or
3
+ under_scored, as an argument.
4
+
5
+ Example:
6
+ `rails generate observer Account`
7
+
8
+ This will create:
9
+ app/models/account_observer.rb
10
+ test/unit/account_observer_test.rb (as needed)
@@ -0,0 +1,17 @@
1
+ require "rails/generators/named_base"
2
+
3
+ module Rails
4
+ module Generators
5
+ class ObserverGenerator < ::Rails::Generators::NamedBase
6
+ check_class_collision suffix: "Observer"
7
+ source_root ::File.expand_path("../templates", __FILE__)
8
+
9
+ def create_observer_file
10
+ destination = ::File.join("app/models", class_path, "#{file_name}_observer.rb")
11
+ template "observer.rb.erb", destination
12
+ end
13
+
14
+ hook_for :test_framework
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ <% module_namespacing do -%>
2
+ class <%= class_name %>Observer < Everett::Observer
3
+ end
4
+ <% end -%>
@@ -0,0 +1,15 @@
1
+ require "rails/generators/test_unit"
2
+
3
+ module TestUnit
4
+ module Generators
5
+ class ObserverGenerator < ::TestUnit::Generators::Base
6
+ check_class_collision suffix: "ObserverTest"
7
+ source_root ::File.expand_path("../templates", __FILE__)
8
+
9
+ def create_test_file
10
+ destination = ::File.join("test/unit", class_path, "#{file_name}_observer_test.rb")
11
+ template "observer_test.rb.erb", destination
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ require "test_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>ObserverTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ <% end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everett
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yasaichi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-27 00:00:00.000000000 Z
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: appraisal
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: codeclimate-test-reporter
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -164,7 +178,7 @@ dependencies:
164
178
  - - ">="
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
- description: Everett is a substitute for ActiveRecord::Observer on Rails 5.
181
+ description: Everett is a substitute for Active Record Observer on Rails 5.
168
182
  email:
169
183
  - yasaichi@users.noreply.github.com
170
184
  executables: []
@@ -185,6 +199,11 @@ files:
185
199
  - lib/generators/everett/install/USAGE
186
200
  - lib/generators/everett/install/install_generator.rb
187
201
  - lib/generators/everett/install/templates/everett.rb
202
+ - lib/generators/rails/observer/USAGE
203
+ - lib/generators/rails/observer/observer_generator.rb
204
+ - lib/generators/rails/observer/templates/observer.rb.erb
205
+ - lib/generators/test_unit/observer/observer_generator.rb
206
+ - lib/generators/test_unit/observer/templates/observer_test.rb.erb
188
207
  - lib/tasks/everett_tasks.rake
189
208
  homepage: https://github.com/yasaichi/everett
190
209
  licenses:
@@ -209,5 +228,5 @@ rubyforge_project:
209
228
  rubygems_version: 2.5.1
210
229
  signing_key:
211
230
  specification_version: 4
212
- summary: Substitute for ActiveRecord::Observer on Rails 5
231
+ summary: Substitute for Active Record Observer on Rails 5
213
232
  test_files: []