release_notes 0.2.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20abfeb2d8d618567392ea7156dfa4e016c20e74
4
- data.tar.gz: 2b2c81dff9b96eb2514d8aaa5108ca659861e691
3
+ metadata.gz: b87726f5ce617cdc8a5c2d09c794065c8c2c1a45
4
+ data.tar.gz: b0bb70f0a18b2b054a0850e2a27215a9f64d81d8
5
5
  SHA512:
6
- metadata.gz: 671c1ec3281ac5efc43f3774331c894e6b77977231e9a36eb65ed62002fbda49c74409b0033a5c6c45191cd49d623654e00bb8a0c710f27ee8f36a46e9d69ebf
7
- data.tar.gz: c07497b81b5e373f5bfc17480eb2de0522bb082edd4c9dd652b503ee1b26bdfcbca7c8ffc9c62907ea0fdafe7999565adea5b47a6d0938638b27810619daa9de
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
- After installing ReleaseNotes you need to run the install generator:
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 an initializer containing ReleaseNotes various configuration options. When you are done, you are ready to add a ReleaseNote model to using the following generator:
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 `config/initializers/release_notes.rb` file with the name of the model you generated.
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. As mentioned before, you can choose to use a different model name, but remember to edit the `config/initializers/release_notes.rb` file with the name.
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
- Add the following to your layout/application.html.erb file
49
+ Then add one of the following render tags to whichever view you'd like to display the broadcast message in.
50
50
 
51
- <%= stylesheet_link_tag "release_notes/application", media: "all" %>
51
+ <%= render 'release_notes/broadcasts/link_back' %>
52
52
 
53
- Then add the following render to wherever you'd like to display the broadcast message.
53
+ OR...
54
54
 
55
- <%= render 'release_notes/broadcasts/shared' %>
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 in the `release_notes` folder. Open the file in your favorite editor and fill out the relevant sections to your heart's content.
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 reset your model - maybe you've gone back and edited a previous release note - you can rebuild the ReleaseNote model by running `release_notes update -r` appending the `-r` option.
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 reset your model - maybe you've gone back and edited a previous release note - you can rebuild the Broadcast model by running `release_notes broadcast update -r` appending the `-r` option.
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
 
@@ -15,7 +15,7 @@ module ReleaseNotes
15
15
  :quote => true,
16
16
  :footnotes => true]
17
17
 
18
- render_options = [:filter_html => true,
18
+ render_options = [:filter_html => false,
19
19
  :hard_wrap => true,
20
20
  :prettify => true]
21
21
 
@@ -2,9 +2,4 @@
2
2
  <div>
3
3
  <%= markup(ReleaseNotes.broadcast_model.constantize.last.markdown).html_safe %>
4
4
  </div>
5
- <div>
6
- <a href="/<%= ReleaseNotes.mount_at %>">
7
- View all release notes
8
- </a>
9
- </div>
10
5
  <% end %>
@@ -0,0 +1,6 @@
1
+ <%= render 'release_notes/broadcasts/bare' %>
2
+ <div>
3
+ <a href="/<%= ReleaseNotes.mount_at %>">
4
+ View all release notes
5
+ </a>
6
+ </div>
@@ -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 %><% if !@release_note_version.nil? %>/<%= @release_note_version %><% end %>)
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
 
@@ -0,0 +1,3 @@
1
+ ReleaseNotes::ReleaseNotesController.class_eval do
2
+ layout 'release_notes/application'
3
+ end
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'
@@ -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 => '-V', :desc => 'use the given version number'
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 => '-V', :desc => 'update only the given version number'
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
- options[:release_note_version]])
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
- # Gets last broadcast version from db
30
- last_broadcast = ReleaseNotes.broadcast_model.constantize.last
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
- if last_broadcast.nil?
33
- last_version = 0
34
- else
35
- last_version = last_broadcast.version.to_i
36
- end
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
- end
68
+ else
69
+ # Gets last broadcast version from db
70
+ last_broadcast = ReleaseNotes.broadcast_model.constantize.last
50
71
 
51
- say "#{ReleaseNotes.broadcast_model} model successfully updated.", :green
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}/*_[0-9]*.md")
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
@@ -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
- @release_note_version = release_note_version.gsub('.', '_')
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
@@ -1,3 +1,3 @@
1
1
  module ReleaseNotes
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -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", "~> 4.0.0"
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.2.1
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-02-10 00:00:00.000000000 Z
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: 4.0.0
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: 4.0.0
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/_shared.html.erb
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: