release_notes 0.1.3 → 0.2.0

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: 693a9c73e2241120056f4676c9da2944dcb0e2ce
4
- data.tar.gz: 9cd136e107570674a7eb1272bc54d879b13afadc
3
+ metadata.gz: 944aabbdcfbe98177f96767bacfb25ac122628fa
4
+ data.tar.gz: 6b6eb9634870439af6a73a2c1192af44a3025e62
5
5
  SHA512:
6
- metadata.gz: c37e57a7948fab39d3886add8a6f8c542d915e71b4a7bdf7d3cef58f5afb4e53875daf80f35db7aa93a5cd032c7eb622cc0c6c11b59eb0baa4c2575490ad74f4
7
- data.tar.gz: 5a9da389aeb6b4615df33c2928c723a1bf4b1b47200ac0025b9f935dc74eb07850138528fae4c48f5629f69e29a2ec2ee65be5c9dae0f34bfd01d584c5f6fe14
6
+ metadata.gz: d98b8739536d1be288b3a69cb8225872064ae22d2cc7107f961271b807c58caa5f4324995a5fb7c2747bdb1353a4711f7a800268bd8b28e818b4f44d94b27a00
7
+ data.tar.gz: dbb63344fd67d55c0b0953c6e78406b6173de94f69ef6eb5fe1b6b54e9e5b5b1a96774f0b7b9c1c4170dfc73c461a046b8ec740640b99c7889a9260c134978c0
data/README.md CHANGED
@@ -32,7 +32,31 @@ Be sure to migrate your database.
32
32
 
33
33
  $ rake db:migrate
34
34
 
35
- *Optional:* While not necessary, you may want to copy over the ReleaseNotes views to your app to customize:
35
+ ### Optional
36
+
37
+ #### Broadcasts
38
+
39
+ To add the ability to display broadcasts of new releases (or any other messages) run the following:
40
+
41
+ $ rails generate release_notes:broadcasts Broadcast
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.
44
+
45
+ Migrate your database.
46
+
47
+ $ rake db:migrate
48
+
49
+ Add the following to your layout/application.html.erb file
50
+
51
+ <%= stylesheet_link_tag "release_notes/application", media: "all" %>
52
+
53
+ Then add the following render to wherever you'd like to display the broadcast message.
54
+
55
+ <%= render 'release_notes/broadcasts/shared' %>
56
+
57
+ #### Views
58
+
59
+ While not necessary, you may want to copy over the ReleaseNotes views to your app to customize:
36
60
 
37
61
  $ rails generate release_notes:views
38
62
 
@@ -66,6 +90,22 @@ If you ever want to reset your model - maybe you've gone back and edited a previ
66
90
 
67
91
  To view all of your release notes just visit `http://yourapp/release_notes` (or whatever route is mounted in your `routes.rb` file) in your application. To view a specific version just visit `http://yourapp/release_notes/:version` where `:version` is the release notes version that you are looking to view using underscores instead of periods (i.e. `0_1_0`).
68
92
 
93
+ ### Create a new Broadcast
94
+
95
+ To create a new Broadcast run:
96
+
97
+ $ release_notes broadcast new
98
+
99
+ This will generate a broadcast markdown file which you can edit.
100
+
101
+ ### Update Broadcast
102
+
103
+ After finalizing your broadcast markdown file be sure to update your Broadcast model by running:
104
+
105
+ $ release_notes broadcast update
106
+
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.
108
+
69
109
  ## Contributing
70
110
 
71
111
  1. Fork it ( http://github.com/eanlain/release_notes/fork )
@@ -12,6 +12,18 @@
12
12
  *= require_directory .
13
13
  */
14
14
 
15
+ html,
16
+ body {
17
+ height: 100%;
18
+ }
19
+
20
+ #wrap {
21
+ min-height: 100%;
22
+ height: auto;
23
+ margin: 0 auto -60px;
24
+ padding: 0 0 60px;
25
+ }
26
+
15
27
  body {
16
28
  padding-top: 20px;
17
29
  padding-bottom: 20px;
@@ -35,6 +47,7 @@ body {
35
47
  }
36
48
 
37
49
  .footer {
50
+ height: 60px;
38
51
  padding-top: 19px;
39
52
  color: #777;
40
53
  border-top: 1px solid #e5e5e5;
@@ -56,6 +69,7 @@ body {
56
69
 
57
70
  .note {
58
71
  margin: 40px 0;
72
+ border-radius: 10px;
59
73
  }
60
74
 
61
75
  .note p + h4 {
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  .release {
4
2
  background: #EEE;
5
3
  border-radius: 3px;
@@ -0,0 +1,10 @@
1
+ <% if ReleaseNotes.broadcast_model.constantize.last %>
2
+ <div>
3
+ <%= markup(ReleaseNotes.broadcast_model.constantize.last.markdown).html_safe %>
4
+ </div>
5
+ <div>
6
+ <a href="/<%= ReleaseNotes.mount_at %>">
7
+ View all release notes
8
+ </a>
9
+ </div>
10
+ <% end %>
data/bin/release_notes CHANGED
@@ -4,7 +4,7 @@ begin
4
4
  require File.expand_path('config/environment.rb')
5
5
  require File.expand_path('config/initializers/release_notes.rb')
6
6
  rescue LoadError
7
- puts "Not in Rails root, or just can't find it... that's cool though - using default settings instead."
7
+ puts "Can't find config/initializers/release_notes.rb... that's cool though - using default settings instead."
8
8
  end
9
9
 
10
10
  require 'release_notes/cli'
@@ -0,0 +1,47 @@
1
+ require 'rails/generators/active_record'
2
+ require 'generators/release_notes/orm_helpers'
3
+
4
+ module ActiveRecord
5
+ module Generators
6
+ class BroadcastsGenerator < ActiveRecord::Generators::Base
7
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
8
+
9
+ include ReleaseNotes::Generators::OrmHelpers
10
+ source_root File.expand_path("../templates", __FILE__)
11
+
12
+ def copy_broadcasts_migration
13
+ if (behavior == :invoke && model_exists?)
14
+ raise "#{table_name} already exists..."
15
+ else
16
+ migration_template "broadcasts_migration.rb", "db/migrate/release_notes_create_#{table_name}"
17
+ end
18
+ end
19
+
20
+ def generate_module
21
+ invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke
22
+ end
23
+
24
+ def inject_broadcasts_content
25
+ content = broadcasts_model_contents
26
+
27
+ class_path = if namespaced?
28
+ class_name.to_s.split("::")
29
+ else
30
+ [class_name]
31
+ end
32
+
33
+ indent_depth = class_path.size - 1
34
+ content = content.split("\n").map { |line| " " * indent_depth + line }.join("\n") << "\n"
35
+
36
+ inject_into_class(model_path, class_path.last, content) if model_exists?
37
+ end
38
+
39
+ def migration_data
40
+ <<RUBY
41
+ t.text :markdown, :null => false
42
+ t.string :version, :null => false
43
+ RUBY
44
+ end
45
+ end
46
+ end
47
+ end
@@ -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 "migration.rb", "db/migrate/release_notes_create_#{table_name}"
16
+ migration_template "release_notes_migration.rb", "db/migrate/release_notes_create_#{table_name}"
17
17
  end
18
18
  end
19
19
 
@@ -22,7 +22,7 @@ module ActiveRecord
22
22
  end
23
23
 
24
24
  def inject_release_notes_content
25
- content = model_contents
25
+ content = release_notes_model_contents
26
26
 
27
27
  class_path = if namespaced?
28
28
  class_name.to_s.split("::")
@@ -0,0 +1,13 @@
1
+ class ReleaseNotesCreate<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def change
3
+ create_table(:<%= table_name %>) do |t|
4
+ <%= migration_data -%>
5
+
6
+ <% attributes.each do |attribute| -%>
7
+ t.<%= attribute.type %> :<%= attribute.name %>
8
+ <% end -%>
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ require 'rails/generators/named_base'
2
+
3
+ module ReleaseNotes
4
+ module Generators
5
+ class BroadcastsGenerator < Rails::Generators::NamedBase
6
+ include Rails::Generators::ResourceHelpers
7
+
8
+ namespace "release_notes:broadcasts"
9
+ source_root File.expand_path("../templates", __FILE__)
10
+
11
+ desc "Generates a Broadcast model with the given NAME (if one does not exist)."
12
+
13
+ hook_for :orm
14
+ end
15
+ end
16
+ end
@@ -1,10 +1,17 @@
1
1
  module ReleaseNotes
2
2
  module Generators
3
3
  module OrmHelpers
4
- def model_contents
4
+ def release_notes_model_contents
5
5
  buffer = <<-CONTENT
6
- validates :version, presence: true,
7
- uniqueness: true
6
+ validates :version, presence: true, uniqueness: true
7
+ CONTENT
8
+ buffer
9
+ end
10
+
11
+ def broadcasts_model_contents
12
+ buffer = <<-CONTENT
13
+ validates :markdown, presence: true
14
+ validates :version, presence: true, uniqueness: true
8
15
  CONTENT
9
16
  buffer
10
17
  end
@@ -8,15 +8,15 @@ module ReleaseNotes
8
8
  namespace "release_notes"
9
9
  source_root File.expand_path("../templates", __FILE__)
10
10
 
11
- desc "Generates a model with the given NAME (if one does not exist) with " <<
12
- "release_notes configuration plus a migration file and release_notes routes."
11
+ desc "Generates a ReleaseNote model with the given NAME (if one does not exist) with " <<
12
+ "release_notes configuration plus release_notes routes."
13
13
 
14
14
  hook_for :orm
15
15
 
16
16
  class_option :routes, :desc => "Generate routes", :type => :boolean, :default => true
17
17
 
18
18
  def add_release_notes_routes
19
- release_notes_routes = "mount ReleaseNotes::Engine, at: '/#{plural_name}'"
19
+ release_notes_routes = "mount ReleaseNotes::Engine, at: '/#{plural_name}', :as => '#{ReleaseNotes.mount_at}'"
20
20
 
21
21
  route release_notes_routes
22
22
  end
@@ -0,0 +1,3 @@
1
+ ### [<%= @subject -%>](/<%= ReleaseNotes.mount_at %><% if !@release_note_version.nil? %>/<%= @release_note_version %><% end %>)
2
+
3
+ <%= @body -%>
@@ -1,14 +1,20 @@
1
1
  # Use this hook to configure ReleaseNotes.
2
2
  ReleaseNotes.setup do |config|
3
- # The name of your application.
3
+ # Name of your application.
4
4
  config.app_name = 'Application Name Goes Here'
5
5
 
6
- # The name of the model you're using to store the various release notes.
6
+ # Name of the model you're using to store the various release notes.
7
7
  config.release_note_model = 'ReleaseNote'
8
8
 
9
- # The name of the folder you're using to store the release note markdown files.
9
+ # Name of the model you're using to store broadcasts.
10
+ config.broadcast_model = 'Broadcast'
11
+
12
+ # Name of the folder you're using to store the release note and broadcast markdown files.
10
13
  config.release_note_folder = 'release_notes'
11
14
 
12
- # The version number that the first ReleaseNote should start at.
15
+ # Path that ReleaseNotes::Engine is mounted at in the config/routes.rb file.
16
+ config.mount_at = 'release_notes'
17
+
18
+ # Version number that the first ReleaseNote should start at.
13
19
  config.starting_version = '0.1.0'
14
20
  end
@@ -0,0 +1,71 @@
1
+ module ReleaseNotes
2
+ class Broadcast < Thor
3
+ desc 'new', 'Create a new broadcast'
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
+ method_option :release_note_version, :aliases => '-r', :desc => 'corresponding release note version'
8
+
9
+ def new
10
+ ReleaseNotes::Generators::Broadcast.start([options[:destination],
11
+ options[:subject],
12
+ options[:body],
13
+ options[:release_note_version]])
14
+ end
15
+
16
+
17
+ desc 'update', "Update #{ReleaseNotes.broadcast_model} models"
18
+ method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
19
+ method_option :reset, :aliases => '-r', :type => :boolean, :default => false, :desc => 'delete all model entries and rebuilds them'
20
+
21
+ def update
22
+ # If reset option is passed delete all broadcasts in model
23
+ if options[:reset]
24
+ ReleaseNotes.broadcast_model.constantize.all.each do |b|
25
+ b.destroy
26
+ end
27
+ end
28
+
29
+ # Gets last broadcast version from db
30
+ last_broadcast = ReleaseNotes.broadcast_model.constantize.last
31
+
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}")
45
+
46
+ ReleaseNotes.broadcast_model.constantize.create(version: version,
47
+ markdown: markdown)
48
+ end
49
+ end
50
+
51
+ say "#{ReleaseNotes.broadcast_model} model successfully updated.", :green
52
+ end
53
+
54
+ protected
55
+ def collect_broadcast_files(dirname)
56
+ broadcast_lookup_at(dirname).collect do |file|
57
+ File.basename(file)
58
+ end
59
+ end
60
+
61
+ def current_broadcast_number(dirname)
62
+ broadcast_lookup_at(dirname).collect do |file|
63
+ File.basename(file).split('_').last.to_i
64
+ end.max.to_i
65
+ end
66
+
67
+ def broadcast_lookup_at(dirname)
68
+ Dir.glob("#{dirname}/*_[0-9]*.md")
69
+ end
70
+ end
71
+ end
@@ -2,20 +2,23 @@ require 'thor'
2
2
  require 'release_notes'
3
3
  require 'release_notes/version'
4
4
  require 'release_notes/versioning'
5
+ require 'release_notes/cli/broadcast'
5
6
  require 'release_notes/cli/helpers'
6
7
  require 'release_notes/generators/release_note'
8
+ require 'release_notes/generators/broadcast'
7
9
 
8
10
  module ReleaseNotes
9
11
  class CLI < Thor
10
-
12
+ register(Broadcast, 'broadcast', 'broadcast [COMMAND]', 'Create a new broadcast or update Broadcast models')
13
+
11
14
  package_name 'ReleaseNotes'
12
15
  map '-v' => :version
13
16
 
14
17
 
15
- desc 'new', 'create a new release note'
18
+ desc 'new', 'Create a new release note'
16
19
  method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
17
20
  method_option :force, :aliases => '-f', :type => :boolean, :desc => 'overwrite files that already exist'
18
- method_option :increment, :aliases => '-i', :default => 'patch', :banner => 'MODE', :desc => 'increment version by mode'
21
+ method_option :increment, :aliases => '-i', :default => 'patch', :banner => 'MODE', :desc => 'increment version by mode - "major", "minor", "patch"'
19
22
  method_option :message, :aliases => '-m', :desc => 'interactive release note bullet input'
20
23
  method_option :version, :aliases => '-V', :desc => 'use the given version number'
21
24
 
@@ -34,13 +37,13 @@ module ReleaseNotes
34
37
  end
35
38
 
36
39
  ReleaseNotes::Generators::ReleaseNote.start([options[:destination],
37
- message,
38
- update_version,
39
- "--force=#{options[:force] || false}"])
40
+ message,
41
+ update_version,
42
+ "--force=#{options[:force] || false}"])
40
43
  end
41
44
 
42
45
 
43
- desc 'update', "update #{ReleaseNotes.release_note_model} model"
46
+ desc 'update', "Update #{ReleaseNotes.release_note_model} models"
44
47
  method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
45
48
  method_option :no_log, :aliases => '-n', :type => :boolean, :default => false, :desc => 'disable README.md log of release notes'
46
49
  method_option :reset, :aliases => '-r', :type => :boolean, :default => false, :desc => 'delete all model entries and rebuilds them'
@@ -108,7 +111,7 @@ module ReleaseNotes
108
111
  end
109
112
 
110
113
 
111
- desc 'version', 'show version of release_notes'
114
+ desc 'version', 'Show version of release_notes'
112
115
 
113
116
  def version
114
117
  puts "ReleaseNotes #{ReleaseNotes::VERSION}"
@@ -1,5 +1,11 @@
1
1
  module ReleaseNotes
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace ReleaseNotes
4
+
5
+ initializer 'release_notes.action_controller' do |app|
6
+ ActiveSupport.on_load :action_controller do
7
+ helper ReleaseNotes::ApplicationHelper
8
+ end
9
+ end
4
10
  end
5
11
  end
@@ -0,0 +1,52 @@
1
+ require 'thor/group'
2
+
3
+ module ReleaseNotes
4
+ module Generators
5
+ class Broadcast < Thor::Group
6
+ include Thor::Actions
7
+
8
+ argument :destination, :type => :string
9
+ argument :subject, :type => :string
10
+ argument :body, :type => :string
11
+ argument :release_note_version, :type => :string
12
+
13
+ source_root File.expand_path('../../../generators/templates', __FILE__)
14
+
15
+ def set_local_assigns
16
+ @subject = subject
17
+ @body = body
18
+ @release_note_version = release_note_version.gsub('.', '_')
19
+ @broadcast_template = 'broadcast_blank.md'
20
+ @destination = File.expand_path(destination)
21
+ end
22
+
23
+ def create_directory
24
+ empty_directory(@destination)
25
+ end
26
+
27
+ def get_broadcast_number
28
+ @broadcast_number = next_broadcast_number(@destination)
29
+ end
30
+
31
+ def copy_broadcast
32
+ @filename = "#{destination}/broadcast_#{@broadcast_number}.md"
33
+ template(@broadcast_template, @filename)
34
+ end
35
+
36
+ protected
37
+ def next_broadcast_number(dirname)
38
+ current_broadcast_number(dirname) + 1
39
+ end
40
+
41
+ def current_broadcast_number(dirname)
42
+ broadcast_lookup_at(dirname).collect do |file|
43
+ File.basename(file).split('_').last.to_i
44
+ end.max.to_i
45
+ end
46
+
47
+ def broadcast_lookup_at(dirname)
48
+ Dir.glob("#{dirname}/*_[0-9]*.md")
49
+ end
50
+ end
51
+ end
52
+ end
@@ -28,7 +28,7 @@ module ReleaseNotes
28
28
  end
29
29
  end
30
30
 
31
- def create_update_file
31
+ def create_directory
32
32
  empty_directory(@destination)
33
33
  end
34
34
 
@@ -1,3 +1,3 @@
1
1
  module ReleaseNotes
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/release_notes.rb CHANGED
@@ -13,10 +13,18 @@ module ReleaseNotes
13
13
  mattr_accessor :release_note_model
14
14
  @@release_note_model = 'ReleaseNote'
15
15
 
16
+ # Model name of the model created to store broadcasts.
17
+ mattr_accessor :broadcast_model
18
+ @@broadcast_model = 'Broadcast'
19
+
16
20
  # Name of the folder where release notes are stored.
17
21
  mattr_accessor :release_note_folder
18
22
  @@release_note_folder = 'release_notes'
19
23
 
24
+ # Path that ReleaseNotes::Engine is mounted at in the config/routes.rb file.
25
+ mattr_accessor :mount_at
26
+ @@mount_at = 'release_notes'
27
+
20
28
  # Default way to setup ReleaseNotes. Run rails g release_notes:install
21
29
  # to create a fresh initializer with all configuration values.
22
30
  def self.setup
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.1.3
4
+ version: 0.2.0
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-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,26 +145,33 @@ 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
149
  - app/views/release_notes/release_notes/_shared.html.erb
149
150
  - app/views/release_notes/release_notes/index.html.erb
150
151
  - app/views/release_notes/release_notes/show.html.erb
151
152
  - bin/release_notes
152
153
  - config/routes.rb
153
154
  - features/support/setup.rb
155
+ - lib/generators/active_record/broadcasts_generator.rb
154
156
  - lib/generators/active_record/release_notes_generator.rb
155
- - lib/generators/active_record/templates/migration.rb
157
+ - lib/generators/active_record/templates/broadcasts_migration.rb
158
+ - lib/generators/active_record/templates/release_notes_migration.rb
159
+ - lib/generators/release_notes/broadcasts_generator.rb
156
160
  - lib/generators/release_notes/install_generator.rb
157
161
  - lib/generators/release_notes/orm_helpers.rb
158
162
  - lib/generators/release_notes/release_notes_generator.rb
159
163
  - lib/generators/release_notes/views_generator.rb
160
164
  - lib/generators/templates/README
165
+ - lib/generators/templates/broadcast_blank.md
161
166
  - lib/generators/templates/release_notes.rb
162
167
  - lib/generators/templates/update.md
163
168
  - lib/generators/templates/update_blank.md
164
169
  - lib/release_notes.rb
165
170
  - lib/release_notes/cli.rb
171
+ - lib/release_notes/cli/broadcast.rb
166
172
  - lib/release_notes/cli/helpers.rb
167
173
  - lib/release_notes/engine.rb
174
+ - lib/release_notes/generators/broadcast.rb
168
175
  - lib/release_notes/generators/release_note.rb
169
176
  - lib/release_notes/version.rb
170
177
  - lib/release_notes/versioning.rb