paul_revere 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Appraisals +1 -1
- data/Gemfile.lock +2 -2
- data/NEWS.md +6 -0
- data/README.md +37 -7
- data/{lib/generators/paul_revere/templates → app/assets/javascripts}/announcements.js +0 -0
- data/app/models/announcement.rb +2 -0
- data/gemfiles/{3.0.12.gemfile → rails-3.0.15.gemfile} +1 -1
- data/gemfiles/{rails-3.2.3.gemfile → rails-3.1.6.gemfile} +1 -1
- data/gemfiles/{rails-3.1.4.gemfile → rails-3.2.6.gemfile} +1 -1
- data/lib/generators/paul_revere/paul_revere_generator.rb +20 -2
- data/lib/paul_revere/version.rb +1 -1
- data/spec/fake_app.rb +4 -0
- data/spec/models/announcement_spec.rb +17 -4
- metadata +51 -24
- data/gemfiles/3.1.4.gemfile +0 -11
- data/gemfiles/3.2.3.gemfile +0 -7
- data/gemfiles/rails-3.0.12.gemfile +0 -7
data/Appraisals
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paul_revere (1.
|
4
|
+
paul_revere (1.1)
|
5
5
|
rails (~> 3.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
i18n (>= 0.4.0)
|
51
51
|
mime-types (~> 1.16)
|
52
52
|
treetop (~> 1.4.8)
|
53
|
-
mime-types (1.
|
53
|
+
mime-types (1.19)
|
54
54
|
mocha (0.9.12)
|
55
55
|
multi_json (1.0.3)
|
56
56
|
polyglot (0.3.3)
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -6,17 +6,44 @@ Paul Revere
|
|
6
6
|
|
7
7
|
Simple announcement plugin to include "one off" style announcements in Rails web apps.
|
8
8
|
|
9
|
-
Install
|
10
|
-
|
9
|
+
Install with the asset pipeline (Rails 3.1+, asset pipeline enabled)
|
10
|
+
--------------------------------------------------------------------
|
11
11
|
|
12
12
|
Install as normal in your Gemfile:
|
13
13
|
|
14
14
|
gem 'paul_revere'
|
15
15
|
|
16
|
-
Run the generator to create the migration
|
16
|
+
Run the generator to create the migration:
|
17
17
|
|
18
18
|
rails generate paul_revere
|
19
19
|
|
20
|
+
Add the announcement JS to `app/assets/javascripts/application.js`:
|
21
|
+
|
22
|
+
//= require announcements
|
23
|
+
|
24
|
+
Run the migration:
|
25
|
+
|
26
|
+
rake db:migrate && rake db:migrate:redo
|
27
|
+
|
28
|
+
Install without the asset pipeline (Rails 3.0 or asset pipeline disabled)
|
29
|
+
---------------------------------------------------------------------------
|
30
|
+
|
31
|
+
Install as normal in your Gemfile:
|
32
|
+
|
33
|
+
gem 'paul_revere'
|
34
|
+
|
35
|
+
Run the generator to create the migration and copy the JavaScript file into public:
|
36
|
+
|
37
|
+
rails generate paul_revere
|
38
|
+
|
39
|
+
Add the announcement JS to your layout, such as `app/views/layouts/application.html.erb`:
|
40
|
+
|
41
|
+
<%= javascript_include_tag 'announcements' %>
|
42
|
+
|
43
|
+
Run the migration:
|
44
|
+
|
45
|
+
rake db:migrate && rake db:migrate:redo
|
46
|
+
|
20
47
|
Usage
|
21
48
|
-----
|
22
49
|
|
@@ -31,9 +58,13 @@ Paul Revere provides...
|
|
31
58
|
So the flow would be...
|
32
59
|
|
33
60
|
* Install the gem
|
34
|
-
*
|
35
|
-
|
36
|
-
|
61
|
+
* Use those partials in the correct places in your view code and mailer view code where you want announcements to show up:
|
62
|
+
|
63
|
+
<%= render 'announcements/announcement_for_all' %>
|
64
|
+
|
65
|
+
* When you want to make an announcement, use the Rails console to create a new `Announcement` record:
|
66
|
+
|
67
|
+
Announcement.create!(body: 'This Web site is shutting down because you refuse to pay')
|
37
68
|
|
38
69
|
Beastie Boys Lyrics
|
39
70
|
-------------------
|
@@ -104,7 +135,6 @@ His boy had beef and he got dropped
|
|
104
135
|
Mike D. grabbed the money M.C.A. snatched the gold
|
105
136
|
I grabbed two girlies and a beer that's cold.
|
106
137
|
|
107
|
-
|
108
138
|
Credits
|
109
139
|
-------
|
110
140
|
|
File without changes
|
data/app/models/announcement.rb
CHANGED
@@ -4,11 +4,29 @@ class PaulRevereGenerator < Rails::Generators::Base
|
|
4
4
|
include Rails::Generators::Migration
|
5
5
|
extend ActiveRecord::Generators::Migration
|
6
6
|
|
7
|
-
desc "Put the
|
7
|
+
desc "Put the JavaScript and migration in place"
|
8
8
|
source_root File.join(File.dirname(__FILE__), "templates")
|
9
9
|
|
10
10
|
def install
|
11
|
-
|
11
|
+
copy_javascript if needs_js_copied?
|
12
12
|
migration_template "migration.rb", "db/migrate/create_announcements.rb"
|
13
13
|
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def copy_javascript
|
18
|
+
copy_file File.join(javascript_path, 'announcements.js'), js_destination
|
19
|
+
end
|
20
|
+
|
21
|
+
def javascript_path
|
22
|
+
File.join(%w(.. .. .. .. app assets javascripts))
|
23
|
+
end
|
24
|
+
|
25
|
+
def needs_js_copied?
|
26
|
+
::Rails.version < '3.1' || !::Rails.application.config.assets.enabled
|
27
|
+
end
|
28
|
+
|
29
|
+
def js_destination
|
30
|
+
'public/javascripts/announcements.js'
|
31
|
+
end
|
14
32
|
end
|
data/lib/paul_revere/version.rb
CHANGED
data/spec/fake_app.rb
CHANGED
@@ -4,19 +4,32 @@ require File.join(File.dirname(__FILE__), '..', '..', 'app', 'models', 'announce
|
|
4
4
|
|
5
5
|
describe Announcement do
|
6
6
|
it "should return the latest announcement when there are several" do
|
7
|
-
old =
|
8
|
-
latest =
|
9
|
-
older =
|
7
|
+
old = create_announcement(:body => 'no fun', :created_at => 2.days.ago)
|
8
|
+
latest = create_announcement(:body => 'fun', :created_at => 1.day.ago)
|
9
|
+
older = create_announcement(:body => 'less fun', :created_at => 3.days.ago)
|
10
10
|
|
11
11
|
Announcement.current.should == latest
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should return an existent announcement where there is no announcement" do
|
15
|
-
|
15
|
+
create_announcement(:body => 'body')
|
16
16
|
Announcement.current.exists?.should == true
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should return a non-existent announcement where there is no announcement" do
|
20
20
|
Announcement.current.exists?.should be_false
|
21
21
|
end
|
22
|
+
|
23
|
+
it 'can always assign straight to the body' do
|
24
|
+
Announcement.create!(:body => 'hello').body.should == 'hello'
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_announcement(attributes)
|
28
|
+
announcement = Announcement.new
|
29
|
+
attributes.each do |key, value|
|
30
|
+
announcement.send("#{key}=", value)
|
31
|
+
end
|
32
|
+
announcement.save!
|
33
|
+
announcement
|
34
|
+
end
|
22
35
|
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: '1.
|
4
|
+
version: '1.1'
|
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: 2012-
|
18
|
+
date: 2012-09-13 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|
22
|
-
requirement:
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
25
25
|
- - ~>
|
@@ -27,10 +27,15 @@ dependencies:
|
|
27
27
|
version: '3.0'
|
28
28
|
type: :runtime
|
29
29
|
prerelease: false
|
30
|
-
version_requirements:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '3.0'
|
31
36
|
- !ruby/object:Gem::Dependency
|
32
37
|
name: rspec
|
33
|
-
requirement:
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
34
39
|
none: false
|
35
40
|
requirements:
|
36
41
|
- - ! '>='
|
@@ -38,10 +43,15 @@ dependencies:
|
|
38
43
|
version: '0'
|
39
44
|
type: :development
|
40
45
|
prerelease: false
|
41
|
-
version_requirements:
|
46
|
+
version_requirements: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
42
52
|
- !ruby/object:Gem::Dependency
|
43
53
|
name: rspec-rails
|
44
|
-
requirement:
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
45
55
|
none: false
|
46
56
|
requirements:
|
47
57
|
- - ! '>='
|
@@ -49,10 +59,15 @@ dependencies:
|
|
49
59
|
version: '0'
|
50
60
|
type: :development
|
51
61
|
prerelease: false
|
52
|
-
version_requirements:
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
53
68
|
- !ruby/object:Gem::Dependency
|
54
69
|
name: sqlite3
|
55
|
-
requirement:
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
56
71
|
none: false
|
57
72
|
requirements:
|
58
73
|
- - ! '>='
|
@@ -60,10 +75,15 @@ dependencies:
|
|
60
75
|
version: '0'
|
61
76
|
type: :development
|
62
77
|
prerelease: false
|
63
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
64
84
|
- !ruby/object:Gem::Dependency
|
65
85
|
name: mocha
|
66
|
-
requirement:
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
67
87
|
none: false
|
68
88
|
requirements:
|
69
89
|
- - ! '>='
|
@@ -71,10 +91,15 @@ dependencies:
|
|
71
91
|
version: '0'
|
72
92
|
type: :development
|
73
93
|
prerelease: false
|
74
|
-
version_requirements:
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
75
100
|
- !ruby/object:Gem::Dependency
|
76
101
|
name: appraisal
|
77
|
-
requirement:
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
78
103
|
none: false
|
79
104
|
requirements:
|
80
105
|
- - ! '>='
|
@@ -82,7 +107,12 @@ dependencies:
|
|
82
107
|
version: '0'
|
83
108
|
type: :development
|
84
109
|
prerelease: false
|
85
|
-
version_requirements:
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
86
116
|
description: Paul Revere provides a model and helper methods to do one-off style announcements.
|
87
117
|
email: support@thoughtbot.com
|
88
118
|
executables: []
|
@@ -98,21 +128,18 @@ files:
|
|
98
128
|
- NEWS.md
|
99
129
|
- README.md
|
100
130
|
- Rakefile
|
131
|
+
- app/assets/javascripts/announcements.js
|
101
132
|
- app/helpers/announcements_helper.rb
|
102
133
|
- app/models/announcement.rb
|
103
134
|
- app/views/announcements/_announcement.html.erb
|
104
135
|
- app/views/announcements/_announcement_for_all.html.erb
|
105
136
|
- app/views/announcements/_email_announcement.erb
|
106
|
-
- gemfiles/3.0.
|
107
|
-
- gemfiles/3.1.
|
108
|
-
- gemfiles/3.2.
|
109
|
-
- gemfiles/rails-3.0.12.gemfile
|
110
|
-
- gemfiles/rails-3.1.4.gemfile
|
111
|
-
- gemfiles/rails-3.2.3.gemfile
|
137
|
+
- gemfiles/rails-3.0.15.gemfile
|
138
|
+
- gemfiles/rails-3.1.6.gemfile
|
139
|
+
- gemfiles/rails-3.2.6.gemfile
|
112
140
|
- init.rb
|
113
141
|
- lib/generators/paul_revere/USAGE
|
114
142
|
- lib/generators/paul_revere/paul_revere_generator.rb
|
115
|
-
- lib/generators/paul_revere/templates/announcements.js
|
116
143
|
- lib/generators/paul_revere/templates/migration.rb
|
117
144
|
- lib/paul_revere.rb
|
118
145
|
- lib/paul_revere/version.rb
|
@@ -137,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
164
|
version: '0'
|
138
165
|
segments:
|
139
166
|
- 0
|
140
|
-
hash: -
|
167
|
+
hash: -1368084792273439523
|
141
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
169
|
none: false
|
143
170
|
requirements:
|
@@ -146,10 +173,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
173
|
version: '0'
|
147
174
|
segments:
|
148
175
|
- 0
|
149
|
-
hash: -
|
176
|
+
hash: -1368084792273439523
|
150
177
|
requirements: []
|
151
178
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.8.
|
179
|
+
rubygems_version: 1.8.24
|
153
180
|
signing_key:
|
154
181
|
specification_version: 3
|
155
182
|
summary: Simple announcement plugin to include 'one off' style announcements in Rails
|
data/gemfiles/3.1.4.gemfile
DELETED
data/gemfiles/3.2.3.gemfile
DELETED