release_notes 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d57288609fb0fa2b5ecebcb9297f0c1325f8d19
4
- data.tar.gz: e66df67f8015fc2c5e846f4075b880ede26fca3c
3
+ metadata.gz: 731dcb71f1a19814625ea48da3cfd1fa952a9c0e
4
+ data.tar.gz: 6f51fcd0ea61d46157b59cc2a7adebde72002921
5
5
  SHA512:
6
- metadata.gz: 2afed717fe251763b46d0d2e91759e593441233362e29951054607ed63852dbbcb2eb0b7ee1beade18c103a0d8bdead0e5c993504e34fc51117acba48e6349e8
7
- data.tar.gz: 154cbf62a72617323b680f1e88abddc001ed2555b56245314402484afc890bfd1f6737536a9a784cd791347a498d0680b215e09bda7adce910528ebbcfc87b23
6
+ metadata.gz: c0ad76f89c32fa8f47fdd59de3ddf16127d785bce48399311e6a9564897e023acb00a6ca2ad7c7587321b1b3fd64257380ab4471f40cbd2ce4662bc26dbdeef5
7
+ data.tar.gz: 232cb6697d9e10cc1e84bb2fbd96906747217a44432f6473f3d70c8d39f507707748c1f5b8f5581a1fea5280a1c8bdd287823a8a38486dbbf0ef86ff878bfdfb
data/README.md CHANGED
@@ -32,45 +32,6 @@ Be sure to migrate your database.
32
32
 
33
33
  $ rake db:migrate
34
34
 
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. You can choose to use a different model name, but you must edit the release_notes initializer file with the updated Broadcast name.
44
-
45
- Migrate your database.
46
-
47
- $ rake db:migrate
48
-
49
- Then add one of the following render tags to whichever view you'd like to display the broadcast message in.
50
-
51
- <%= render 'release_notes/broadcasts/link_back' %>
52
-
53
- OR...
54
-
55
- <%= render 'release_notes/broadcasts/bare' %>
56
-
57
- #### Views
58
-
59
- While not necessary, you may want to copy over the ReleaseNotes views to your app to customize:
60
-
61
- $ rails generate release_notes:views
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
-
74
35
  ## Usage
75
36
 
76
37
  ### Generate a new release note template
@@ -95,42 +56,19 @@ After finalizing your release note markdown file be sure to update your ReleaseN
95
56
 
96
57
  $ release_notes update
97
58
 
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.
103
-
104
- ### View release notes in your application
105
-
106
- 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`).
107
-
108
- ### Create a new Broadcast
109
-
110
- To create a new Broadcast run:
111
-
112
- $ release_notes broadcast new
113
-
114
- This will generate a broadcast markdown file which you can edit.
115
- **Note:** You *can* use HTML within the markdown file.
116
-
117
- ### Update Broadcast
59
+ If you ever want to update a previous release note and/or want to rebuild your ReleaseNotes model and README you can run the following:
118
60
 
119
- After finalizing your broadcast markdown file be sure to update your Broadcast model by running:
61
+ $ release_notes update -r
120
62
 
121
- $ release_notes broadcast update
63
+ ### Getting Help
122
64
 
123
- If you ever want to update a particular broadcast you can run the following:
65
+ To get additional help on release_notes commands or to see all available options just run:
124
66
 
125
- $ release_notes broadcast update -v=VERSION
67
+ $ release_notes --help [command]
126
68
 
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
69
+ ### View release notes in your application
132
70
 
133
- The "latest" version will be set to the `VERSION` specified.
71
+ 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`).
134
72
 
135
73
  ## Contributing
136
74
 
@@ -8,14 +8,6 @@ CONTENT
8
8
  buffer
9
9
  end
10
10
 
11
- def broadcasts_model_contents
12
- buffer = <<-CONTENT
13
- validates :markdown, presence: true
14
- validates :version, presence: true, uniqueness: true
15
- CONTENT
16
- buffer
17
- end
18
-
19
11
  private
20
12
 
21
13
  def model_exists?
@@ -6,16 +6,10 @@ ReleaseNotes.setup do |config|
6
6
  # Name of the model you're using to store the various release notes.
7
7
  config.release_note_model = 'ReleaseNote'
8
8
 
9
- # Name of the model you're using to store broadcasts.
10
- config.broadcast_model = 'Broadcast'
11
-
12
9
  # Name of the model you're using to store users.
13
10
  config.user_model = 'User'
14
11
 
15
- # Name of the model you're using to store broadcasts for users.
16
- config.user_broadcast_model = 'UserBroadcast'
17
-
18
- # Name of the folder you're using to store the release note and broadcast markdown files.
12
+ # Name of the folder you're using to store the release note markdown files.
19
13
  config.release_note_folder = 'release_notes'
20
14
 
21
15
  # Path that ReleaseNotes::Engine is mounted at in the config/routes.rb file.
@@ -2,15 +2,11 @@ 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'
6
5
  require 'release_notes/cli/helpers'
7
6
  require 'release_notes/generators/release_note'
8
- require 'release_notes/generators/broadcast'
9
7
 
10
8
  module ReleaseNotes
11
9
  class CLI < Thor
12
- register(Broadcast, 'broadcast', 'broadcast [COMMAND]', 'Create a new broadcast or update Broadcast models')
13
-
14
10
  package_name 'ReleaseNotes'
15
11
  map '-v' => :version
16
12
 
@@ -47,7 +43,6 @@ module ReleaseNotes
47
43
  method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
48
44
  method_option :no_log, :aliases => '-n', :type => :boolean, :default => false, :desc => 'disable README.md log of release notes'
49
45
  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'
51
46
 
52
47
  def update
53
48
  # If reset option is passed delete all release notes in model
@@ -1,3 +1,3 @@
1
1
  module ReleaseNotes
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/release_notes.rb CHANGED
@@ -13,18 +13,10 @@ 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
-
20
16
  # Model name of the model created to store users.
21
17
  mattr_accessor :user_model
22
18
  @@user_model = 'User'
23
19
 
24
- # Model name of the model created to store broadcasts for users.
25
- mattr_accessor :user_broadcast_model
26
- @@user_broadcast_model = 'UserBroadcast'
27
-
28
20
  # Name of the folder where release notes are stored.
29
21
  mattr_accessor :release_note_folder
30
22
  @@release_note_folder = 'release_notes'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: release_notes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Robins
@@ -145,35 +145,27 @@ 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/_bare.html.erb
149
- - app/views/release_notes/broadcasts/_link_back.html.erb
150
148
  - app/views/release_notes/release_notes/_shared.html.erb
151
149
  - app/views/release_notes/release_notes/index.html.erb
152
150
  - app/views/release_notes/release_notes/show.html.erb
153
151
  - bin/release_notes
154
152
  - config/routes.rb
155
153
  - features/support/setup.rb
156
- - lib/generators/active_record/broadcasts_generator.rb
157
154
  - lib/generators/active_record/release_notes_generator.rb
158
- - lib/generators/active_record/templates/broadcasts_migration.rb
159
155
  - lib/generators/active_record/templates/release_notes_migration.rb
160
- - lib/generators/release_notes/broadcasts_generator.rb
161
156
  - lib/generators/release_notes/install_generator.rb
162
157
  - lib/generators/release_notes/orm_helpers.rb
163
158
  - lib/generators/release_notes/release_notes_generator.rb
164
159
  - lib/generators/release_notes/views_generator.rb
165
160
  - lib/generators/templates/README
166
- - lib/generators/templates/broadcast_blank.md
167
161
  - lib/generators/templates/release_notes.rb
168
162
  - lib/generators/templates/release_notes_controller_decorator.rb
169
163
  - lib/generators/templates/update.md
170
164
  - lib/generators/templates/update_blank.md
171
165
  - lib/release_notes.rb
172
166
  - lib/release_notes/cli.rb
173
- - lib/release_notes/cli/broadcast.rb
174
167
  - lib/release_notes/cli/helpers.rb
175
168
  - lib/release_notes/engine.rb
176
- - lib/release_notes/generators/broadcast.rb
177
169
  - lib/release_notes/generators/release_note.rb
178
170
  - lib/release_notes/version.rb
179
171
  - lib/release_notes/versioning.rb
@@ -1,5 +0,0 @@
1
- <% if ReleaseNotes.broadcast_model.constantize.last %>
2
- <div>
3
- <%= markup(ReleaseNotes.broadcast_model.constantize.last.markdown).html_safe %>
4
- </div>
5
- <% end %>
@@ -1,6 +0,0 @@
1
- <%= render 'release_notes/broadcasts/bare' %>
2
- <div>
3
- <a href="/<%= ReleaseNotes.mount_at %>">
4
- View all release notes
5
- </a>
6
- </div>
@@ -1,47 +0,0 @@
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}.rb"
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
@@ -1,13 +0,0 @@
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
@@ -1,16 +0,0 @@
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,3 +0,0 @@
1
- ### <% if @release_note_version.nil? -%><%= @subject -%><% else -%>[<%= @subject -%>](/<%= ReleaseNotes.mount_at -%>/<%= @release_note_version -%>)<% end -%>
2
-
3
- <%= @body -%>
@@ -1,116 +0,0 @@
1
- module ReleaseNotes
2
- class Broadcast < Thor
3
- desc 'broadcast 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 :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
-
9
- def new
10
- release_note_version = options[:release_note_version] || ""
11
-
12
- ReleaseNotes::Generators::Broadcast.start([options[:destination],
13
- options[:subject],
14
- options[:body],
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
34
- end
35
-
36
-
37
- desc 'broadcast update', "Update #{ReleaseNotes.broadcast_model} models"
38
- method_option :destination, :aliases => '-d', :default => ReleaseNotes.release_note_folder, :desc => 'relative location of release note folder'
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'
41
-
42
- def update
43
- # If reset option is passed delete all broadcasts in model
44
- if options[:reset]
45
- ReleaseNotes.broadcast_model.constantize.all.each do |b|
46
- b.destroy
47
- end
48
- end
49
-
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}")
54
-
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)
60
-
61
- say "#{ReleaseNotes.broadcast_model} model successfully updated.", :green
62
- else
63
- ReleaseNotes.broadcast_model.constantize.create(version: version,
64
- markdown: markdown)
65
-
66
- say "#{ReleaseNotes.broadcast_model} model successfully saved.", :green
67
- end
68
- else
69
- # Gets last broadcast version from db
70
- last_broadcast = ReleaseNotes.broadcast_model.constantize.last
71
-
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
93
- end
94
-
95
- protected
96
- def collect_broadcast_files(dirname)
97
- broadcast_lookup_at(dirname).collect do |file|
98
- File.basename(file)
99
- end
100
- end
101
-
102
- def current_broadcast_number(dirname)
103
- broadcast_lookup_at(dirname).collect do |file|
104
- File.basename(file).split('_').last.to_i
105
- end.max.to_i
106
- end
107
-
108
- def broadcast_lookup_at(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])
114
- end
115
- end
116
- end
@@ -1,58 +0,0 @@
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
-
19
- if release_note_version != ""
20
- @release_note_version = release_note_version.gsub('.', '_')
21
- else
22
- @release_note_version = nil
23
- end
24
-
25
- @broadcast_template = 'broadcast_blank.md'
26
- @destination = File.expand_path(destination)
27
- end
28
-
29
- def create_directory
30
- empty_directory(@destination)
31
- end
32
-
33
- def get_broadcast_number
34
- @broadcast_number = next_broadcast_number(@destination)
35
- end
36
-
37
- def copy_broadcast
38
- @filename = "#{destination}/broadcast_#{@broadcast_number}.md"
39
- template(@broadcast_template, @filename)
40
- end
41
-
42
- protected
43
- def next_broadcast_number(dirname)
44
- current_broadcast_number(dirname) + 1
45
- end
46
-
47
- def current_broadcast_number(dirname)
48
- broadcast_lookup_at(dirname).collect do |file|
49
- File.basename(file).split('_').last.to_i
50
- end.max.to_i
51
- end
52
-
53
- def broadcast_lookup_at(dirname)
54
- Dir.glob("#{dirname}/*_[0-9]*.md")
55
- end
56
- end
57
- end
58
- end