svn_log 0.0.1 → 0.0.2

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/.gitignore CHANGED
@@ -1,4 +1,3 @@
1
1
  *.gem
2
2
  .bundle
3
- Gemfile.lock
4
3
  pkg/*
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 1.9.2@svn_log
1
+ rvm use 1.9.3-head@svn_log
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ svn_log (0.0.1)
5
+ nokogiri
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ nokogiri (1.5.0)
12
+ rake (0.9.2)
13
+ rspec (2.6.0)
14
+ rspec-core (~> 2.6.0)
15
+ rspec-expectations (~> 2.6.0)
16
+ rspec-mocks (~> 2.6.0)
17
+ rspec-core (2.6.4)
18
+ rspec-expectations (2.6.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.6.0)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ rake
27
+ rspec
28
+ svn_log!
@@ -0,0 +1,10 @@
1
+ Based upon the idea of Michael Feathers - that we should gather data from our
2
+ code repositories.
3
+
4
+ Also written to continue to learn Ruby and making Gems.
5
+
6
+ It simply uses svn log to get data from the repository and then parses it into
7
+ data objects which could then be consumed by other applications for graphing
8
+ trends etc.
9
+
10
+
data/Rakefile CHANGED
@@ -5,11 +5,5 @@ RSpec::Core::RakeTask.new(:spec) do |t|
5
5
  t.rspec_opts = ['--format', 'progress' ]
6
6
  end
7
7
 
8
- desc "Run all specs with RCov"
9
- RSpec::Core::RakeTask.new(:rcov) do |t|
10
- t.rcov = true
11
- t.rcov_opts = ['--text-report', '--save', 'coverage.info', '--exclude', 'spec_helper', '--exclude', '^/']
12
- end
13
-
14
8
  task :default => [:spec]
15
9
 
data/TODO.md ADDED
@@ -0,0 +1,17 @@
1
+ /* vim: set filetype=markdown : */
2
+
3
+ * DONE Change to parsing XML - needed to do good job of getting list of files
4
+ * figure out here doc so i can properly test newline problem i struggled with.
5
+ * DONE parse svn log output into some sort of object thingie
6
+ * DONE revision
7
+ * DONE user
8
+ * DONE date and time
9
+ * DONE files
10
+ * DONE files (and the type of change (add, modify, delete)
11
+ * DONE comments
12
+ * make logevent inspect a generated output instead of hardcoding all attributes
13
+ * collate said data along different axis:
14
+ * user
15
+ * date
16
+ * file
17
+ * file collections
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.dirname(__FILE__) + '/../lib/'
4
+
5
+ location = ARGV[0]
6
+
7
+ require 'svn_log'
8
+
9
+ raw_log = SvnLog::Raw.log location
10
+
11
+ puts LogParser.new(raw_log).events.inspect
12
+
13
+
@@ -2,4 +2,6 @@ require "svn_log/version"
2
2
 
3
3
  module SvnLog
4
4
  require 'svn_log/raw'
5
+ require 'svn_log/log_parser'
6
+ require 'svn_log/log_event'
5
7
  end
@@ -0,0 +1,21 @@
1
+ require 'date'
2
+ require 'svn_log/modification'
3
+
4
+ class LogEvent
5
+ attr_reader :revision
6
+ attr_reader :user
7
+ attr_reader :timestamp
8
+ attr_reader :change_list
9
+ attr_reader :message
10
+
11
+ def initialize(log_event)
12
+ @revision = log_event.attribute('revision').value
13
+ @user = log_event.xpath('author').text
14
+ @timestamp = DateTime.parse(log_event.xpath('date').text)
15
+ @message = log_event.xpath('msg').text
16
+ @change_list = log_event.xpath('paths/path').collect do |path|
17
+ Modification.parse(path)
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'svn_log/log_event'
2
+ require 'nokogiri'
3
+
4
+ class LogParser
5
+ attr_reader :events
6
+
7
+ def initialize(log)
8
+ doc = Nokogiri::XML(log).xpath('log/logentry')
9
+ @events = doc.collect do |e|
10
+ LogEvent.new e
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,25 @@
1
+ require 'nokogiri'
2
+
3
+ class Modification
4
+ ADD='A'
5
+ DELETE='D'
6
+ MODIFY='M'
7
+
8
+ attr_reader :type
9
+ attr_reader :path
10
+
11
+ def initialize(type, path)
12
+ @type=type
13
+ @path=path
14
+ end
15
+
16
+ def self.parse(path)
17
+ Modification.new(path.attribute('action').value, path.text)
18
+ end
19
+
20
+ def ==(other)
21
+ @type == other.type &&
22
+ @path == other.path
23
+ end
24
+
25
+ end
@@ -1,5 +1,7 @@
1
1
  module SvnLog
2
- def raw_log
3
- `svn log -vq | grep -ve '^---\|^Changed path'`
2
+ class Raw
3
+ def self.log(file_or_directory)
4
+ `svn log --xml -v #{file_or_directory}`
5
+ end
4
6
  end
5
7
  end
@@ -1,3 +1,3 @@
1
1
  module SvnLog
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,32 @@
1
+ require 'svn_log/log_event'
2
+ require 'nokogiri'
3
+
4
+ describe LogEvent do
5
+ let(:log) do
6
+ Nokogiri::XML('
7
+ <logentry revision="266">
8
+ <author>verdammelt</author>
9
+ <date>2008-12-30T18:04:50.418516Z</date>
10
+ <paths>
11
+ <path
12
+ kind=""
13
+ copyfrom-path="/trunk"
14
+ copyfrom-rev="265"
15
+ action="A">/branches/tnef2.dev</path>
16
+ </paths>
17
+ <msg>creating new branch for v2 rewrite
18
+ and some other stuff</msg>
19
+ </logentry>
20
+ ').children.first
21
+ end
22
+
23
+ subject { LogEvent.new(log) }
24
+
25
+ its(:revision) { should == '266' }
26
+ its(:user) { should == 'verdammelt' }
27
+ its(:timestamp) { should == DateTime.parse('2008-12-30T18:04:50.418516Z') }
28
+ its(:message) { should == "creating new branch for v2 rewrite\nand some other stuff" }
29
+ its(:change_list) {
30
+ should == [Modification.new('A', '/branches/tnef2.dev')]
31
+ }
32
+ end
@@ -0,0 +1,45 @@
1
+ require 'svn_log/log_parser'
2
+
3
+ describe LogParser do
4
+ let(:log) { '<?xml version="1.0" encoding="UTF-8"?>
5
+ <log>
6
+ <logentry
7
+ revision="266">
8
+ <author>verdammelt</author>
9
+ <date>2008-12-30T18:04:50.418516Z</date>
10
+ <paths>
11
+ <path
12
+ kind=""
13
+ copyfrom-path="/trunk"
14
+ copyfrom-rev="265"
15
+ action="A">/branches/tnef2.dev</path>
16
+ </paths>
17
+ <msg>creating new branch for v2 rewrite</msg>
18
+ </logentry>
19
+ <logentry
20
+ revision="265">
21
+ <author>verdammelt</author>
22
+ <date>2008-12-30T17:47:35.535656Z</date>
23
+ <paths>
24
+ <path
25
+ kind=""
26
+ action="D">/branches/tnef-13-branch</path>
27
+ </paths>
28
+ <msg>deleting obsolete tnef-13-branch branch</msg>
29
+ </logentry>
30
+ </log>' }
31
+
32
+ it "separates out the individual logs" do
33
+ LogParser.new(log).events.should have(2).items
34
+ end
35
+
36
+ it "revisions can be gleaned" do
37
+ LogParser.new(log).events.collect { |e| e.revision }.should == ['266', '265']
38
+ end
39
+
40
+ it "can see the date of the event" do
41
+ first_time = DateTime.parse('2008-12-30T18:04:50.418516Z')
42
+ second_time = DateTime.parse('2008-12-30T17:47:35.535656Z')
43
+ LogParser.new(log).events.collect { |e| e.timestamp }.should == [ first_time, second_time ]
44
+ end
45
+ end
@@ -0,0 +1,39 @@
1
+ require 'svn_log/modification'
2
+
3
+ describe Modification do
4
+ context "basic parsing" do
5
+ subject {
6
+ Modification.parse (
7
+ Nokogiri::XML('<path action="A">/branches/tnef2.dev</path>').
8
+ children.
9
+ first)
10
+ }
11
+
12
+ its(:type) { should == Modification::ADD }
13
+ its(:path) { should == '/branches/tnef2.dev' }
14
+ end
15
+
16
+ context "specific types" do
17
+ it "knows add" do
18
+ subjectWithAction('A').type.should == Modification::ADD
19
+ end
20
+ it "modify" do
21
+ subjectWithAction('M').type.should == Modification::MODIFY
22
+ end
23
+ it "delete" do
24
+ subjectWithAction('D').type.should == Modification::DELETE
25
+ end
26
+
27
+ def subjectWithAction(action)
28
+ Modification.parse(
29
+ Nokogiri::XML("<path action=\"#{action}\"></path>").children.first
30
+ )
31
+ end
32
+ end
33
+
34
+ it "modifications can be compared with equality" do
35
+ Modification.new('A', 'a path').should == Modification.new('A', 'a path')
36
+ Modification.new('A', 'a path').should_not == Modification.new('A', 'another path')
37
+ end
38
+
39
+ end
@@ -18,7 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
+ s.add_dependency "nokogiri"
22
+
21
23
  # specify any dependencies here; for example:
22
24
  s.add_development_dependency "rspec"
23
- s.add_development_dependency "rcov"
25
+ s.add_development_dependency "rake"
24
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svn_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-22 00:00:00.000000000Z
12
+ date: 2012-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: &2151930800 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2151930800
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: rspec
16
- requirement: &2153830260 !ruby/object:Gem::Requirement
27
+ requirement: &2151930140 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ! '>='
@@ -21,10 +32,10 @@ dependencies:
21
32
  version: '0'
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *2153830260
35
+ version_requirements: *2151930140
25
36
  - !ruby/object:Gem::Dependency
26
- name: rcov
27
- requirement: &2153829840 !ruby/object:Gem::Requirement
37
+ name: rake
38
+ requirement: &2151929480 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
@@ -32,22 +43,33 @@ dependencies:
32
43
  version: '0'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *2153829840
46
+ version_requirements: *2151929480
36
47
  description: Gather info from an SVN repository from the svn log command.
37
48
  email:
38
49
  - verdammelt@gmail.com
39
- executables: []
50
+ executables:
51
+ - svn_log
40
52
  extensions: []
41
53
  extra_rdoc_files: []
42
54
  files:
43
55
  - .gitignore
56
+ - .rspec
44
57
  - .rvmrc
45
58
  - Gemfile
46
- - README
59
+ - Gemfile.lock
60
+ - README.md
47
61
  - Rakefile
62
+ - TODO.md
63
+ - bin/svn_log
48
64
  - lib/svn_log.rb
65
+ - lib/svn_log/log_event.rb
66
+ - lib/svn_log/log_parser.rb
67
+ - lib/svn_log/modification.rb
49
68
  - lib/svn_log/raw.rb
50
69
  - lib/svn_log/version.rb
70
+ - spec/log_event_spec.rb
71
+ - spec/log_parser_spec.rb
72
+ - spec/modification_spec.rb
51
73
  - svn_log.gemspec
52
74
  homepage: ''
53
75
  licenses: []
@@ -69,8 +91,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
91
  version: '0'
70
92
  requirements: []
71
93
  rubyforge_project: svn_log
72
- rubygems_version: 1.8.10
94
+ rubygems_version: 1.8.16
73
95
  signing_key:
74
96
  specification_version: 3
75
97
  summary: Gather info from an SVN repository.
76
- test_files: []
98
+ test_files:
99
+ - spec/log_event_spec.rb
100
+ - spec/log_parser_spec.rb
101
+ - spec/modification_spec.rb
data/README DELETED
File without changes