simple_changelog 0.0.8

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.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'SimpleChangelog'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,48 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+
6
+ #app-changelog {
7
+ font-family: Helvetica, arial, sans-serif;
8
+ width: 1000px;
9
+ margin: 0 auto;
10
+ }
11
+
12
+ .underlined {
13
+ border-bottom: 1px solid #CCC;
14
+ }
15
+
16
+ #app-changelog .commits {
17
+ margin-left: 50px;
18
+ }
19
+
20
+ .commit .dev, .commit .d {
21
+ color: #2E64FE;
22
+ font-weight: bold;
23
+ }
24
+
25
+ .commit .fix, .commit .f {
26
+ color: #04B431;
27
+ font-weight: bold;
28
+ }
29
+
30
+ .commit .ref, .commit .r {
31
+ color: #FF8000;
32
+ font-weight: bold;
33
+ }
34
+
35
+ .commit .cros {
36
+ color: #000000;
37
+ font-weight: bold;
38
+ }
39
+
40
+ .commit .bug, .commit .b {
41
+ color: #B40404;
42
+ font-weight: bold;
43
+ }
44
+
45
+ .commit .new, .commit .n {
46
+ color: #6A0888;
47
+ font-weight: bold;
48
+ }
@@ -0,0 +1,4 @@
1
+ module SimpleChangelog
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,10 @@
1
+ require_dependency "simple_changelog/application_controller"
2
+
3
+ module SimpleChangelog
4
+ class RepositoriesController < ApplicationController
5
+ def show
6
+ @repo = Repository.new
7
+ @changelog = @repo.load_history
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ module SimpleChangelog
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,26 @@
1
+ module SimpleChangelog
2
+ module RepositoriesHelper
3
+ def long_date_format(datetime)
4
+ datetime.to_date.to_formatted_s :long
5
+ end
6
+
7
+ def highlight_commit_tags(commit_message)
8
+ highlighted_message = commit_message.gsub(/\[[^\[\]]+\]/) do |tag|
9
+ tag_class = tag.gsub(/[^A-Za-z]/, '').downcase
10
+ content_tag(:span, class:tag_class) { tag }
11
+ end
12
+
13
+ highlighted_message.html_safe
14
+ end
15
+
16
+ def current_version_tag
17
+ Repository.new.current_version_tag
18
+ end
19
+
20
+ def changelog_link
21
+ unless Rails.env.production?
22
+ link_to current_version_tag, simple_changelog_url
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ module SimpleChangelog
2
+ class Commit < Struct.new(:message, :date, :id)
3
+ end
4
+ end
@@ -0,0 +1,66 @@
1
+ module SimpleChangelog
2
+ class Repository
3
+ def initialize(path = Rails.root)
4
+ @repo = Grit::Repo.new path
5
+ @tags = @repo.tags
6
+ @commits = @repo.commits
7
+ end
8
+
9
+ def load_history
10
+ history = {}
11
+ if @tags.any? || @commits.any?
12
+ middle_tags = convert_tags(@tags).sort_by { |t| t.date }
13
+ tags = [tail_tag] + middle_tags + [head_tag]
14
+ tags.reverse!
15
+
16
+ tags.each_cons(2) do |prev, succ|
17
+ history[prev] = commits_between(succ, prev).sort_by { |c| c.message }
18
+ end
19
+ end
20
+
21
+ history
22
+ end
23
+
24
+ def current_version_tag
25
+ if @tags.empty?
26
+ @commits.empty? ? '' : 'HEAD'
27
+ else
28
+ @tags.last.name
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def head_tag
35
+ commit = @repo.commits('master', 1).first
36
+ Tag.new('HEAD', commit.date, commit.id)
37
+ end
38
+
39
+ def tail_tag
40
+ commit = @repo.commits('master', 1, @repo.commit_count - 1).first
41
+ Tag.new('TAIL', commit.date, commit.id)
42
+ end
43
+
44
+ def commits_between(from, to)
45
+ commits = @repo.commits_between(from.commit_id, to.commit_id)
46
+ commits << @repo.commit(from.commit_id)
47
+ convert_commits(commits)
48
+ end
49
+
50
+ def convert_commits(commits)
51
+ commits.map do |c|
52
+ Commit.new(c.short_message,
53
+ c.date,
54
+ c.id)
55
+ end
56
+ end
57
+
58
+ def convert_tags(tags)
59
+ tags.map do |t|
60
+ Tag.new(t.name,
61
+ t.tag_date,
62
+ t.commit.id)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,4 @@
1
+ module SimpleChangelog
2
+ class Tag < Struct.new(:name, :date, :commit_id)
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SimpleChangelog</title>
5
+ <%= stylesheet_link_tag "simple_changelog/application", :media => "all" %>
6
+ <%= javascript_include_tag "simple_changelog/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ <div class="commit">
2
+ <%= highlight_commit_tags(commit.message) %>
3
+ </div>
@@ -0,0 +1,7 @@
1
+ <div class="version-tag">
2
+ <h2 class="underlined"><%= version_tag.name %>&nbsp;(<%= long_date_format(version_tag.date) %>)</h2>
3
+ <section class="commits">
4
+ <%= render partial: 'commit',
5
+ collection: changelog[version_tag] %>
6
+ </section>
7
+ </div>
@@ -0,0 +1,7 @@
1
+ <div id="app-changelog">
2
+ <h1 class="underlined">Application repository changelog</h1>
3
+
4
+ <%= render partial: 'version_tag',
5
+ collection: @changelog.keys,
6
+ locals: { changelog: @changelog } %>
7
+ </div>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ SimpleChangelog::Engine.routes.draw do
2
+ get "repositories/show"
3
+
4
+ root to: "repositories#show"
5
+ end
@@ -0,0 +1,17 @@
1
+ module SimpleChangelog
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ desc "Mounts simple_changelog to your application."
7
+
8
+ def mount_engine
9
+ route 'mount SimpleChangelog::Engine => "/simple_changelog", as: "simple_changelog" '
10
+ end
11
+
12
+ def show_readme
13
+ readme "README" if behavior == :invoke
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+
2
+ Generator mounted SimpleChangelog
3
+ in your config/routes.rb file:
4
+
5
+ It will also generate simple_changelog_url
6
+ and simple_changelog_uri methods
7
+
8
+ SimpleChangelog::RepositoriesHelper has been
9
+ connected to your app.
10
+
11
+ You can use the following methods:
12
+ #long_date_format(datetime)
13
+ #highlight_commit_tags(commit_message)
14
+ #current_version_tag
@@ -0,0 +1,4 @@
1
+ require "simple_changelog/engine"
2
+
3
+ module SimpleChangelog
4
+ end
@@ -0,0 +1,17 @@
1
+ require 'grit'
2
+
3
+ module SimpleChangelog
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace SimpleChangelog
6
+
7
+ config.generators do |g|
8
+ g.test_framework :rspec, :view_specs => false
9
+ end
10
+
11
+ initializer 'simple_changelog.action_controller' do |app|
12
+ ActiveSupport.on_load :action_controller do
13
+ helper RepositoriesHelper
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleChangelog
2
+ VERSION = "0.0.8"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :simple_changelog do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_changelog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Sologub
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: grit
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.5.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.5.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: sqlite3
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Simple gem for rails applications and their git repositories. Mounts
79
+ page with history of commits.
80
+ email:
81
+ - alexsologoub@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - app/helpers/simple_changelog/repositories_helper.rb
87
+ - app/helpers/simple_changelog/application_helper.rb
88
+ - app/controllers/simple_changelog/application_controller.rb
89
+ - app/controllers/simple_changelog/repositories_controller.rb
90
+ - app/models/simple_changelog/tag.rb
91
+ - app/models/simple_changelog/commit.rb
92
+ - app/models/simple_changelog/repository.rb
93
+ - app/views/simple_changelog/repositories/_commit.html.erb
94
+ - app/views/simple_changelog/repositories/_version_tag.html.erb
95
+ - app/views/simple_changelog/repositories/show.html.erb
96
+ - app/views/layouts/simple_changelog/application.html.erb
97
+ - app/assets/javascripts/simple_changelog/application.js
98
+ - app/assets/javascripts/simple_changelog/repositories.js
99
+ - app/assets/stylesheets/simple_changelog/repositories.css
100
+ - app/assets/stylesheets/simple_changelog/application.css
101
+ - config/routes.rb
102
+ - lib/simple_changelog.rb
103
+ - lib/tasks/simple_changelog_tasks.rake
104
+ - lib/simple_changelog/engine.rb
105
+ - lib/simple_changelog/version.rb
106
+ - lib/generators/simple_changelog/install_generator.rb
107
+ - lib/generators/templates/README
108
+ - MIT-LICENSE
109
+ - Rakefile
110
+ - README.rdoc
111
+ homepage: https://github.com/marvelousNinja/simple_changelog.git
112
+ licenses: []
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.24
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Simple gem for rails applications and their git repositories. Mounts page
135
+ with history of commits.
136
+ test_files: []