simple_changelog 0.0.15 → 0.0.16

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2IwNDgyZWJlYzViYjNmMzM0NmYxZTNlYjg3N2ZiNTQxOTRmY2U3Yg==
5
+ data.tar.gz: !binary |-
6
+ NjA5M2QxYWExZjMwZjNiZWE4NmI1MWJjMThlNzA4NTc1YjYyOWRiMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDEzNDkyYzQzNTFhMGIwZmQ2MjYzMDllMjZkN2U0MzQ1ODUwNWM5NzhlNWM1
10
+ ZWNlNmEyOWM0NTA3OWM2NDUyY2Q1MjY1YTEwYWQ5NWYwZTEwYjdiZDBjMWFj
11
+ ZjRhNDU3MzVlNjhhNDhhYmJiYThiODkwODdkOWNhY2IzZTI2ZjM=
12
+ data.tar.gz: !binary |-
13
+ Y2RlYjUyOTY1NDNiZjY5ZWQ3ZTlhNGE2MTZhNDk2MjZiOGVjNzgyZjljM2Zh
14
+ NzU1MjI4Y2I3YWU2N2YyNWI3YjdkYzIzMGU5MzY5NzJmMTUxZWZkZGFmOTJl
15
+ NjU4Y2M5ZTg0MjA4Y2M4YTI5NTEwYTM3ZDMyYzg0ZGMyZDY5MWY=
@@ -16,33 +16,44 @@
16
16
  #app-changelog .commits {
17
17
  margin-left: 50px;
18
18
  }
19
+ .commit {
20
+ padding: 4px;
21
+ }
22
+ .commit.odd {
23
+ background-color: #eee;
24
+ }
19
25
 
20
- .commit .dev, .commit .d {
26
+ .commit .type.dev, .commit .type.d {
21
27
  color: #2E64FE;
22
28
  font-weight: bold;
23
29
  }
24
30
 
25
- .commit .fix, .commit .f {
31
+ .commit type.fix, .commit .f {
26
32
  color: #04B431;
27
33
  font-weight: bold;
28
34
  }
29
35
 
30
- .commit .ref, .commit .r {
36
+ .commit .type.ref, .commit .type.r {
31
37
  color: #FF8000;
32
38
  font-weight: bold;
33
39
  }
34
40
 
35
- .commit .cros {
36
- color: #000000;
41
+ .commit .type.bug, .commit .type.b {
42
+ color: #B40404;
37
43
  font-weight: bold;
38
44
  }
39
45
 
40
- .commit .bug, .commit .b {
41
- color: #B40404;
46
+ .commit .type.new, .commit .type.n {
47
+ color: #6A0888;
42
48
  font-weight: bold;
43
49
  }
44
50
 
45
- .commit .new, .commit .n {
46
- color: #6A0888;
51
+ .commit .name {
52
+ color: #000000;
47
53
  font-weight: bold;
48
54
  }
55
+
56
+ .commit .author {
57
+ color: #888;
58
+ font-size: .8em;
59
+ }
@@ -1,24 +1,9 @@
1
+ require('minigit')
2
+
1
3
  module SimpleChangelog
2
4
  module RepositoriesHelper
3
5
  def long_date_format(datetime)
4
6
  datetime.to_date.to_formatted_s :long
5
7
  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
- ENV['app_version'] ||= Repository.new.current_version_tag
18
- end
19
-
20
- def changelog_link(html_options = {})
21
- link_to current_version_tag, simple_changelog_path, html_options
22
- end
23
8
  end
24
- end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleChangelog
2
- Commit = Struct.new(:message, :date, :id, :author)
2
+ Commit = Struct.new(:name, :type, :message, :author)
3
3
  end
@@ -1,64 +1,64 @@
1
1
  module SimpleChangelog
2
2
  class Repository
3
+
4
+ NEW_LINE_SPLITTER = /\r?\n/
5
+
3
6
  def initialize(path = Rails.root)
4
- @repo = Grit::Repo.new path
5
- @tags = @repo.tags
6
- @commits = @repo.commits
7
+ @repo = MiniGit.new path
8
+
9
+ create_tags
7
10
  end
8
11
 
9
12
  def load_history
10
13
  history = {}
11
14
 
12
- if @tags.any? || @commits.any?
13
- middle_tags = convert_tags(@tags).sort_by { |t| t.date }
14
- tags = [tail_tag] + middle_tags
15
- tags << head_tag if has_head_commits?(middle_tags)
16
- tags.reverse!
17
- tags.each_cons(2) do |prev, succ|
18
- history[prev] = commits_between(succ, prev).sort_by { |c| c.message }
15
+ if @tags.any?
16
+ @tags.each_cons(2) do |prev, succ|
17
+ history[prev] = commits_between(succ, prev)
19
18
  end
20
19
  end
21
20
 
22
21
  history
23
22
  end
24
23
 
25
- def current_version_tag
26
- if @tags.empty?
27
- @commits.empty? ? '' : 'HEAD'
28
- else
29
- last_tag = @tags.sort_by { |t| t.tag_date }.last
30
- last_tag.name
31
- end
32
- end
33
-
34
24
  private
35
25
 
36
- def has_head_commits?(middle_tags)
37
- commit = @repo.commits('master', 1).first
38
- middle_tags.none? { |t| t.commit_id == commit.id }
39
- end
26
+ def create_tags
27
+ tags_string = @repo.capturing.log tags: true, 'simplify-by-decoration' => true, pretty: 'format:%d|q%ai'
40
28
 
41
- def head_tag
42
- commit = @repo.commits('master', 1).first
43
- Tag.new('HEAD', commit.date, commit.id)
44
- end
29
+ @tags = []
45
30
 
46
- def tail_tag
47
- commit = @repo.commits('master', 1, @repo.commit_count - 1).first
48
- Tag.new('TAIL', commit.date, commit.id)
49
- end
31
+ tags_string.split(NEW_LINE_SPLITTER).each do |tag_info|
32
+ match = /\A\((.+)\)\|(.+)\z/.match(tag_info.strip)
33
+ if match
34
+ names = match[1]
35
+ datetime = DateTime.parse(match[2])
50
36
 
51
- def commits_between(from, to)
52
- commits = @repo.commits_between(from.commit_id, to.commit_id)
53
- convert_commits(commits)
54
- end
37
+ names.split(',').each do |name|
38
+ @tags << SimpleChangelog::Tag.new(name.strip, datetime)
39
+ end
40
+ end
41
+ end
55
42
 
56
- def convert_commits(commits)
57
- commits.map { |c| Commit.new(c.short_message, c.date, c.id, c.author.name) }
43
+ @tags.sort! { |a, b| -(a.datetime <=> b.datetime) }
58
44
  end
59
45
 
60
- def convert_tags(tags)
61
- tags.map { |t| Tag.new(t.name, t.tag_date, t.commit.id) }
46
+ def commits_between(prev, succ)
47
+ commits = []
48
+ commits_string = @repo.capturing.log "#{prev.name}..#{succ.name}", pretty: 'format:%an|%s'
49
+
50
+ commits_string.split(NEW_LINE_SPLITTER).each do |commmit_info|
51
+ match = /\A(.+?)\|(\[(.+)\])(.+)\z/.match(commmit_info.strip)
52
+
53
+ if match
54
+ names = match[3].split('][')
55
+ type = names.pop if names.count > 1
56
+
57
+ commits << SimpleChangelog::Commit.new(names.join(', '), type, (match[4].strip if match[4]), match[1])
58
+ end
59
+ end
60
+
61
+ commits
62
62
  end
63
63
  end
64
64
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleChangelog
2
- Tag = Struct.new(:name, :date, :commit_id)
2
+ Tag = Struct.new(:name, :datetime)
3
3
  end
@@ -1,4 +1,8 @@
1
- <div class="commit">
2
- <%= highlight_commit_tags(commit.message) %>
3
- <b>&nbsp;by&nbsp;<%= commit.author %></b>
1
+ <div class="commit <%= cycle("odd", "even") %>">
2
+ <span class="name"><%= commit.name %></span> |
3
+ <% if commit.type %>
4
+ <span class="type <%= commit.type.downcase %>"><%= commit.type %></span> –
5
+ <% end %>
6
+ <span class="message"><%= commit.message %></span>
7
+ <span class="author"> by <%= commit.author %></span>
4
8
  </div>
@@ -1,7 +1,6 @@
1
1
  <div class="version-tag">
2
- <h2 class="underlined"><%= version_tag.name %>&nbsp;(<%= long_date_format(version_tag.date) %>)</h2>
2
+ <h2 class="underlined"><%= version_tag.name %>&nbsp;(<%= long_date_format(version_tag.datetime) %>)</h2>
3
3
  <section class="commits">
4
- <%= render partial: 'commit',
5
- collection: changelog[version_tag] %>
4
+ <%= render partial: 'commit', collection: changelog[version_tag] %>
6
5
  </section>
7
6
  </div>
@@ -1,5 +1,3 @@
1
- require 'grit'
2
-
3
1
  module SimpleChangelog
4
2
  class Engine < ::Rails::Engine
5
3
  isolate_namespace SimpleChangelog
@@ -1,3 +1,3 @@
1
1
  module SimpleChangelog
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
5
- prerelease:
4
+ version: 0.0.16
6
5
  platform: ruby
7
6
  authors:
8
7
  - Alex Sologub
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-01 00:00:00.000000000 Z
11
+ date: 2013-04-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,31 +20,27 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.2.8
30
27
  - !ruby/object:Gem::Dependency
31
- name: grit
28
+ name: minigit
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - '='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 2.5.0
33
+ version: 0.0.3
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - '='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 2.5.0
40
+ version: 0.0.3
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: sqlite3
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -83,54 +74,53 @@ executables: []
83
74
  extensions: []
84
75
  extra_rdoc_files: []
85
76
  files:
86
- - app/helpers/simple_changelog/repositories_helper.rb
87
- - app/helpers/simple_changelog/application_helper.rb
77
+ - app/assets/javascripts/simple_changelog/application.js
78
+ - app/assets/javascripts/simple_changelog/repositories.js
79
+ - app/assets/stylesheets/simple_changelog/application.css
80
+ - app/assets/stylesheets/simple_changelog/repositories.css
88
81
  - app/controllers/simple_changelog/application_controller.rb
89
82
  - app/controllers/simple_changelog/repositories_controller.rb
90
- - app/models/simple_changelog/tag.rb
83
+ - app/helpers/simple_changelog/application_helper.rb
84
+ - app/helpers/simple_changelog/repositories_helper.rb
91
85
  - app/models/simple_changelog/commit.rb
92
86
  - app/models/simple_changelog/repository.rb
87
+ - app/models/simple_changelog/tag.rb
88
+ - app/views/layouts/simple_changelog/application.html.erb
93
89
  - app/views/simple_changelog/repositories/_commit.html.erb
94
90
  - app/views/simple_changelog/repositories/_version_tag.html.erb
95
91
  - 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
92
  - 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
93
  - lib/generators/simple_changelog/install_generator.rb
107
94
  - lib/generators/templates/README
95
+ - lib/simple_changelog/engine.rb
96
+ - lib/simple_changelog/version.rb
97
+ - lib/simple_changelog.rb
98
+ - lib/tasks/simple_changelog_tasks.rake
108
99
  - MIT-LICENSE
109
100
  - Rakefile
110
101
  - README.rdoc
111
102
  homepage: https://github.com/marvelousNinja/simple_changelog.git
112
103
  licenses: []
104
+ metadata: {}
113
105
  post_install_message:
114
106
  rdoc_options: []
115
107
  require_paths:
116
108
  - lib
117
109
  required_ruby_version: !ruby/object:Gem::Requirement
118
- none: false
119
110
  requirements:
120
111
  - - ! '>='
121
112
  - !ruby/object:Gem::Version
122
113
  version: '0'
123
114
  required_rubygems_version: !ruby/object:Gem::Requirement
124
- none: false
125
115
  requirements:
126
116
  - - ! '>='
127
117
  - !ruby/object:Gem::Version
128
118
  version: '0'
129
119
  requirements: []
130
120
  rubyforge_project:
131
- rubygems_version: 1.8.24
121
+ rubygems_version: 2.0.3
132
122
  signing_key:
133
- specification_version: 3
123
+ specification_version: 4
134
124
  summary: Simple gem for rails applications and their git repositories. Mounts page
135
125
  with history of commits.
136
126
  test_files: []