gritter_notices 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +109 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/app/models/gritter_notice.rb +43 -0
- data/lib/generators/gritter_notices_generator.rb +23 -0
- data/lib/generators/templates/migration.rb +23 -0
- data/lib/gritter_notices/active_record.rb +48 -0
- data/lib/gritter_notices/rspec_matcher.rb +40 -0
- data/lib/gritter_notices/view_helpers.rb +61 -0
- data/lib/gritter_notices.rb +13 -0
- data/spec/gritter_notice_spec.rb +12 -0
- data/spec/notice_spec.rb +12 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/factories.rb +8 -0
- data/spec/support/user.rb +4 -0
- metadata +233 -0
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem 'gritter'
|
7
|
+
gem 'activerecord'
|
8
|
+
gem 'actionpack'
|
9
|
+
|
10
|
+
# Add dependencies to develop your gem here.
|
11
|
+
# Include everything needed to run rake, tests, features, etc.
|
12
|
+
group :development do
|
13
|
+
gem 'activerecord-nulldb-adapter'
|
14
|
+
gem 'factory_girl'
|
15
|
+
gem 'shoulda'
|
16
|
+
gem "rspec", "~> 2.3.0"
|
17
|
+
gem "bundler", "~> 1.0.0"
|
18
|
+
gem "jeweler", "~> 1.5.2"
|
19
|
+
gem "rcov", ">= 0"
|
20
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Danil Pismenny
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
= gritter_notices
|
2
|
+
|
3
|
+
Использует модуль gritter для отображения flash сообщеий, а также вводит механизм сохраняемых пользовательских сообщений (notice).
|
4
|
+
|
5
|
+
Удобно применять для отправки пользователю flash-сообщений из фоновых задач.
|
6
|
+
|
7
|
+
Визуально выглядит так: http://boedesign.com/demos/gritter/
|
8
|
+
|
9
|
+
== Установка
|
10
|
+
|
11
|
+
Включаем модуль в Gemfile, незабываем затем сделать bundle install:
|
12
|
+
|
13
|
+
gem 'gritter' # неабываем его далее установить согласно документации
|
14
|
+
gem 'gritter_notices'
|
15
|
+
|
16
|
+
Создаем таблицу `gritter_notices`
|
17
|
+
|
18
|
+
rails g gritter_notices
|
19
|
+
rake db:migrate
|
20
|
+
|
21
|
+
Подключаем в notices в модель user:
|
22
|
+
|
23
|
+
has_gritter_notices
|
24
|
+
|
25
|
+
Где-то в layout делаем так (haml-пример):
|
26
|
+
|
27
|
+
%head
|
28
|
+
= include_gritter
|
29
|
+
%body
|
30
|
+
= gflash // session сообщения добавляемые через gritter-овский gflash :success=>траляля
|
31
|
+
= gritter_flash_messages // Все остальные сообщения добавляемые через flash[:success] или notice
|
32
|
+
|
33
|
+
== Использование
|
34
|
+
|
35
|
+
В расширяемую модель добавляются метод `notice`. Агрументы:
|
36
|
+
|
37
|
+
* Текстовое сообщение (String) или ключ к строке локали (Symbol)
|
38
|
+
* Хеш опций прозрачно сохраняемых в модели и используемые при подстановке в `I18n::translate`.
|
39
|
+
** В хеше опций пожно указать :scope для трансляции локали (по умолчанию `:gritter_notices`) и
|
40
|
+
** `:level` из поддерживаемых gritter-ом - [:success, :warning, :notice, :error, :progress], по умолчанию :notice
|
41
|
+
** :title
|
42
|
+
** :sticky
|
43
|
+
** другие опции понимаемые gritter-ом
|
44
|
+
|
45
|
+
Примеры использования:
|
46
|
+
|
47
|
+
user.notice 'Просто текстовое сообщение'
|
48
|
+
user.notice 'Текстовое сообщение', :level=>:notice
|
49
|
+
|
50
|
+
если в локали указать
|
51
|
+
|
52
|
+
ru:
|
53
|
+
gritter_notices:
|
54
|
+
import_contacts: Импортиорваны контакты (%{count})
|
55
|
+
|
56
|
+
то можно будет использовать ключ, вместо текстового сообщения:
|
57
|
+
|
58
|
+
user.notice :import_contacts, :count=>123
|
59
|
+
|
60
|
+
Для краткости можно :level указывать через подчеркивание после названия метода `notice`:
|
61
|
+
|
62
|
+
notice_success
|
63
|
+
notice_error
|
64
|
+
notice_warning
|
65
|
+
notice_progress
|
66
|
+
notice_notice # синоним просто `notice`
|
67
|
+
|
68
|
+
Далее во вьюхе вызываем:
|
69
|
+
|
70
|
+
= gritter_flash_messages
|
71
|
+
|
72
|
+
который отображает и flash сообщения и накопвшиеся `notices`.
|
73
|
+
|
74
|
+
== Дополнительно
|
75
|
+
|
76
|
+
Поддерживается `universal_flash_messages` и `flash-message-conductor`, тоесть сохранение во flash массивов сообщений, типа:
|
77
|
+
|
78
|
+
flash[:notice] = ['Сообщение1', 'Сообщение2']
|
79
|
+
|
80
|
+
== TODO
|
81
|
+
|
82
|
+
Удалять gritter_notice только после того как они закроются или их закроют
|
83
|
+
|
84
|
+
Контроллер gritter_notices с одной акцией delivered. Ставить ее запуск на onclose. Сделать настраиваемым текущее поведение:
|
85
|
+
|
86
|
+
1. notices помечаются доставленными когда показываются во view (контроллер не используется)
|
87
|
+
2. notices помечаются удаленными когда закрываются (сами или принудительно) onclose
|
88
|
+
3. обычные notices по методу 1, sticky notices по методу 2.
|
89
|
+
|
90
|
+
|
91
|
+
== Credits
|
92
|
+
* Robin Brouwer https://github.com/RobinBrouwer/gritter
|
93
|
+
* Jordan Boesch http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/
|
94
|
+
|
95
|
+
== Contributing to gritter_notices
|
96
|
+
|
97
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
98
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
99
|
+
* Fork the project
|
100
|
+
* Start a feature/bugfix branch
|
101
|
+
* Commit and push until you are happy with your contribution
|
102
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
103
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
104
|
+
|
105
|
+
== Copyright
|
106
|
+
|
107
|
+
Copyright (c) 2011 Danil Pismenny. See LICENSE.txt for
|
108
|
+
further details.
|
109
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "gritter_notices"
|
16
|
+
gem.homepage = "http://github.com/dapi/gritter_notices"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = "Show flashes and saved user's notices with Gritter (growl-like jQuery plugin)"
|
19
|
+
gem.description = %Q{Provide `notice` method to user model to save notices and to shows them later in views with Gritter (growl-like jQuery plugin). Fully support of Rails flash messages also. Helpful to send flash messages from background jobs.}
|
20
|
+
gem.email = "danil@orionet.ru"
|
21
|
+
gem.authors = ["Danil Pismenny"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "gritter_notices #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Сообщения от системы пользователю для отображения их через flash. Например:
|
4
|
+
#
|
5
|
+
# :import_contacts - импортированы контакты
|
6
|
+
# :import_events - импортированы мероприятия
|
7
|
+
#
|
8
|
+
# Сообщения посылаются так:
|
9
|
+
#
|
10
|
+
# user.notice :import_contacts, :provider=>:facebook
|
11
|
+
#
|
12
|
+
# Тексты сообщений описываются в локали
|
13
|
+
|
14
|
+
class GritterNotice < ActiveRecord::Base
|
15
|
+
belongs_to :owner, :polymorphic=>true
|
16
|
+
|
17
|
+
scope :delivered, where("delivered_at is not nul").order('delivered_at')
|
18
|
+
scope :fresh, where("delivered_at is null").order('created_at').limit(5)
|
19
|
+
|
20
|
+
serialize :options, Hash
|
21
|
+
|
22
|
+
validates_presence_of :owner, :message
|
23
|
+
|
24
|
+
def fresh?
|
25
|
+
delivered_at.blank?
|
26
|
+
end
|
27
|
+
|
28
|
+
def delivered?
|
29
|
+
not fresh?
|
30
|
+
end
|
31
|
+
|
32
|
+
def destroy_after_deliver?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def mark_as_delivered
|
37
|
+
if destroy_after_deliver?
|
38
|
+
destroy
|
39
|
+
else
|
40
|
+
update_attribute :delivered_at, Time.now
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class GritterNoticesGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.next_migration_number(dirname)
|
12
|
+
if ActiveRecord::Base.timestamped_migrations
|
13
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
|
+
else
|
15
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_migration_file
|
20
|
+
migration_template 'migration.rb', 'db/migrate/create_gritter_notices_table.rb'
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateGritterNoticesTable < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :gritter_notices, :force => true do |t|
|
4
|
+
t.integer :owner_id, :null => false
|
5
|
+
t.string :owner_type, :null => false
|
6
|
+
t.text :message, :null => false
|
7
|
+
# t.string :level, :default => "notice", :null => false
|
8
|
+
# t.string :title
|
9
|
+
# t.string :image
|
10
|
+
# t.boolean :sticky, :default=>false, :null=>false
|
11
|
+
t.text :options, :null=>false
|
12
|
+
t.datetime :delivered_at
|
13
|
+
t.datetime :created_at
|
14
|
+
t.datetime :updated_at
|
15
|
+
end
|
16
|
+
|
17
|
+
add_index :gritter_notices, [:owner_id, :delivered_at]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.down
|
21
|
+
drop_table :gritter_notices
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module GritterNotices::ActiveRecord
|
2
|
+
|
3
|
+
ValidMethods = Hash[*GritterNotices::KEYS.map { |key| ["notice_#{key}".to_sym, key] }.flatten]
|
4
|
+
|
5
|
+
# :level => [:success, :warning, :notice, :error, :progress]
|
6
|
+
def has_gritter_notices
|
7
|
+
has_many :gritter_notices, :as => :owner, :dependent => :delete_all
|
8
|
+
include InstanceMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
|
13
|
+
#
|
14
|
+
# Examples:
|
15
|
+
#
|
16
|
+
# notice :message=>'asdsad', :image=>:notice
|
17
|
+
# notice 'message', :level=>:success
|
18
|
+
#
|
19
|
+
|
20
|
+
def notice *args
|
21
|
+
options = args.extract_options!
|
22
|
+
message = args.first || options[:message]
|
23
|
+
options = {:scope=>:gritter_notices, :level=>:notice}.merge options
|
24
|
+
if message.is_a? Symbol
|
25
|
+
options[:gritter_message_key] = message
|
26
|
+
message = I18n::translate(message, options)
|
27
|
+
end
|
28
|
+
gritter_notices.create! :message=>message, :options=>options
|
29
|
+
end
|
30
|
+
|
31
|
+
# notice_success
|
32
|
+
# notice_error
|
33
|
+
# notice_warning
|
34
|
+
# notice_progress
|
35
|
+
# notice_notice - default. An alias for `notice`
|
36
|
+
|
37
|
+
def method_missing(method_name, *args, &block)
|
38
|
+
if level = ValidMethods[method_name]
|
39
|
+
options = args.extract_options!
|
40
|
+
options[:level] = level
|
41
|
+
args << options
|
42
|
+
notice *args
|
43
|
+
else
|
44
|
+
super(method_name, *args, &block)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module GritterNotices
|
2
|
+
module RSpecMatcher
|
3
|
+
def have_gritter_notice(message=nil)
|
4
|
+
HaveGritterNotice.new(message)
|
5
|
+
end
|
6
|
+
|
7
|
+
class HaveGritterNotice
|
8
|
+
def initialize(message)
|
9
|
+
@message = message
|
10
|
+
end
|
11
|
+
|
12
|
+
def description
|
13
|
+
"send gritter notice '#{@message}' to '#{@model}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def failure_message_for_should
|
17
|
+
"#{@model.class} should have gritter_notice with message '#{@message}'"
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message_for_should_not
|
21
|
+
"#{@model.class} should not have an gritter_notice with message '#{@message}'"
|
22
|
+
end
|
23
|
+
|
24
|
+
# def from(value)
|
25
|
+
# @from = value
|
26
|
+
# self
|
27
|
+
# end
|
28
|
+
|
29
|
+
# def to(value)
|
30
|
+
# @to = value
|
31
|
+
# self
|
32
|
+
# end
|
33
|
+
|
34
|
+
def matches?(model)
|
35
|
+
@model = model
|
36
|
+
not model.gritter_notices.select { |g| !@message or g.message == @message or g.options[:gritter_message_key] == @message }.empty?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
module GritterNotices::ViewHelpers
|
4
|
+
|
5
|
+
GRITTER_CONVERT_KEYS = { :info=>:notice, :alert=>:warning, :failure=>:error, :other=>:notice }.
|
6
|
+
merge Hash[*GritterNotices::KEYS.map {|k| [k,k]}.flatten]
|
7
|
+
|
8
|
+
|
9
|
+
#
|
10
|
+
# Ключи понимаемые гриттером:
|
11
|
+
# :success, :warning, :notice, :error, :progress
|
12
|
+
#
|
13
|
+
# Все возможные (системные):
|
14
|
+
# :success, :warning, :notice, :error, :alert, :info, :failure
|
15
|
+
|
16
|
+
def gritter_flash_messages *args
|
17
|
+
options = args.extract_options!
|
18
|
+
titles = gflash_titles(options)
|
19
|
+
flashes = []
|
20
|
+
|
21
|
+
# Собираем flash-сообщения
|
22
|
+
flash.each_pair do |key, message_array|
|
23
|
+
message_array = [message_array] unless message_array.is_a? Array
|
24
|
+
message_array.flatten.each { |message|
|
25
|
+
key = key.to_sym
|
26
|
+
# Превращаем системные флешки в гритеровские
|
27
|
+
gritter_key = GRITTER_CONVERT_KEYS[key] || GRITTER_CONVERT_KEYS[:other] || key
|
28
|
+
title = titles[gritter_key] || key.to_s
|
29
|
+
flashes << add_gritter(message, :image => gritter_key, :title => title)
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Собираем gritter_notices
|
34
|
+
current_user.gritter_notices.fresh.each do |notice|
|
35
|
+
options = notice.options
|
36
|
+
gritter_key = GRITTER_CONVERT_KEYS[options[:level]] || GRITTER_CONVERT_KEYS[:other] || options[:level]
|
37
|
+
options[:title] = titles[gritter_key] || options[:level].to_s unless options[:title]
|
38
|
+
options[:image] = gritter_key unless options[:image]
|
39
|
+
flashes << add_gritter(notice.message, options)
|
40
|
+
notice.mark_as_delivered
|
41
|
+
end if current_user and current_user.respond_to? :gritter_notices
|
42
|
+
|
43
|
+
js(flashes).html_safe
|
44
|
+
end
|
45
|
+
|
46
|
+
def move_gritter_notices_to_flashes
|
47
|
+
return unless current_user
|
48
|
+
current_user.gritter_notices.fresh.each do |notice|
|
49
|
+
append_flash_message notice.level, notice.message
|
50
|
+
notice.mark_as_delivered
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def append_flash_message(type, msg, now=false)
|
57
|
+
f = now ? flash.now : flash
|
58
|
+
f[type] ||= []
|
59
|
+
f[type] << msg
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module GritterNotices
|
3
|
+
# Keys supported by gritter
|
4
|
+
KEYS = [ :success, :warning, :notice, :error, :progress ]
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'gritter_notices/active_record'
|
8
|
+
ActiveRecord::Base.send( :extend, GritterNotices::ActiveRecord )
|
9
|
+
|
10
|
+
require 'gritter_notices/view_helpers'
|
11
|
+
ActionView::Base.send( :include, GritterNotices::ViewHelpers )
|
12
|
+
|
13
|
+
require 'gritter_notices/rspec_matcher'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe GritterNotice do
|
5
|
+
it { should belong_to(:user) }
|
6
|
+
it { should validate_presence_of(:user) }
|
7
|
+
it { should validate_presence_of(:message) }
|
8
|
+
context "помечается как доставленная" do
|
9
|
+
subject { Factory :notice }
|
10
|
+
it { should_not be_delivered }
|
11
|
+
end
|
12
|
+
end
|
data/spec/notice_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe GritterNotice do
|
5
|
+
it { should belong_to(:user) }
|
6
|
+
it { should validate_presence_of(:user) }
|
7
|
+
it { should validate_presence_of(:message) }
|
8
|
+
context "mark as delivered" do
|
9
|
+
subject { Factory :notice }
|
10
|
+
it { should_not be_delivered }
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'active_record'
|
5
|
+
require 'action_view'
|
6
|
+
# require 'nulldb_rspec'
|
7
|
+
# include NullDB::RSpec::NullifiedDatabase
|
8
|
+
|
9
|
+
|
10
|
+
require 'gritter_notices'
|
11
|
+
|
12
|
+
require 'app/models/gritter_notice'
|
13
|
+
|
14
|
+
require 'factory_girl'
|
15
|
+
|
16
|
+
|
17
|
+
# Factory.definition_file_paths = [
|
18
|
+
# File.join(Rails.root, 'spec', 'factories')
|
19
|
+
# ]
|
20
|
+
|
21
|
+
|
22
|
+
# Requires supporting files with custom matchers and macros, etc,
|
23
|
+
# in ./support/ and its subdirectories.
|
24
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
25
|
+
|
26
|
+
RSpec.configure do |config|
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gritter_notices
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Danil Pismenny
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-29 00:00:00 +04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: gritter
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
prerelease: false
|
33
|
+
type: :runtime
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: activerecord
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
prerelease: false
|
47
|
+
type: :runtime
|
48
|
+
requirement: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: actionpack
|
51
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
prerelease: false
|
61
|
+
type: :runtime
|
62
|
+
requirement: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: activerecord-nulldb-adapter
|
65
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
prerelease: false
|
75
|
+
type: :development
|
76
|
+
requirement: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: factory_girl
|
79
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
prerelease: false
|
89
|
+
type: :development
|
90
|
+
requirement: *id005
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: shoulda
|
93
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
version: "0"
|
102
|
+
prerelease: false
|
103
|
+
type: :development
|
104
|
+
requirement: *id006
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rspec
|
107
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
113
|
+
segments:
|
114
|
+
- 2
|
115
|
+
- 3
|
116
|
+
- 0
|
117
|
+
version: 2.3.0
|
118
|
+
prerelease: false
|
119
|
+
type: :development
|
120
|
+
requirement: *id007
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: bundler
|
123
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ~>
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 23
|
129
|
+
segments:
|
130
|
+
- 1
|
131
|
+
- 0
|
132
|
+
- 0
|
133
|
+
version: 1.0.0
|
134
|
+
prerelease: false
|
135
|
+
type: :development
|
136
|
+
requirement: *id008
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: jeweler
|
139
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ~>
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 7
|
145
|
+
segments:
|
146
|
+
- 1
|
147
|
+
- 5
|
148
|
+
- 2
|
149
|
+
version: 1.5.2
|
150
|
+
prerelease: false
|
151
|
+
type: :development
|
152
|
+
requirement: *id009
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rcov
|
155
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
hash: 3
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
version: "0"
|
164
|
+
prerelease: false
|
165
|
+
type: :development
|
166
|
+
requirement: *id010
|
167
|
+
description: Provide `notice` method to user model to save notices and to shows them later in views with Gritter (growl-like jQuery plugin). Fully support of Rails flash messages also. Helpful to send flash messages from background jobs.
|
168
|
+
email: danil@orionet.ru
|
169
|
+
executables: []
|
170
|
+
|
171
|
+
extensions: []
|
172
|
+
|
173
|
+
extra_rdoc_files:
|
174
|
+
- LICENSE.txt
|
175
|
+
- README.rdoc
|
176
|
+
files:
|
177
|
+
- Gemfile
|
178
|
+
- LICENSE.txt
|
179
|
+
- README.rdoc
|
180
|
+
- Rakefile
|
181
|
+
- VERSION
|
182
|
+
- app/models/gritter_notice.rb
|
183
|
+
- lib/generators/gritter_notices_generator.rb
|
184
|
+
- lib/generators/templates/migration.rb
|
185
|
+
- lib/gritter_notices.rb
|
186
|
+
- lib/gritter_notices/active_record.rb
|
187
|
+
- lib/gritter_notices/rspec_matcher.rb
|
188
|
+
- lib/gritter_notices/view_helpers.rb
|
189
|
+
- spec/gritter_notice_spec.rb
|
190
|
+
- spec/notice_spec.rb
|
191
|
+
- spec/spec_helper.rb
|
192
|
+
- spec/support/factories.rb
|
193
|
+
- spec/support/user.rb
|
194
|
+
has_rdoc: true
|
195
|
+
homepage: http://github.com/dapi/gritter_notices
|
196
|
+
licenses:
|
197
|
+
- MIT
|
198
|
+
post_install_message:
|
199
|
+
rdoc_options: []
|
200
|
+
|
201
|
+
require_paths:
|
202
|
+
- lib
|
203
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
204
|
+
none: false
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
hash: 3
|
209
|
+
segments:
|
210
|
+
- 0
|
211
|
+
version: "0"
|
212
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
|
+
none: false
|
214
|
+
requirements:
|
215
|
+
- - ">="
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
hash: 3
|
218
|
+
segments:
|
219
|
+
- 0
|
220
|
+
version: "0"
|
221
|
+
requirements: []
|
222
|
+
|
223
|
+
rubyforge_project:
|
224
|
+
rubygems_version: 1.5.0
|
225
|
+
signing_key:
|
226
|
+
specification_version: 3
|
227
|
+
summary: Show flashes and saved user's notices with Gritter (growl-like jQuery plugin)
|
228
|
+
test_files:
|
229
|
+
- spec/gritter_notice_spec.rb
|
230
|
+
- spec/notice_spec.rb
|
231
|
+
- spec/spec_helper.rb
|
232
|
+
- spec/support/factories.rb
|
233
|
+
- spec/support/user.rb
|