release_notes 0.2.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -11
- data/app/helpers/release_notes/application_helper.rb +1 -1
- data/app/views/release_notes/broadcasts/{_shared.html.erb → _bare.html.erb} +0 -5
- data/app/views/release_notes/broadcasts/_link_back.html.erb +6 -0
- data/lib/generators/active_record/broadcasts_generator.rb +1 -1
- data/lib/generators/active_record/release_notes_generator.rb +1 -1
- data/lib/generators/release_notes/install_generator.rb +4 -0
- data/lib/generators/templates/broadcast_blank.md +1 -1
- data/lib/generators/templates/release_notes.rb +6 -0
- data/lib/generators/templates/release_notes_controller_decorator.rb +3 -0
- data/lib/release_notes.rb +8 -0
- data/lib/release_notes/cli.rb +2 -2
- data/lib/release_notes/cli/broadcast.rb +68 -23
- data/lib/release_notes/engine.rb +6 -0
- data/lib/release_notes/generators/broadcast.rb +7 -1
- data/lib/release_notes/version.rb +1 -1
- data/release_notes.gemspec +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b87726f5ce617cdc8a5c2d09c794065c8c2c1a45
|
4
|
+
data.tar.gz: b0bb70f0a18b2b054a0850e2a27215a9f64d81d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4e23f0fd107133ddd37aad19a4e10d906092ffe289a5f3074c9e2e6e0f9ac2acbc7b7f71bae4a9d7e71f3dbe836d42c23e57151ea444f371600590172836ec0
|
7
|
+
data.tar.gz: 1fd93580d20818e7bee849a10b5fe1bed9e7f3db09966e219d4330f1eebe1b435459395593df14875e25f7889e672a14c616e47cab98cc28516a36ec845e4c2e
|
data/README.md
CHANGED
@@ -18,15 +18,15 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Getting Started
|
20
20
|
|
21
|
-
|
21
|
+
If you're looking to use ReleaseNotes with Rails you will need to run the install generator:
|
22
22
|
|
23
23
|
$ rails generate release_notes:install
|
24
24
|
|
25
|
-
The generator will install
|
25
|
+
The generator will install a ReleaseNotes initializer containing various configuration options and a ReleaseNotes controller decorator. When you are done, you are ready to add a ReleaseNote model to using the following generator:
|
26
26
|
|
27
27
|
$ rails generate release_notes ReleaseNote
|
28
28
|
|
29
|
-
This will generate a model named `ReleaseNote` in your Rails project. You can choose to use a different model name, but after doing so you must update `config.release_note_model` in the
|
29
|
+
This will generate a model named `ReleaseNote` in your Rails project and will add a route in your `config/routes.rb` file at `/release_notes`. You can choose to use a different model name, but after doing so you must update `config.release_note_model` in the release_notes initializer with the name of the model you generated.
|
30
30
|
|
31
31
|
Be sure to migrate your database.
|
32
32
|
|
@@ -40,19 +40,19 @@ To add the ability to display broadcasts of new releases (or any other messages)
|
|
40
40
|
|
41
41
|
$ rails generate release_notes:broadcasts Broadcast
|
42
42
|
|
43
|
-
This will generate a model named `Broadcast` in your Rails project.
|
43
|
+
This will generate a model named `Broadcast` in your Rails project. You can choose to use a different model name, but you must edit the release_notes initializer file with the updated Broadcast name.
|
44
44
|
|
45
45
|
Migrate your database.
|
46
46
|
|
47
47
|
$ rake db:migrate
|
48
48
|
|
49
|
-
|
49
|
+
Then add one of the following render tags to whichever view you'd like to display the broadcast message in.
|
50
50
|
|
51
|
-
<%=
|
51
|
+
<%= render 'release_notes/broadcasts/link_back' %>
|
52
52
|
|
53
|
-
|
53
|
+
OR...
|
54
54
|
|
55
|
-
<%= render 'release_notes/broadcasts/
|
55
|
+
<%= render 'release_notes/broadcasts/bare' %>
|
56
56
|
|
57
57
|
#### Views
|
58
58
|
|
@@ -60,6 +60,17 @@ While not necessary, you may want to copy over the ReleaseNotes views to your ap
|
|
60
60
|
|
61
61
|
$ rails generate release_notes:views
|
62
62
|
|
63
|
+
If you do decide to customize the ReleaseNotes views and want to use your own layout you should probably **(1)** edit the layout declaration in `app/decorators/controllers/release_notes/release_notes_controller_decorator.rb` and **(2)** add one of the following stylesheet_link_tag snippets to your view:
|
64
|
+
|
65
|
+
<%= stylesheet_link_tag "release_notes/application", media: "all" %>
|
66
|
+
|
67
|
+
Will load Bootstrap 3 and a [Github Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) style.
|
68
|
+
|
69
|
+
<%= stylesheet_link_tag "release_notes/github", media: "all" %>
|
70
|
+
|
71
|
+
Will load just the [Github Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) style.
|
72
|
+
|
73
|
+
|
63
74
|
## Usage
|
64
75
|
|
65
76
|
### Generate a new release note template
|
@@ -68,7 +79,7 @@ To create a new release note run the following:
|
|
68
79
|
|
69
80
|
$ release_notes new
|
70
81
|
|
71
|
-
A new release note markdown file will be generated
|
82
|
+
A new release note markdown file will be generated and saved to the `release_notes` folder. Open the file in your favorite editor and fill out the relevant sections to your heart's content.
|
72
83
|
|
73
84
|
### Generate a new release note from the console
|
74
85
|
|
@@ -84,7 +95,11 @@ After finalizing your release note markdown file be sure to update your ReleaseN
|
|
84
95
|
|
85
96
|
$ release_notes update
|
86
97
|
|
87
|
-
If you ever want to
|
98
|
+
If you ever want to update a particular release note you can run the following, where `VERSION` is the specific release note version that you want to update.
|
99
|
+
|
100
|
+
$ release_notes update -v=VERSION
|
101
|
+
|
102
|
+
This will only update the release note matching the version number specified.
|
88
103
|
|
89
104
|
### View release notes in your application
|
90
105
|
|
@@ -97,6 +112,7 @@ To create a new Broadcast run:
|
|
97
112
|
$ release_notes broadcast new
|
98
113
|
|
99
114
|
This will generate a broadcast markdown file which you can edit.
|
115
|
+
**Note:** You *can* use HTML within the markdown file.
|
100
116
|
|
101
117
|
### Update Broadcast
|
102
118
|
|
@@ -104,7 +120,17 @@ After finalizing your broadcast markdown file be sure to update your Broadcast m
|
|
104
120
|
|
105
121
|
$ release_notes broadcast update
|
106
122
|
|
107
|
-
If you ever want to
|
123
|
+
If you ever want to update a particular broadcast you can run the following:
|
124
|
+
|
125
|
+
$ release_notes broadcast update -v=VERSION
|
126
|
+
|
127
|
+
### Set a Broadcast
|
128
|
+
|
129
|
+
You can set a specific broadcast to set as the "latest" broadcast (the default shown by using the broadcast partials) by running the following:
|
130
|
+
|
131
|
+
$ release_notes broadcast set_version VERSION
|
132
|
+
|
133
|
+
The "latest" version will be set to the `VERSION` specified.
|
108
134
|
|
109
135
|
## Contributing
|
110
136
|
|
@@ -13,7 +13,7 @@ module ActiveRecord
|
|
13
13
|
if (behavior == :invoke && model_exists?)
|
14
14
|
raise "#{table_name} already exists..."
|
15
15
|
else
|
16
|
-
migration_template "broadcasts_migration.rb", "db/migrate/release_notes_create_#{table_name}"
|
16
|
+
migration_template "broadcasts_migration.rb", "db/migrate/release_notes_create_#{table_name}.rb"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -13,7 +13,7 @@ module ActiveRecord
|
|
13
13
|
if (behavior == :invoke && model_exists?)
|
14
14
|
raise "#{table_name} already exists..."
|
15
15
|
else
|
16
|
-
migration_template "release_notes_migration.rb", "db/migrate/release_notes_create_#{table_name}"
|
16
|
+
migration_template "release_notes_migration.rb", "db/migrate/release_notes_create_#{table_name}.rb"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -13,6 +13,10 @@ module ReleaseNotes
|
|
13
13
|
template "release_notes.rb", "config/initializers/release_notes.rb"
|
14
14
|
end
|
15
15
|
|
16
|
+
def copy_controller_decorator
|
17
|
+
template "release_notes_controller_decorator.rb", "app/decorators/controllers/release_notes/release_notes_controller_decorator.rb"
|
18
|
+
end
|
19
|
+
|
16
20
|
def show_readme
|
17
21
|
readme "README" if behavior == :invoke
|
18
22
|
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
### [<%= @subject -%>](/<%= ReleaseNotes.mount_at
|
1
|
+
### <% if @release_note_version.nil? -%><%= @subject -%><% else -%>[<%= @subject -%>](/<%= ReleaseNotes.mount_at -%>/<%= @release_note_version -%>)<% end -%>
|
2
2
|
|
3
3
|
<%= @body -%>
|
@@ -9,6 +9,12 @@ ReleaseNotes.setup do |config|
|
|
9
9
|
# Name of the model you're using to store broadcasts.
|
10
10
|
config.broadcast_model = 'Broadcast'
|
11
11
|
|
12
|
+
# Name of the model you're using to store users.
|
13
|
+
config.user_model = 'User'
|
14
|
+
|
15
|
+
# Name of the model you're using to store broadcasts for users.
|
16
|
+
config.user_broadcast_model = 'UserBroadcast'
|
17
|
+
|
12
18
|
# Name of the folder you're using to store the release note and broadcast markdown files.
|
13
19
|
config.release_note_folder = 'release_notes'
|
14
20
|
|
data/lib/release_notes.rb
CHANGED
@@ -17,6 +17,14 @@ module ReleaseNotes
|
|
17
17
|
mattr_accessor :broadcast_model
|
18
18
|
@@broadcast_model = 'Broadcast'
|
19
19
|
|
20
|
+
# Model name of the model created to store users.
|
21
|
+
mattr_accessor :user_model
|
22
|
+
@@user_model = 'User'
|
23
|
+
|
24
|
+
# Model name of the model created to store broadcasts for users.
|
25
|
+
mattr_accessor :user_broadcast_model
|
26
|
+
@@user_broadcast_model = 'UserBroadcast'
|
27
|
+
|
20
28
|
# Name of the folder where release notes are stored.
|
21
29
|
mattr_accessor :release_note_folder
|
22
30
|
@@release_note_folder = 'release_notes'
|
data/lib/release_notes/cli.rb
CHANGED
@@ -20,7 +20,7 @@ module ReleaseNotes
|
|
20
20
|
method_option :force, :aliases => '-f', :type => :boolean, :desc => 'overwrite files that already exist'
|
21
21
|
method_option :increment, :aliases => '-i', :default => 'patch', :banner => 'MODE', :desc => 'increment version by mode - "major", "minor", "patch"'
|
22
22
|
method_option :message, :aliases => '-m', :desc => 'interactive release note bullet input'
|
23
|
-
method_option :version, :aliases => '-
|
23
|
+
method_option :version, :aliases => '-v', :desc => 'use the given version number'
|
24
24
|
|
25
25
|
def new
|
26
26
|
if options[:version].nil?
|
@@ -47,7 +47,7 @@ module ReleaseNotes
|
|
47
47
|
method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
|
48
48
|
method_option :no_log, :aliases => '-n', :type => :boolean, :default => false, :desc => 'disable README.md log of release notes'
|
49
49
|
method_option :reset, :aliases => '-r', :type => :boolean, :default => false, :desc => 'delete all model entries and rebuilds them'
|
50
|
-
# method_option :version, :aliases => '-
|
50
|
+
# method_option :version, :aliases => '-v', :desc => 'update only the given version number'
|
51
51
|
|
52
52
|
def update
|
53
53
|
# If reset option is passed delete all release notes in model
|
@@ -1,22 +1,43 @@
|
|
1
1
|
module ReleaseNotes
|
2
2
|
class Broadcast < Thor
|
3
|
-
desc 'new', 'Create a new broadcast'
|
3
|
+
desc 'broadcast new', 'Create a new broadcast'
|
4
4
|
method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
|
5
|
-
method_option :body, :aliases => '-b', :default => "We've made some new changes - check 'em out!", :desc => 'body of broadcast'
|
6
|
-
method_option :subject, :aliases => '-s', :default => "New Update", :desc => 'subject of broadcast'
|
7
5
|
method_option :release_note_version, :aliases => '-r', :desc => 'corresponding release note version'
|
6
|
+
method_option :subject, :aliases => '-s', :default => "New Update", :desc => 'subject of broadcast'
|
7
|
+
method_option :body, :aliases => '-b', :default => "We've made some new changes - check 'em out!", :desc => 'body of broadcast'
|
8
8
|
|
9
9
|
def new
|
10
|
+
release_note_version = options[:release_note_version] || ""
|
11
|
+
|
10
12
|
ReleaseNotes::Generators::Broadcast.start([options[:destination],
|
11
13
|
options[:subject],
|
12
14
|
options[:body],
|
13
|
-
|
15
|
+
release_note_version])
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
desc 'broadcast set_version [VERSION]', 'Sets the latest broadcast to the given version'
|
20
|
+
|
21
|
+
def set_version(version)
|
22
|
+
rn = ReleaseNotes.broadcast_model.constantize.find_by(version: version)
|
23
|
+
|
24
|
+
new_rn = ReleaseNotes.broadcast_model.constantize.new
|
25
|
+
new_rn.version = rn.version
|
26
|
+
new_rn.markdown = rn.markdown
|
27
|
+
|
28
|
+
rn.destroy
|
29
|
+
new_rn.save
|
30
|
+
|
31
|
+
say "Latest broadcast is now set to version #{version}.", :green
|
32
|
+
rescue NoMethodError
|
33
|
+
say "Broadcast version #{version} was not found in the db.", :red
|
14
34
|
end
|
15
35
|
|
16
36
|
|
17
|
-
desc 'update', "Update #{ReleaseNotes.broadcast_model} models"
|
37
|
+
desc 'broadcast update', "Update #{ReleaseNotes.broadcast_model} models"
|
18
38
|
method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
|
19
39
|
method_option :reset, :aliases => '-r', :type => :boolean, :default => false, :desc => 'delete all model entries and rebuilds them'
|
40
|
+
method_option :version, :aliases => '-v', :desc => 'specific broadcast version to save/update'
|
20
41
|
|
21
42
|
def update
|
22
43
|
# If reset option is passed delete all broadcasts in model
|
@@ -26,29 +47,49 @@ module ReleaseNotes
|
|
26
47
|
end
|
27
48
|
end
|
28
49
|
|
29
|
-
|
30
|
-
|
50
|
+
if options[:version]
|
51
|
+
version = options[:version]
|
52
|
+
broadcast_file = single_broadcast_lookup_at(options[:destination], version)
|
53
|
+
markdown = File.read("#{options[:destination]}/#{broadcast_file}")
|
31
54
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# Collects relevant files and saves version and content to db
|
39
|
-
broadcast_files = collect_broadcast_files(options[:destination])
|
40
|
-
broadcast_files.each do |file|
|
41
|
-
version = file.split('_').last.to_i
|
42
|
-
|
43
|
-
if version > last_version
|
44
|
-
markdown = File.read("#{options[:destination]}/#{file}")
|
55
|
+
# If version is set check to see if its already in db or create new one
|
56
|
+
if ReleaseNotes.broadcast_model.constantize.find_by(version: version)
|
57
|
+
ReleaseNotes.broadcast_model.constantize
|
58
|
+
.find_by(version: version)
|
59
|
+
.update_attributes(markdown: markdown)
|
45
60
|
|
61
|
+
say "#{ReleaseNotes.broadcast_model} model successfully updated.", :green
|
62
|
+
else
|
46
63
|
ReleaseNotes.broadcast_model.constantize.create(version: version,
|
47
64
|
markdown: markdown)
|
65
|
+
|
66
|
+
say "#{ReleaseNotes.broadcast_model} model successfully saved.", :green
|
48
67
|
end
|
49
|
-
|
68
|
+
else
|
69
|
+
# Gets last broadcast version from db
|
70
|
+
last_broadcast = ReleaseNotes.broadcast_model.constantize.last
|
50
71
|
|
51
|
-
|
72
|
+
if last_broadcast.nil?
|
73
|
+
last_version = 0
|
74
|
+
else
|
75
|
+
last_version = last_broadcast.version.to_i
|
76
|
+
end
|
77
|
+
|
78
|
+
# Collects relevant files and saves version and content to db
|
79
|
+
broadcast_files = collect_broadcast_files(options[:destination])
|
80
|
+
broadcast_files.each do |file|
|
81
|
+
version = file.split('_').last.to_i
|
82
|
+
|
83
|
+
if version > last_version
|
84
|
+
markdown = File.read("#{options[:destination]}/#{file}")
|
85
|
+
|
86
|
+
ReleaseNotes.broadcast_model.constantize.create(version: version,
|
87
|
+
markdown: markdown)
|
88
|
+
|
89
|
+
say "#{ReleaseNotes.broadcast_model} version #{version} successfully saved.", :green
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
52
93
|
end
|
53
94
|
|
54
95
|
protected
|
@@ -65,7 +106,11 @@ module ReleaseNotes
|
|
65
106
|
end
|
66
107
|
|
67
108
|
def broadcast_lookup_at(dirname)
|
68
|
-
Dir.glob("#{dirname}
|
109
|
+
Dir.glob("#{dirname}/broadcast_[0-9]*.md")
|
110
|
+
end
|
111
|
+
|
112
|
+
def single_broadcast_lookup_at(dirname, version)
|
113
|
+
File.basename(Dir.glob("#{dirname}/broadcast_#{version}*.md")[0])
|
69
114
|
end
|
70
115
|
end
|
71
116
|
end
|
data/lib/release_notes/engine.rb
CHANGED
@@ -2,6 +2,12 @@ module ReleaseNotes
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace ReleaseNotes
|
4
4
|
|
5
|
+
config.to_prepare do
|
6
|
+
Dir.glob(Rails.root + "app/decorators/**/release_notes/*_decorator*.rb").each do |c|
|
7
|
+
require_dependency(c)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
initializer 'release_notes.action_controller' do |app|
|
6
12
|
ActiveSupport.on_load :action_controller do
|
7
13
|
helper ReleaseNotes::ApplicationHelper
|
@@ -15,7 +15,13 @@ module ReleaseNotes
|
|
15
15
|
def set_local_assigns
|
16
16
|
@subject = subject
|
17
17
|
@body = body
|
18
|
-
|
18
|
+
|
19
|
+
if release_note_version != ""
|
20
|
+
@release_note_version = release_note_version.gsub('.', '_')
|
21
|
+
else
|
22
|
+
@release_note_version = nil
|
23
|
+
end
|
24
|
+
|
19
25
|
@broadcast_template = 'broadcast_blank.md'
|
20
26
|
@destination = File.expand_path(destination)
|
21
27
|
end
|
data/release_notes.gemspec
CHANGED
@@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "aruba", "~> 0.5.4"
|
27
27
|
|
28
28
|
spec.add_dependency "thor", "~> 0.18.1"
|
29
|
-
spec.add_dependency "rails", "
|
29
|
+
spec.add_dependency "rails", "> 3.0.0"
|
30
30
|
spec.add_dependency "redcarpet", "~> 3.0.0"
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: release_notes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Robins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rails
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>'
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.0.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '>'
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 3.0.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: redcarpet
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +145,8 @@ files:
|
|
145
145
|
- app/controllers/release_notes/release_notes_controller.rb
|
146
146
|
- app/helpers/release_notes/application_helper.rb
|
147
147
|
- app/views/layouts/release_notes/application.html.erb
|
148
|
-
- app/views/release_notes/broadcasts/
|
148
|
+
- app/views/release_notes/broadcasts/_bare.html.erb
|
149
|
+
- app/views/release_notes/broadcasts/_link_back.html.erb
|
149
150
|
- app/views/release_notes/release_notes/_shared.html.erb
|
150
151
|
- app/views/release_notes/release_notes/index.html.erb
|
151
152
|
- app/views/release_notes/release_notes/show.html.erb
|
@@ -164,6 +165,7 @@ files:
|
|
164
165
|
- lib/generators/templates/README
|
165
166
|
- lib/generators/templates/broadcast_blank.md
|
166
167
|
- lib/generators/templates/release_notes.rb
|
168
|
+
- lib/generators/templates/release_notes_controller_decorator.rb
|
167
169
|
- lib/generators/templates/update.md
|
168
170
|
- lib/generators/templates/update_blank.md
|
169
171
|
- lib/release_notes.rb
|
@@ -205,3 +207,4 @@ summary: An easy way to incorporate and manage release notes.
|
|
205
207
|
test_files:
|
206
208
|
- features/support/setup.rb
|
207
209
|
- spec/spec_helper.rb
|
210
|
+
has_rdoc:
|