paul_revere 0.2.1 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.swp
2
+ .swo
3
+ *~
4
+ log/
5
+ pkg
6
+ rdoc
7
+ gemfiles/*.lock
8
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ gemfile:
6
+ - gemfiles/3.0.12.gemfile
7
+ - gemfiles/3.1.4.gemfile
8
+ - gemfiles/3.2.3.gemfile
data/Appraisals ADDED
@@ -0,0 +1,5 @@
1
+ ['3.2.3', '3.1.4', '3.0.12'].each do |rails_version|
2
+ appraise "rails-#{rails_version}" do
3
+ gem "rails", rails_version
4
+ end
5
+ end
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source "http://rubygems.org"
2
- gemspec
3
2
 
4
- gem "appraisal"
5
- gem "rspec-rails"
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,117 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ paul_revere (1.0)
5
+ rails (~> 3.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.1.0)
11
+ actionpack (= 3.1.0)
12
+ mail (~> 2.3.0)
13
+ actionpack (3.1.0)
14
+ activemodel (= 3.1.0)
15
+ activesupport (= 3.1.0)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ i18n (~> 0.6)
19
+ rack (~> 1.3.2)
20
+ rack-cache (~> 1.0.3)
21
+ rack-mount (~> 0.8.2)
22
+ rack-test (~> 0.6.1)
23
+ sprockets (~> 2.0.0)
24
+ activemodel (3.1.0)
25
+ activesupport (= 3.1.0)
26
+ bcrypt-ruby (~> 3.0.0)
27
+ builder (~> 3.0.0)
28
+ i18n (~> 0.6)
29
+ activerecord (3.1.0)
30
+ activemodel (= 3.1.0)
31
+ activesupport (= 3.1.0)
32
+ arel (~> 2.2.1)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.1.0)
35
+ activemodel (= 3.1.0)
36
+ activesupport (= 3.1.0)
37
+ activesupport (3.1.0)
38
+ multi_json (~> 1.0)
39
+ appraisal (0.3.8)
40
+ bundler
41
+ rake
42
+ arel (2.2.3)
43
+ bcrypt-ruby (3.0.0)
44
+ builder (3.0.0)
45
+ diff-lcs (1.1.3)
46
+ erubis (2.7.0)
47
+ hike (1.2.1)
48
+ i18n (0.6.0)
49
+ mail (2.3.3)
50
+ i18n (>= 0.4.0)
51
+ mime-types (~> 1.16)
52
+ treetop (~> 1.4.8)
53
+ mime-types (1.18)
54
+ mocha (0.9.12)
55
+ multi_json (1.0.3)
56
+ polyglot (0.3.3)
57
+ rack (1.3.2)
58
+ rack-cache (1.0.3)
59
+ rack (>= 0.4)
60
+ rack-mount (0.8.3)
61
+ rack (>= 1.0.0)
62
+ rack-ssl (1.3.2)
63
+ rack
64
+ rack-test (0.6.1)
65
+ rack (>= 1.0)
66
+ rails (3.1.0)
67
+ actionmailer (= 3.1.0)
68
+ actionpack (= 3.1.0)
69
+ activerecord (= 3.1.0)
70
+ activeresource (= 3.1.0)
71
+ activesupport (= 3.1.0)
72
+ bundler (~> 1.0)
73
+ railties (= 3.1.0)
74
+ railties (3.1.0)
75
+ actionpack (= 3.1.0)
76
+ activesupport (= 3.1.0)
77
+ rack-ssl (~> 1.3.2)
78
+ rake (>= 0.8.7)
79
+ rdoc (~> 3.4)
80
+ thor (~> 0.14.6)
81
+ rake (0.9.2)
82
+ rdoc (3.9.4)
83
+ rspec (2.6.0)
84
+ rspec-core (~> 2.6.0)
85
+ rspec-expectations (~> 2.6.0)
86
+ rspec-mocks (~> 2.6.0)
87
+ rspec-core (2.6.4)
88
+ rspec-expectations (2.6.0)
89
+ diff-lcs (~> 1.1.2)
90
+ rspec-mocks (2.6.0)
91
+ rspec-rails (2.6.1)
92
+ actionpack (~> 3.0)
93
+ activesupport (~> 3.0)
94
+ railties (~> 3.0)
95
+ rspec (~> 2.6.0)
96
+ sprockets (2.0.0)
97
+ hike (~> 1.2)
98
+ rack (~> 1.0)
99
+ tilt (~> 1.1, != 1.3.0)
100
+ sqlite3 (1.3.4)
101
+ thor (0.14.6)
102
+ tilt (1.3.3)
103
+ treetop (1.4.10)
104
+ polyglot
105
+ polyglot (>= 0.3.1)
106
+ tzinfo (0.3.33)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ appraisal
113
+ mocha
114
+ paul_revere!
115
+ rspec
116
+ rspec-rails
117
+ sqlite3
data/NEWS.md ADDED
@@ -0,0 +1,5 @@
1
+ New in 1.0:
2
+
3
+ * Support for Rails 3.2.3, 3.1.4, and 3.0.12.
4
+ * Fix the JavaScript that hides the announcements to work out of the box.
5
+ * The announcement hiding cookie expires after a year.
data/README.md CHANGED
@@ -31,6 +31,7 @@ Paul Revere provides...
31
31
  So the flow would be...
32
32
 
33
33
  * Install the gem
34
+ * Add `helper :announcements` either to application_controller.rb or to the specific controllers where you want to make the announcement helpers available
34
35
  * Use those partials in the correct places in your view code and mailer view code where you want announcements to show up
35
36
  * When you want to make an announcement, use the rails console to create a new Announcement record
36
37
 
data/Rakefile CHANGED
@@ -1,31 +1,18 @@
1
- # encoding: UTF-8
2
- require 'rubygems'
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- end
8
-
9
- require 'rake'
10
- require 'rdoc/task'
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
11
3
  require 'appraisal'
12
4
 
13
- require 'rspec/core'
14
5
  require 'rspec/core/rake_task'
15
6
  RSpec::Core::RakeTask.new(:spec)
16
7
 
17
- desc "Default: run the unit tests."
18
- task :default => [:all]
19
-
20
- desc 'Test the plugin under all supported Rails versions.'
21
- task :all => ["appraisal:install"] do |t|
22
- exec('rake appraisal spec')
8
+ task :default do |t|
9
+ if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
10
+ exec 'rake spec'
11
+ else
12
+ Rake::Task['appraise'].execute
13
+ end
23
14
  end
24
15
 
25
- desc 'Generate documentation for the paul revere plugin.'
26
- RDoc::Task.new(:rdoc) do |rdoc|
27
- rdoc.rdoc_dir = 'rdoc'
28
- rdoc.title = 'PaulRevere'
29
- rdoc.options << '--line-numbers' << '--inline-source'
30
- rdoc.rdoc_files.include('lib/**/*.rb')
16
+ task :appraise => ['appraisal:install'] do |t|
17
+ exec 'rake appraisal'
31
18
  end
@@ -1,9 +1 @@
1
- <% if current_user and current_announcement.exists? and not announcement_hidden?(current_announcement) %>
2
- <div id="flash-border" class="announcement">
3
- <span><%= current_announcement.body.html_safe %></span>
4
- <span class="hide">
5
- <%= link_to_function "hide", "hideAnnouncement('announcement_#{current_announcement.created_at}');" %>
6
- </span>
7
- </div>
8
- <% end %>
9
-
1
+ <%= render 'announcements/announcement_for_all' if current_user %>
@@ -1,11 +1,8 @@
1
- <% if current_announcement.exists? and not announcement_hidden?(current_announcement) %>
2
- <div id="flash-border">
3
- <div id="announcement">
4
- <span><%= current_announcement.body.html_safe %></span>
5
- <span class="hide">
6
- <%= link_to_function "hide", "hideAnnouncement('announcement_#{current_announcement.created_at}');" %>
7
- </span>
8
- </div>
1
+ <% if current_announcement.exists? && !announcement_hidden?(current_announcement) %>
2
+ <div id="announcement">
3
+ <span><%= current_announcement.body.html_safe %></span>
4
+ <span class="hide">
5
+ <%= link_to_function "hide", "hideAnnouncement('announcement_#{current_announcement.created_at}')" %>
6
+ </span>
9
7
  </div>
10
8
  <% end %>
11
-
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.0.12"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.1.4"
6
+ gem "sass-rails"
7
+ gem "coffee-script"
8
+ gem "uglifier"
9
+ gem "jquery-rails"
10
+
11
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.2.3"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.0.12"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.1.4"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.2.3"
6
+
7
+ gemspec :path=>"../"
@@ -1,6 +1,6 @@
1
1
  function hideAnnouncement(announcement_created_at) {
2
- createCookie(announcement_created_at, 'hidden', 1);
3
- $("#announcement").parent().slideUp();
2
+ createCookie(announcement_created_at, 'hidden', 365);
3
+ $("#announcement").slideUp();
4
4
  }
5
5
 
6
6
  // http://www.quirksmode.org/js/cookies.html
@@ -0,0 +1,3 @@
1
+ module PaulRevere
2
+ VERSION = '1.0'.freeze
3
+ end
data/lib/paul_revere.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'paul_revere/version'
2
+
1
3
  module PaulRevere
2
4
  class Engine < Rails::Engine
3
5
  end
@@ -0,0 +1,26 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "paul_revere/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "paul_revere"
6
+ s.version = PaulRevere::VERSION.dup
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ['Nick Quaranto', 'Matt Jankowski', 'Joe Ferris', 'Christopher Meiklejohn', 'Tammer Saleh', 'Jason Morrison', 'Gabe Berke-Williams']
9
+ s.email = "support@thoughtbot.com"
10
+ s.homepage = "https://github.com/thoughtbot/paul_revere"
11
+ s.summary = "Simple announcement plugin to include 'one off' style announcements in Rails web apps."
12
+ s.description = "Paul Revere provides a model and helper methods to do one-off style announcements."
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency("rails", "~> 3.0")
20
+
21
+ s.add_development_dependency("rspec")
22
+ s.add_development_dependency("rspec-rails")
23
+ s.add_development_dependency("sqlite3")
24
+ s.add_development_dependency("mocha")
25
+ s.add_development_dependency("appraisal")
26
+ end
@@ -0,0 +1,18 @@
1
+ class ActiveSupport::TestCase
2
+
3
+ def self.with_current_announcement(&blk)
4
+ context "When there is a current announcement" do
5
+ setup do
6
+ Annoucement.create!(:body => 'therefore,')
7
+ end
8
+ merge_block(&blk)
9
+ end
10
+ end
11
+
12
+ def self.should_display_current_announcement
13
+ should "have the current announcement in it" do
14
+ assert_match Announcement.current.body, @email.body
15
+ end
16
+ end
17
+
18
+ end
data/spec/fake_app.rb ADDED
@@ -0,0 +1,16 @@
1
+ # Create a rails app
2
+ module PaulRevere
3
+ class Application < Rails::Application
4
+ end
5
+ end
6
+
7
+ # Run migrations
8
+ project_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
9
+ require File.join project_root, 'lib', 'generators', 'paul_revere', 'templates', 'migration'
10
+
11
+ ActiveRecord::Base.establish_connection(
12
+ :adapter => "sqlite3",
13
+ :database => ":memory:"
14
+ )
15
+
16
+ CreateAnnouncements.suppress_messages { CreateAnnouncements.up }
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ require File.join(File.dirname(__FILE__), '..', '..', 'app', 'helpers', 'announcements_helper')
4
+ require File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'announcement')
5
+
6
+ describe AnnouncementsHelper do
7
+
8
+ it "should return the current announcement when sent current_announcement and cache doesn't exist" do
9
+ assign :current_announcement, nil
10
+ Announcement.stubs(:current).returns(:foo)
11
+ helper.current_announcement.should == :foo
12
+ end
13
+
14
+ it "should return a cached announcement when sent current_announcement and cache exists" do
15
+ assign :current_announcement, :foo
16
+ Announcement.expects(:current).never
17
+ helper.current_announcement.should == :foo
18
+ end
19
+
20
+ describe "when there is an announcement" do
21
+ before do
22
+ @announcement = Announcement.create!(:body => 'a body')
23
+ assign :announcement, @announcement
24
+ end
25
+
26
+ describe "and the user has hidden an announcement" do
27
+ before { helper.stubs(:cookies).returns("announcement_#{@announcement.created_at}" => "hidden") }
28
+
29
+ it "should return true when sent announcement_hidden? with announcement" do
30
+ helper.announcement_hidden?(@announcement).should be_true
31
+ end
32
+ end
33
+
34
+ describe "and the user has not hidden an announcement" do
35
+ before { helper.stubs(:cookies).returns("announcement_#{@announcement.created_at}" => "not hidden") }
36
+
37
+ it "should return false when sent announcement_hidden? with announcement" do
38
+ helper.announcement_hidden?(@announcement).should be_false
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ require File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'announcement')
4
+
5
+ describe Announcement do
6
+ it "should return the latest announcement when there are several" do
7
+ old = Announcement.create!(:body => 'no fun', :created_at => 2.days.ago)
8
+ latest = Announcement.create!(:body => 'fun', :created_at => 1.day.ago)
9
+ older = Announcement.create!(:body => 'less fun', :created_at => 3.days.ago)
10
+
11
+ Announcement.current.should == latest
12
+ end
13
+
14
+ it "should return an existent announcement where there is no announcement" do
15
+ Announcement.create!(:body => 'body')
16
+ Announcement.current.exists?.should == true
17
+ end
18
+
19
+ it "should return a non-existent announcement where there is no announcement" do
20
+ Announcement.current.exists?.should be_false
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe PaulRevere do
4
+ it "should be valid" do
5
+ PaulRevere.should be_a(Module)
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ # Configure Rails Envinronment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require "rails/all"
5
+ require "rspec/rails"
6
+
7
+ # Pull in the fake rails app
8
+ require 'fake_app'
9
+
10
+ # Load support files
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
+
13
+ RSpec.configure do |config|
14
+ # Remove this line if you don't want RSpec's should and should_not
15
+ # methods or matchers
16
+ require 'rspec/expectations'
17
+ config.include RSpec::Matchers
18
+
19
+ # == Mock Framework
20
+ config.mock_with :mocha
21
+
22
+ # Remove announcements before each example
23
+ config.before(:each) do
24
+ Announcement.delete_all
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paul_revere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: '1.0'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,11 +15,11 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2011-09-18 00:00:00.000000000 Z
18
+ date: 2012-05-11 00:00:00.000000000Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
22
- requirement: &2152105720 !ruby/object:Gem::Requirement
22
+ requirement: &22372400 !ruby/object:Gem::Requirement
23
23
  none: false
24
24
  requirements:
25
25
  - - ~>
@@ -27,10 +27,10 @@ dependencies:
27
27
  version: '3.0'
28
28
  type: :runtime
29
29
  prerelease: false
30
- version_requirements: *2152105720
30
+ version_requirements: *22372400
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rspec
33
- requirement: &2152105180 !ruby/object:Gem::Requirement
33
+ requirement: &22371980 !ruby/object:Gem::Requirement
34
34
  none: false
35
35
  requirements:
36
36
  - - ! '>='
@@ -38,10 +38,21 @@ dependencies:
38
38
  version: '0'
39
39
  type: :development
40
40
  prerelease: false
41
- version_requirements: *2152105180
41
+ version_requirements: *22371980
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec-rails
44
+ requirement: &22371520 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: *22371520
42
53
  - !ruby/object:Gem::Dependency
43
54
  name: sqlite3
44
- requirement: &2152104700 !ruby/object:Gem::Requirement
55
+ requirement: &22371100 !ruby/object:Gem::Requirement
45
56
  none: false
46
57
  requirements:
47
58
  - - ! '>='
@@ -49,10 +60,21 @@ dependencies:
49
60
  version: '0'
50
61
  type: :development
51
62
  prerelease: false
52
- version_requirements: *2152104700
63
+ version_requirements: *22371100
53
64
  - !ruby/object:Gem::Dependency
54
65
  name: mocha
55
- requirement: &2152104240 !ruby/object:Gem::Requirement
66
+ requirement: &22370680 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ type: :development
73
+ prerelease: false
74
+ version_requirements: *22370680
75
+ - !ruby/object:Gem::Dependency
76
+ name: appraisal
77
+ requirement: &22370260 !ruby/object:Gem::Requirement
56
78
  none: false
57
79
  requirements:
58
80
  - - ! '>='
@@ -60,28 +82,47 @@ dependencies:
60
82
  version: '0'
61
83
  type: :development
62
84
  prerelease: false
63
- version_requirements: *2152104240
85
+ version_requirements: *22370260
64
86
  description: Paul Revere provides a model and helper methods to do one-off style announcements.
65
87
  email: support@thoughtbot.com
66
88
  executables: []
67
89
  extensions: []
68
90
  extra_rdoc_files: []
69
91
  files:
92
+ - .gitignore
93
+ - .travis.yml
94
+ - Appraisals
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - MIT-LICENSE
98
+ - NEWS.md
99
+ - README.md
100
+ - Rakefile
70
101
  - app/helpers/announcements_helper.rb
71
102
  - app/models/announcement.rb
72
103
  - app/views/announcements/_announcement.html.erb
73
104
  - app/views/announcements/_announcement_for_all.html.erb
74
105
  - app/views/announcements/_email_announcement.erb
106
+ - gemfiles/3.0.12.gemfile
107
+ - gemfiles/3.1.4.gemfile
108
+ - gemfiles/3.2.3.gemfile
109
+ - gemfiles/rails-3.0.12.gemfile
110
+ - gemfiles/rails-3.1.4.gemfile
111
+ - gemfiles/rails-3.2.3.gemfile
112
+ - init.rb
113
+ - lib/generators/paul_revere/USAGE
75
114
  - lib/generators/paul_revere/paul_revere_generator.rb
76
115
  - lib/generators/paul_revere/templates/announcements.js
77
116
  - lib/generators/paul_revere/templates/migration.rb
78
- - lib/generators/paul_revere/USAGE
79
117
  - lib/paul_revere.rb
80
- - MIT-LICENSE
81
- - Rakefile
82
- - Gemfile
83
- - README.md
84
- - init.rb
118
+ - lib/paul_revere/version.rb
119
+ - paul_revere.gemspec
120
+ - shoulda_macros/announcement.rb
121
+ - spec/fake_app.rb
122
+ - spec/helpers/announcements_helper_spec.rb
123
+ - spec/models/announcement_spec.rb
124
+ - spec/paul_revere_spec.rb
125
+ - spec/spec_helper.rb
85
126
  homepage: https://github.com/thoughtbot/paul_revere
86
127
  licenses: []
87
128
  post_install_message:
@@ -94,15 +135,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
135
  - - ! '>='
95
136
  - !ruby/object:Gem::Version
96
137
  version: '0'
138
+ segments:
139
+ - 0
140
+ hash: -3043656868834385100
97
141
  required_rubygems_version: !ruby/object:Gem::Requirement
98
142
  none: false
99
143
  requirements:
100
144
  - - ! '>='
101
145
  - !ruby/object:Gem::Version
102
146
  version: '0'
147
+ segments:
148
+ - 0
149
+ hash: -3043656868834385100
103
150
  requirements: []
104
151
  rubyforge_project:
105
- rubygems_version: 1.8.10
152
+ rubygems_version: 1.8.11
106
153
  signing_key:
107
154
  specification_version: 3
108
155
  summary: Simple announcement plugin to include 'one off' style announcements in Rails