svnx 0.0.2 → 0.0.3

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: 7568851539f67dc7fd63364ea9f321cbd2778eb2
4
- data.tar.gz: 250ae23ce41faca126887be909434539400b30df
3
+ metadata.gz: df897af510240d716cdc7c8c3d1a104ab2d6ca6c
4
+ data.tar.gz: 9124a68c96632f05faeee974e88b5c5551fb82c9
5
5
  SHA512:
6
- metadata.gz: 7349591f27fcaf6c89152c07cef03928814eb5bceaee3efcf49421396734604f57e8c580927d8ead613321857afa981b999a5b774e592ce0047e8415e49c49e6
7
- data.tar.gz: b25d5d269537dc85b929a135a34f0aa49db11ad9c2721a39255b68eb9172a083f9e37ea93f79c89fa0a86fe4c05c3afd56850f334b8f9967f58908550a6b4d4a
6
+ metadata.gz: fce53366b404dddc37fcbfcaa5b86200df0a829806bf3e9f5fdefa8b5607ae42cb90023b4b643e8cdfd530e1b1021c3d540e7f46d5aefc919c08304d92c33c1f
7
+ data.tar.gz: d8cd5441dea00c059678e52d3b05582ca9eb38f227589ed96b60c295ab5d66b2994aa3d04701d037f75b4253b99b2f2e835583206db3572b7c168ad8fc2ccf7e
data/lib/svnx.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  module SVNx
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
@@ -58,4 +58,13 @@ module SVNx
58
58
  cls.new @args
59
59
  end
60
60
  end
61
+
62
+ class CatExec
63
+ attr_reader :output
64
+
65
+ def initialize args
66
+ cmd = CatCommand.new CatCommandArgs.new(args)
67
+ @output = cmd.execute
68
+ end
69
+ end
61
70
  end
data/lib/svnx/entry.rb CHANGED
@@ -10,7 +10,7 @@ module SVNx
10
10
  class Entry
11
11
  include Logue::Loggable
12
12
 
13
- def initialize args = Hash.new
13
+ def initialize args
14
14
  if xmllines = args[:xmllines]
15
15
  if xmllines.kind_of? Array
16
16
  xmllines = xmllines.join ''
data/lib/svnx/exec.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/ruby -w
2
2
  # -*- ruby -*-
3
3
 
4
- require 'rubygems'
5
- require 'riel'
6
4
  require 'svnx/cat/command'
7
5
  require 'svnx/log/command'
8
6
  require 'svnx/info/command'
@@ -2,12 +2,11 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'svnx/command'
5
- require 'rainbow'
5
+ require 'svnx/info/entries'
6
6
 
7
7
  module SVNx
8
8
  class InfoCommandLine < CommandLine
9
9
  def initialize args = Array.new
10
- info "args.to_a: #{args.to_a}".color(:blue)
11
10
  super "info", args.to_a
12
11
  end
13
12
  end
@@ -41,4 +40,14 @@ module SVNx
41
40
  InfoCommandLine.new @args
42
41
  end
43
42
  end
43
+
44
+ class InfoExec
45
+ attr_reader :entry
46
+
47
+ def initialize args
48
+ cmd = InfoCommand.new InfoCommandArgs.new(args)
49
+ # info has only one entry
50
+ @entry = SVNx::Info::Entries.new(:xmllines => cmd.execute)[0]
51
+ end
52
+ end
44
53
  end
@@ -13,15 +13,11 @@ module SVNx::Info
13
13
  attr_reader :path
14
14
  attr_reader :revision
15
15
 
16
- def set_from_xml xmldoc
17
- entry = xmldoc.elements['info/entry']
18
- set_from_element entry
19
- end
20
-
21
16
  def set_from_element elmt
22
17
  set_attr_var elmt, 'kind'
23
18
  set_attr_var elmt, 'path'
24
19
  set_attr_var elmt, 'revision'
20
+
25
21
  set_elmt_var elmt, 'url'
26
22
 
27
23
  repo = elmt.elements['repository']
@@ -31,10 +31,10 @@ module SVNx
31
31
  attr_reader :revision
32
32
  attr_reader :use_cache
33
33
 
34
- def initialize args = Hash.new
34
+ def initialize args
35
35
  @limit = args[:limit]
36
36
  @verbose = args[:verbose]
37
- @use_cache = args[:use_cache].nil? || args[:use_cache]
37
+ @use_cache = args.key?(:use_cache) ? args[:use_cache] : false
38
38
  @revision = args[:revision]
39
39
  super
40
40
  end
@@ -73,4 +73,13 @@ module SVNx
73
73
  cls.new @args
74
74
  end
75
75
  end
76
+
77
+ class LogExec
78
+ attr_reader :entries
79
+
80
+ def initialize args
81
+ cmd = LogCommand.new LogCommandArgs.new(args)
82
+ @entries = SVNx::Log::Entries.new :xmllines => cmd.execute
83
+ end
84
+ end
76
85
  end
@@ -5,18 +5,14 @@ require 'svnx/command'
5
5
 
6
6
  module SVNx
7
7
  class StatusCommandLine < CommandLine
8
- def initialize args = Array.new
8
+ def initialize args
9
9
  super "status", args.to_a
10
10
  end
11
11
  end
12
12
 
13
13
  class StatusCommandArgs < CommandArgs
14
14
  def to_a
15
- ary = Array.new
16
- if @path
17
- ary << @path
18
- end
19
- ary
15
+ [ @path ].compact
20
16
  end
21
17
  end
22
18
 
@@ -25,4 +21,13 @@ module SVNx
25
21
  StatusCommandLine.new @args
26
22
  end
27
23
  end
24
+
25
+ class StatusExec
26
+ attr_reader :entries
27
+
28
+ def initialize args
29
+ cmd = StatusCommand.new StatusCommandArgs.new(args)
30
+ @entries = SVNx::Status::Entries.new(:xmllines => cmd.execute)
31
+ end
32
+ end
28
33
  end
@@ -8,30 +8,17 @@ module SVNx; module Status; end; end
8
8
 
9
9
  module SVNx::Status
10
10
  class Entry < SVNx::Entry
11
-
12
11
  attr_reader :status
13
12
  attr_reader :path
14
13
  attr_reader :status_revision
15
14
  attr_reader :action
15
+ attr_reader :commit_revision
16
16
 
17
- def initialize args = Hash.new
17
+ def initialize args
18
18
  super
19
19
  @action = SVNx::Action.new @status
20
20
  end
21
21
 
22
- def set_from_xml xmldoc
23
- stelmt = xmldoc.elements['status']
24
- tgt = stelmt.elements['target']
25
-
26
- set_attr_var tgt, 'path'
27
-
28
- if entry = tgt.elements['entry']
29
- set_from_element entry
30
- else
31
- @status = "unchanged"
32
- end
33
- end
34
-
35
22
  def set_from_element elmt
36
23
  set_attr_var elmt, 'path'
37
24
 
@@ -39,11 +26,8 @@ module SVNx::Status
39
26
  @status = wcstatus.attributes['item']
40
27
  @status_revision = wcstatus.attributes['revision']
41
28
 
42
- if commit = wcstatus.elements['commit']
43
- @commit_revision = commit.attributes['revision']
44
- else
45
- @commit_revision = nil
46
- end
29
+ commit = wcstatus.elements['commit']
30
+ @commit_revision = commit && commit.attributes['revision']
47
31
  end
48
32
 
49
33
  def to_s
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'integration/tc'
5
+ require 'svnx/info/command'
6
+ require 'svnx/info/entry'
7
+
8
+ module SVNx::Info
9
+ class CommandTestCase < SVNx::IntegrationTestCase
10
+ def test_specified_args
11
+ entry = SVNx::InfoExec.new(path: '/Programs/pvn/pvntestbed.from', revision: nil, limit: nil, verbose: true, use_cache: false).entry
12
+
13
+ assert_not_nil entry
14
+ assert_equal 'dir', entry.kind
15
+ assert_equal '/Programs/pvn/pvntestbed.from', entry.path
16
+ assert_equal '22', entry.revision
17
+ assert_equal 'file:///Programs/Subversion/Repositories/pvntestbed.from', entry.root
18
+ assert_equal 'file:///Programs/Subversion/Repositories/pvntestbed.from', entry.url
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'integration/tc'
5
+ require 'svnx/log/command'
6
+ require 'svnx/log/entries'
7
+
8
+ module SVNx::Log
9
+ class CommandTestCase < SVNx::IntegrationTestCase
10
+ def assert_entry exp_revision, exp_author, exp_npaths, entries, idx
11
+ assert_equal exp_revision, entries[idx].revision
12
+ assert_equal exp_author, entries[idx].author
13
+ assert_equal exp_npaths, entries[idx].paths.size
14
+ end
15
+
16
+ def test_specified_args
17
+ entries = SVNx::LogExec.new(path: '/Programs/pvn/pvntestbed.from', revision: nil, limit: nil, verbose: true, use_cache: false).entries
18
+
19
+ assert_equal 22, entries.size
20
+
21
+ assert_entry '21', 'Governor William J. Le Petomane', 3, entries, 1
22
+ assert_entry '1', 'Gabby Johnson', 1, entries, 21
23
+ end
24
+
25
+ def test_default_args
26
+ entries = SVNx::LogExec.new(path: '/Programs/pvn/pvntestbed.from').entries
27
+
28
+ assert_equal 22, entries.size
29
+
30
+ assert_entry '21', 'Governor William J. Le Petomane', 0, entries, 1
31
+ assert_entry '1', 'Gabby Johnson', 0, entries, 21
32
+ end
33
+
34
+ def test_non_verbose
35
+ entries = SVNx::LogExec.new(path: '/Programs/pvn/pvntestbed.from', verbose: false).entries
36
+
37
+ assert_equal 22, entries.size
38
+
39
+ assert_entry '21', 'Governor William J. Le Petomane', 0, entries, 1
40
+ assert_entry '1', 'Gabby Johnson', 0, entries, 21
41
+ end
42
+
43
+ def test_revision
44
+ entries = SVNx::LogExec.new(path: '/Programs/pvn/pvntestbed.from', revision: '1:15').entries
45
+
46
+ assert_equal 15, entries.size
47
+
48
+ assert_entry '2', 'Harriet Johnson', 0, entries, 1
49
+ assert_entry '15','Mongo', 0, entries, 14
50
+ end
51
+
52
+ def test_limit
53
+ entries = SVNx::LogExec.new(path: '/Programs/pvn/pvntestbed.from', limit: 5).entries
54
+
55
+ assert_equal 5, entries.size
56
+
57
+ assert_entry '22', 'Lyle', 0, entries, 0
58
+ assert_entry '18', 'Lili von Shtupp', 0, entries, 4
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'integration/tc'
5
+ require 'svnx/status/command'
6
+ require 'svnx/status/entries'
7
+ require 'svnx/exec'
8
+
9
+ module SVNx::Status
10
+ class CommandTestCase < SVNx::IntegrationTestCase
11
+ def assert_entry exp_cmt_rev, exp_path, exp_status, exp_st_rev, entries, idx
12
+ entry = entries[idx]
13
+ msg = "entry[#{idx}]: #{entry.path}"
14
+
15
+ assert_equal exp_path, entry.path, msg
16
+ assert_equal exp_cmt_rev, entry.commit_revision, msg
17
+ assert_equal exp_status, entry.status, msg
18
+ assert_equal exp_st_rev, entry.status_revision, msg
19
+ end
20
+
21
+ def test_specified_args
22
+ entries = SVNx::StatusExec.new(path: '/Programs/pvn/pvntestbed.pending', use_cache: false).entries
23
+
24
+ assert_not_nil entries
25
+ assert_equal 5, entries.size
26
+
27
+ sentries = entries.sort { |a, b| a.path <=> b.path }
28
+
29
+ assert_entry '13', '/Programs/pvn/pvntestbed.pending/FirstFile.txt', 'modified', '22', sentries, 0
30
+ assert_entry nil, '/Programs/pvn/pvntestbed.pending/SeventhFile.txt', 'added', '-1', sentries, 1
31
+ assert_entry '9', '/Programs/pvn/pvntestbed.pending/dirzero/SixthFile.txt', 'deleted', '22', sentries, 2
32
+ assert_entry nil, '/Programs/pvn/pvntestbed.pending/src/java/Charlie.java', 'unversioned', nil, sentries, 3
33
+ assert_entry nil, '/Programs/pvn/pvntestbed.pending/src/ruby/dog.rb', 'added', '-1', sentries, 4
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'tc'
5
+ require 'svnx/cat/command'
6
+
7
+ module SVNx::Cat
8
+ class CommandTestCase < PVN::TestCase
9
+ EXPROOT = 'file:///Programs/Subversion/Repositories/pvntestbed.from'
10
+
11
+ def test_cat_default
12
+ expected = Array.new
13
+ expected << 'line one of file two.'
14
+ expected << 'second line'
15
+ expected << 'third line'
16
+ expected << 'line four'
17
+ expected << 'line five'
18
+ expected << 'line 6, Six, VI'
19
+ expected << 'line 7'
20
+ expected.collect! { |x| x + "\n" }
21
+
22
+ cmd = SVNx::CatExec.new path: EXPROOT + "/SecondFile.txt"
23
+
24
+ assert_equal expected, cmd.output
25
+ end
26
+
27
+ def test_cat_revision
28
+ expected = Array.new
29
+ expected << 'line one of file two.'
30
+ expected << 'line four'
31
+ expected << 'line five'
32
+ expected << 'line 6, Six, VI'
33
+ expected << 'line 7'
34
+ expected.collect! { |x| x + "\n" }
35
+
36
+ cmd = SVNx::CatExec.new path: EXPROOT + "/SecondFile.txt", revision: '20'
37
+
38
+ assert_equal expected, cmd.output
39
+ end
40
+
41
+ def test_cat_out_of_range
42
+ expected = Array.new
43
+ expected << 'line one of file two.'
44
+ expected << 'line four'
45
+ expected << 'line five'
46
+ expected << 'line 6, Six, VI'
47
+ expected << 'line 7'
48
+ expected.collect! { |x| x + "\n" }
49
+
50
+ assert_raises(RuntimeError) do
51
+ SVNx::CatExec.new path: EXPROOT + "/SecondFile.txt", revision: '28'
52
+ end
53
+ end
54
+ end
55
+ end
@@ -40,7 +40,6 @@ module SVNx::Log
40
40
 
41
41
  def test_empty_message_element
42
42
  entries = Entries.new :xmllines => Resources::PT_LOG_R19.readlines
43
- nentries = entries.size
44
43
 
45
44
  # empty message here:
46
45
  assert_entry_fields_not_nil entries[0]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svnx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Pace
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logue
@@ -65,18 +65,21 @@ files:
65
65
  - lib/system/command/cachefile.rb
66
66
  - lib/system/command/caching.rb
67
67
  - lib/system/command/line.rb
68
+ - test/integration/info/info_test.rb
69
+ - test/integration/log/log_test.rb
70
+ - test/integration/status/status_test.rb
68
71
  - test/unit/svnx/action_test.rb
72
+ - test/unit/svnx/cat/command_test.rb
69
73
  - test/unit/svnx/info/entries_test.rb
70
- - test/unit/svnx/info/entry_test.rb
71
74
  - test/unit/svnx/log/entries_test.rb
72
75
  - test/unit/svnx/log/entry_test.rb
73
76
  - test/unit/svnx/status/entries_test.rb
74
- - test/unit/svnx/status/entry_test.rb
75
77
  - test/unit/system/command/cachefile_test.rb
76
78
  - test/unit/system/command/caching_test.rb
77
79
  - test/unit/system/command/line_test.rb
78
80
  homepage: http://www.incava.org/projects/svnx
79
- licenses: []
81
+ licenses:
82
+ - MIT
80
83
  metadata: {}
81
84
  post_install_message:
82
85
  rdoc_options: []
@@ -99,13 +102,15 @@ signing_key:
99
102
  specification_version: 4
100
103
  summary: Wrapper around Subversion command line.
101
104
  test_files:
105
+ - test/integration/info/info_test.rb
106
+ - test/integration/log/log_test.rb
107
+ - test/integration/status/status_test.rb
102
108
  - test/unit/svnx/action_test.rb
109
+ - test/unit/svnx/cat/command_test.rb
103
110
  - test/unit/svnx/info/entries_test.rb
104
- - test/unit/svnx/info/entry_test.rb
105
111
  - test/unit/svnx/log/entries_test.rb
106
112
  - test/unit/svnx/log/entry_test.rb
107
113
  - test/unit/svnx/status/entries_test.rb
108
- - test/unit/svnx/status/entry_test.rb
109
114
  - test/unit/system/command/cachefile_test.rb
110
115
  - test/unit/system/command/caching_test.rb
111
116
  - test/unit/system/command/line_test.rb
@@ -1,20 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/info/tc'
5
- require 'svnx/info/entry'
6
-
7
- module SVNx::Info
8
- class EntryTestCase < SVNx::Info::TestCase
9
- def assert_info_entry_equals entry, path, kind, revision
10
- assert_entry_equals entry, :path => path, :kind => 'file', :url => EXPROOT + '/' + path, :root => EXPROOT, :revision => revision
11
- end
12
-
13
- def test_entry_from_xml
14
- xmllines = Resources::PTP_INFO_SIXTH_TXT.readlines
15
-
16
- entry = Entry.new :xmllines => xmllines
17
- assert_info_entry_equals entry, 'dirzero/SixthFile.txt', 'file', '22'
18
- end
19
- end
20
- end
@@ -1,14 +0,0 @@
1
- #!/usr/bin/ruby -w
2
- # -*- ruby -*-
3
-
4
- require 'svnx/status/tc'
5
- require 'svnx/status/entry'
6
-
7
- module SVNx::Status
8
- class EntryTestCase < SVNx::Status::TestCase
9
- def test_entry_from_xml
10
- entry = Entry.new :xmllines => Resources::PTP_STATUS_DOG_RB.readlines
11
- assert_status_entry_equals 'added', 'src/ruby/dog.rb', entry
12
- end
13
- end
14
- end