bezebe-cvs 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  *.gem
2
2
  .bundle
3
3
  pkg/*
4
+ Gemfile.lock
data/.rvmrc ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ #environment_id="ruby-1.9.3-p125@bezebe-cvs"
10
+ environment_id="@bezebe-cvs"
11
+
12
+ # First we attempt to load the desired environment directly from the environment
13
+ # file. This is very fast and efficient compared to running through the entire
14
+ # CLI and selector. If you want feedback on which environment was used then
15
+ # insert the word 'use' after --create as this triggers verbose mode.
16
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
17
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
18
+ then
19
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
20
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
21
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
22
+ else
23
+ # If the environment file has not yet been created, use the RVM CLI to select.
24
+ rvm --create use "$environment_id" || {
25
+ echo "Failed to create RVM environment '${environment_id}'."
26
+ return 1
27
+ }
28
+ fi
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # Bezebe::CVS
2
+
3
+ ## Synopsis
4
+
5
+ At the top of the file there should be a short introduction and/ or overview that explains **what** the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)
6
+
7
+ ## Code Example
8
+
9
+ ## Motivation
10
+
11
+ ## Installation
12
+
13
+ * gem install bezebe-cvs
14
+
15
+ ## Tests
16
+
17
+ * rspec
18
+
19
+ ## Contributors
20
+
21
+ ## License
22
+
23
+ MIT
data/bezebe-cvs.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["tnarik@gmail.com"]
11
11
  gem.summary = "bussy bee CVS"
12
12
  gem.description = "a set of tools for the bussy bee - CVS"
13
- gem.homepage = "http://tnarik.net/stuff/bezebe-cvs"
13
+ gem.homepage = "http://github.com/tnarik/bezebe-cvs"
14
14
  gem.license = "MIT"
15
15
 
16
16
  gem.rubyforge_project = "bezebe"
@@ -26,4 +26,8 @@ Gem::Specification.new do |gem|
26
26
  # devevelopment dependencies
27
27
  gem.add_development_dependency "thor"
28
28
  gem.add_development_dependency "bundler"
29
+
30
+ # testing
31
+ gem.add_development_dependency 'rspec'
32
+ gem.add_development_dependency 'factory_girl'
29
33
  end
data/lib/bezebe-cvs.rb CHANGED
@@ -1,76 +1,18 @@
1
1
  require "bezebe-cvs/version"
2
2
 
3
- require "bezebe-cvs/loginfo"
3
+ require "bezebe-cvs/log_info"
4
4
  require "bezebe-cvs/revision"
5
+ require "bezebe-cvs/sym_name"
5
6
  require "bezebe-cvs/cvslistener"
7
+ require "bezebe-cvs/cvs_client"
6
8
 
7
9
  require "rjb"
8
10
 
9
11
  module Bezebe
10
- module CVS
11
- # Your code goes here...
12
-
13
- attr_accessor :connection
14
-
15
- def self.loadJar
16
- Rjb::load(nil, nil)
17
- Rjb::add_jar(File.expand_path(File.join(File.dirname(File.expand_path(__FILE__)), 'vendor' , 'org-netbeans-lib-cvsclient.jar')))
18
- end
19
-
20
- def self.connect(username, password, host, port = nil, repository = nil)
21
- loadJar
22
-
23
- @connection = Rjb::import('org.netbeans.lib.cvsclient.connection.PServerConnection').new
24
- scrambler = Rjb::import('org.netbeans.lib.cvsclient.connection.StandardScrambler').getInstance
25
-
26
- @connection.setUserName username
27
- @connection.setEncodedPassword(scrambler.scramble(password))
28
- @connection.setHostName host
29
- @connection.setPort port unless port.nil?
30
- @connection.setRepository repository unless repository.nil?
31
-
32
- @connection.open
33
- end
34
-
35
- def self.rlog (filename = nil)
36
- if @connection.nil?
37
- puts "a connection is needed first"
38
- return false
39
- end
40
-
41
- begin
42
- standardadminhandler_class = Rjb::import('org.netbeans.lib.cvsclient.admin.StandardAdminHandler')
43
- client_class = Rjb::import('org.netbeans.lib.cvsclient.Client')
44
- client = client_class.new(@connection, standardadminhandler_class.new)
45
- client.setLocalPath "/tmp"
46
-
47
- logcommand_class = Rjb::import('org.netbeans.lib.cvsclient.command.log.RlogCommand')
48
- logcommand = logcommand_class.new
49
- logcommand.setModule "#{filename}" unless filename.nil?
50
-
51
- a_class = Rjb::import('org.netbeans.lib.cvsclient.command.GlobalOptions')
52
-
53
- event_manager = client.getEventManager
54
- cvslistener = ::Bezebe::CVS::CvsListener.new
55
- cvslistener = Rjb::bind(cvslistener, 'org.netbeans.lib.cvsclient.event.CVSListener')
56
- event_manager.addCVSListener cvslistener
57
-
58
- client.executeCommand(logcommand, a_class.new)
59
-
60
- puts cvslistener.logInfo.to_yaml
61
- puts "\nInformation from HEAD release\n"
62
- puts cvslistener.revision.to_yaml
63
-
64
- puts "\nInformation from symbolic names\n"
65
- names = cvslistener.symNames.toArray
66
- names.each do |name|
67
- puts "- NAME: #{name.getName} FOR REVISION: #{name.getRevision} BRANCH?: #{name.isBranch}"
68
- end
69
- puts "\n\n"
70
- rescue AuthenticationException => e
71
- p e.getMessage
72
- p e.printStackTrace
12
+ module CVS
13
+ def self.loadJar
14
+ Rjb::load(nil, nil)
15
+ Rjb::add_jar(File.expand_path(File.join(File.dirname(File.expand_path(__FILE__)), 'vendor' , 'org-netbeans-lib-cvsclient.jar')))
73
16
  end
74
17
  end
75
- end
76
18
  end
@@ -0,0 +1,238 @@
1
+ require "bezebe-cvs/version"
2
+
3
+ require "bezebe-cvs/log_info"
4
+ require "bezebe-cvs/revision"
5
+ require "bezebe-cvs/sym_name"
6
+ require "bezebe-cvs/cvslistener"
7
+
8
+ require "rjb"
9
+
10
+ module Bezebe
11
+ module CVS
12
+ class CVSClient
13
+ attr_accessor :connection, :last_error
14
+
15
+ def initialize
16
+ ::Bezebe::CVS.loadJar
17
+ end
18
+
19
+ def connect(*connection_details)
20
+ @connection = Rjb::import('org.netbeans.lib.cvsclient.connection.PServerConnection').new
21
+ scrambler = Rjb::import('org.netbeans.lib.cvsclient.connection.StandardScrambler').getInstance
22
+
23
+ if connection_details.size == 1 then
24
+ connection_details = connection_details[0]
25
+
26
+ @connection.setUserName connection_details[:username]
27
+ @connection.setEncodedPassword(scrambler.scramble(connection_details[:password]))
28
+ @connection.setHostName connection_details[:host]
29
+ @connection.setRepository connection_details[:repository] unless connection_details[:repository].nil?
30
+ @connection.setPort connection_details[:port] unless connection_details[:port].nil?
31
+ elsif connection_details.size >= 4 then
32
+ @connection.setUserName connection_details[0]
33
+ @connection.setEncodedPassword(scrambler.scramble(connection_details[1]))
34
+ @connection.setHostName connection_details[2]
35
+ @connection.setRepository connection_details[3] unless connection_details[3].nil?
36
+ @connection.setPort connection_details[4] unless connection_details[4].nil?
37
+ end
38
+
39
+
40
+ begin
41
+ @connection.open
42
+ return true
43
+ rescue AuthenticationException => e
44
+ #p e
45
+ #p e.getMessage
46
+ #p e.printStackTrace
47
+ case e.getMessage
48
+ when "AuthenticationFailed"
49
+ @last_error = "AUTHENTICATION ERROR"
50
+ when "IOException"
51
+ @last_error = "CONFIGURATION ERROR"
52
+ end
53
+ return false
54
+ end
55
+ end
56
+
57
+ def is_open?
58
+ return @connection.isOpen
59
+ end
60
+
61
+ def get_cvs_client
62
+ standardadminhandler_class = Rjb::import('org.netbeans.lib.cvsclient.admin.StandardAdminHandler')
63
+ client_class = Rjb::import('org.netbeans.lib.cvsclient.Client')
64
+ client = client_class.new(@connection, standardadminhandler_class.new)
65
+
66
+ return client
67
+ end
68
+
69
+ def update
70
+ if @connection.nil?
71
+ puts "a connection is needed first"
72
+ return false
73
+ end
74
+
75
+ begin
76
+ client = get_cvs_client
77
+ client.setLocalPath "/tmp/w3c/test/"
78
+ rescue Exception => e
79
+ p e
80
+ rescue CommandException => e
81
+ p e.printStackTrace
82
+ rescue AuthenticationException => e
83
+ p e.getMessage
84
+ p e.printStackTrace
85
+ end
86
+ end
87
+
88
+ def checkout (path, filenames = nil)
89
+ if @connection.nil?
90
+ puts "a connection is needed first"
91
+ return false
92
+ end
93
+
94
+ begin
95
+ client = get_cvs_client
96
+ client.setLocalPath path
97
+
98
+ checkoutcommand_class = Rjb::import('org.netbeans.lib.cvsclient.command.checkout.CheckoutCommand')
99
+ checkoutcommand = checkoutcommand_class.new
100
+
101
+ checkoutcommand.setModule "#{filenames}" unless filenames.nil? or filenames.is_a? Array
102
+ filenames.each { |m| checkoutcommand.setModule "#{m}" } unless filenames.nil? or !filenames.is_a? Array
103
+
104
+ a_class = Rjb::import('org.netbeans.lib.cvsclient.command.GlobalOptions')
105
+ a = a_class.new
106
+
107
+ event_manager = client.getEventManager
108
+ cvslistener = ::Bezebe::CVS::CvsListener.new
109
+ cvslistener = Rjb::bind(cvslistener, 'org.netbeans.lib.cvsclient.event.CVSListener')
110
+ cvslistener.client = client
111
+ event_manager.addCVSListener cvslistener
112
+
113
+ client.executeCommand(checkoutcommand, a)
114
+ rescue => e
115
+ p e
116
+ rescue CommandAbortedException => e
117
+ p e.printStackTrace
118
+ rescue CommandException => e
119
+ p e.printStackTrace
120
+ rescue AuthenticationException => e
121
+ p e.getMessage
122
+ p e.printStackTrace
123
+ end
124
+ end
125
+
126
+ def status (path, filenames = nil)
127
+ if @connection.nil?
128
+ puts "a connection is needed first"
129
+ return false
130
+ end
131
+
132
+ begin
133
+ client = get_cvs_client
134
+ client.setLocalPath path
135
+
136
+ statuscommand_class = Rjb::import('org.netbeans.lib.cvsclient.command.status.StatusCommand')
137
+ statuscommand = statuscommand_class.new
138
+
139
+ file_class = Rjb::import('java.io.File')
140
+ files = []
141
+ files << ( file_class.new filenames ) unless filenames.nil? or filenames.is_a? Array
142
+ filenames.each { |m| files << ( file_class.new m) } unless filenames.nil? or !filenames.is_a? Array
143
+ statuscommand.setFiles files
144
+
145
+ a_class = Rjb::import('org.netbeans.lib.cvsclient.command.GlobalOptions')
146
+ a = a_class.new
147
+ #a.setTraceExecution true
148
+
149
+ event_manager = client.getEventManager
150
+ cvslistener = ::Bezebe::CVS::CvsListener.new
151
+ cvslistener = Rjb::bind(cvslistener, 'org.netbeans.lib.cvsclient.event.CVSListener')
152
+ event_manager.addCVSListener cvslistener
153
+
154
+ client.executeCommand(statuscommand, a)
155
+ return cvslistener
156
+ rescue Exception => e
157
+ p e
158
+ rescue CommandException => e
159
+ p e.printStackTrace
160
+ rescue AuthenticationException => e
161
+ p e.getMessage
162
+ p e.printStackTrace
163
+ end
164
+ end
165
+
166
+ def log (path, filenames = nil)
167
+ if @connection.nil?
168
+ puts "a connection is needed first"
169
+ return false
170
+ end
171
+
172
+ begin
173
+ client = get_cvs_client
174
+ client.setLocalPath path
175
+
176
+ logcommand_class = Rjb::import('org.netbeans.lib.cvsclient.command.log.LogCommand')
177
+ logcommand = logcommand_class.new
178
+
179
+ file_class = Rjb::import('java.io.File')
180
+ files = []
181
+ files << ( file_class.new filenames ) unless filenames.nil? or filenames.is_a? Array
182
+ filenames.each { |m| files << ( file_class.new m) } unless filenames.nil? or !filenames.is_a? Array
183
+ logcommand.setFiles files
184
+
185
+ a_class = Rjb::import('org.netbeans.lib.cvsclient.command.GlobalOptions')
186
+ a = a_class.new
187
+
188
+ event_manager = client.getEventManager
189
+ cvslistener = ::Bezebe::CVS::CvsListener.new
190
+ cvslistener = Rjb::bind(cvslistener, 'org.netbeans.lib.cvsclient.event.CVSListener')
191
+ event_manager.addCVSListener cvslistener
192
+
193
+ client.executeCommand(logcommand, a)
194
+ return cvslistener
195
+ rescue Exception => e
196
+ p e
197
+ rescue CommandException => e
198
+ p e.printStackTrace
199
+ rescue AuthenticationException => e
200
+ p e.getMessage
201
+ p e.printStackTrace
202
+ end
203
+ end
204
+
205
+ def rlog (filenames = nil)
206
+ if @connection.nil?
207
+ puts "a connection is needed first"
208
+ return false
209
+ end
210
+
211
+ begin
212
+ client = get_cvs_client
213
+
214
+ logcommand_class = Rjb::import('org.netbeans.lib.cvsclient.command.log.RlogCommand')
215
+ logcommand = logcommand_class.new
216
+
217
+ logcommand.setModule "#{filenames}" unless filenames.nil? or filenames.is_a? Array
218
+ filenames.each { |m| logcommand.setModule "#{m}" } unless filenames.nil? or !filenames.is_a? Array
219
+
220
+ a_class = Rjb::import('org.netbeans.lib.cvsclient.command.GlobalOptions')
221
+
222
+ event_manager = client.getEventManager
223
+ cvslistener = ::Bezebe::CVS::CvsListener.new
224
+ cvslistener = Rjb::bind(cvslistener, 'org.netbeans.lib.cvsclient.event.CVSListener')
225
+ event_manager.addCVSListener cvslistener
226
+
227
+ client.executeCommand(logcommand, a_class.new)
228
+ return cvslistener
229
+ rescue Exception => e
230
+ p e
231
+ rescue AuthenticationException => e
232
+ p e.getMessage
233
+ p e.printStackTrace
234
+ end
235
+ end
236
+ end
237
+ end
238
+ end
@@ -2,26 +2,59 @@ module Bezebe
2
2
  module CVS
3
3
  class CvsListener
4
4
 
5
- attr_accessor :logInfo, :revision, :symNames
5
+ attr_accessor :logInfo, :logInfos, :client
6
6
 
7
7
  def messageSent (message_event)
8
+ #p "sent"
9
+ #p message_event.getMessage if !message_event.getMessage.empty?
10
+ #p message_event.isError if message_event.isError
11
+ #p message_event.isTagged
12
+ #p message_event.toString
13
+ #p message_event.getSource._classname
14
+ if message_event.getSource._classname == "org.netbeans.lib.cvsclient.response.ErrorMessageResponse" then
15
+ #p message_event.getSource.getMessage
16
+ if message_event.getSource.getMessage =~ /\[server\ aborted\]/ then
17
+ client.abort
18
+ end
19
+ end
8
20
  end
9
21
  def fileAdded (file_added_event)
22
+ #p "added"
10
23
  end
11
24
  def fileToRemove (file_to_remove_event)
25
+ #p "toremove"
12
26
  end
13
27
  def fileRemoved (file_removed_event)
28
+ #p "removed"
14
29
  end
15
30
  def fileUpdated (file_updated_event)
31
+ #p "updated"
16
32
  end
17
33
  def fileInfoGenerated (file_info_event)
18
- @logInfo = ::Bezebe::CVS::LogInfo.new file_info_event.getInfoContainer
19
- @revision = ::Bezebe::CVS::Revision.new file_info_event.getInfoContainer.getRevision @logInfo.headRevision
20
- @symNames = file_info_event.getInfoContainer.getSymNamesForRevision @revision.number
34
+ #p "info"
35
+ if file_info_event.getInfoContainer._classname == "org.netbeans.lib.cvsclient.command.log.LogInformation" then
36
+ @logInfo = ::Bezebe::CVS::LogInfo.new file_info_event.getInfoContainer
37
+ @logInfos = [] if @logInfos.nil?;
38
+ @logInfos << @logInfo
39
+ end
40
+ if file_info_event.getInfoContainer._classname == "org.netbeans.lib.cvsclient.command.status.StatusInformation" then
41
+ p "some status information to be processed"
42
+ p file_info_event.getInfoContainer.getRepositoryRevision
43
+ p file_info_event.getInfoContainer.getWorkingRevision
44
+ p file_info_event.getInfoContainer.getStatusString
45
+ p file_info_event.getInfoContainer.getStickyDate
46
+ p file_info_event.getInfoContainer.getStickyOptions
47
+ p file_info_event.getInfoContainer.getStickyTag
48
+
49
+ p file_info_event.getInfoContainer.getRepositoryFileName
50
+ end
51
+ return nil
21
52
  end
22
53
  def commandTerminated (termination_event)
54
+ #p "terminated"
23
55
  end
24
56
  def moduleExpanded (module_expansion_event)
57
+ #p "expanded"
25
58
  end
26
59
  end
27
60
  end
@@ -0,0 +1,57 @@
1
+ module Bezebe
2
+ module CVS
3
+ class LogInfo
4
+ attr_accessor :headRevision, :totalRevisions, :description, :repositoryFilename, :file, :branch, :accessList,
5
+ :selectedRevisions, :keywordSubstitution, :locks, :revisions, :symbolicNames
6
+
7
+ def initialize(logInformation = nil)
8
+ begin
9
+ if logInformation.kind_of? Rjb::Rjb_JavaProxy then
10
+ if logInformation._classname == "org.netbeans.lib.cvsclient.command.log.LogInformation" then
11
+ @headRevision = logInformation.getHeadRevision
12
+ @totalRevisions = logInformation.getTotalRevisions
13
+ @description = logInformation.getDescription
14
+ @repositoryFilename = logInformation.getRepositoryFilename
15
+ @file = logInformation.getFile
16
+ @branch = logInformation.getBranch
17
+ @accessList = logInformation.getAccessList
18
+ @selectedRevisions = logInformation.getSelectedRevisions
19
+ @keywordSubstitution = logInformation.getKeywordSubstitution
20
+ @locks = logInformation.getLocks
21
+
22
+ # list of revisions
23
+ @revisions = {}
24
+ unless logInformation.getRevisionList.nil? then
25
+ revisions = logInformation.getRevisionList.toArray
26
+ revisions.each do |revision|
27
+ new_revision = ::Bezebe::CVS::Revision.new revision
28
+ @revisions[new_revision.number] = new_revision
29
+ end
30
+ end
31
+
32
+ # list of symbolic names
33
+ @symbolicNames = {}
34
+ unless logInformation.getAllSymbolicNames.nil? then
35
+ symbolicNames = logInformation.getAllSymbolicNames.toArray
36
+ symbolicNames.each do |symbolicName|
37
+ new_symbolicName = ::Bezebe::CVS::SymName.new symbolicName
38
+ @symbolicNames[new_symbolicName.name] = new_symbolicName
39
+ end
40
+ end
41
+ end
42
+ end
43
+ rescue Exception => e
44
+ p e.message
45
+ end
46
+ end
47
+
48
+ def symName_for_revision (revision)
49
+ list = []
50
+ @symbolicNames.each do |k, symbolicName|
51
+ list << symbolicName if k == revision
52
+ end
53
+ return list;
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,7 +1,7 @@
1
1
  module Bezebe
2
2
  module CVS
3
3
  class Revision
4
- attr_accessor :number, :author, :message, :state, :lines, :dateString
4
+ attr_accessor :number, :author, :message, :state, :lines, :dateString, :commitID, :branches
5
5
 
6
6
  def initialize(revision = nil)
7
7
  if revision.kind_of? Rjb::Rjb_JavaProxy then
@@ -12,6 +12,8 @@ module CVS
12
12
  @state = revision.getState
13
13
  @lines = revision.getLines
14
14
  @dateString = revision.getDateString
15
+ @commitID = revision.getCommitID
16
+ @branches = revision.getBranches
15
17
  end
16
18
  end
17
19
  end
@@ -0,0 +1,21 @@
1
+ module Bezebe
2
+ module CVS
3
+ class SymName
4
+ attr_accessor :name, :revision
5
+
6
+ def initialize(symName = nil)
7
+ if symName.kind_of? Rjb::Rjb_JavaProxy then
8
+ if symName._classname == "org.netbeans.lib.cvsclient.command.log.LogInformation$SymName" then
9
+ @name = symName.getName
10
+ @revision = symName.getRevision
11
+ @branch = symName.isBranch
12
+ end
13
+ end
14
+ end
15
+
16
+ def isBranch?
17
+ return @branch;
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Bezebe
2
2
  module CVS
3
- VERSION = "0.0.0"
3
+ VERSION = "0.0.1"
4
4
  end
5
5
  end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bezebe::CVS do
4
+ describe "when using a known repository (W3)" do
5
+
6
+ describe "with correct credentials" do
7
+ it "should work"
8
+ end
9
+
10
+ describe "with wrong credentials" do
11
+ it "shouldn't work"
12
+ end
13
+
14
+ before do
15
+ #::Bezebe::CVS.stub!(:puts)
16
+ #::Bezebe::CVS.stub!(:p)
17
+ #stub!(:puts)
18
+ #stub!(:p)
19
+ @client1 = ::Bezebe::CVS::CVSClient.new
20
+ @client1.connect FactoryGirl.attributes_for(:connection_details)
21
+ end
22
+
23
+ it 'should be able to checkout a single file' do
24
+ a = @client1.checkout "/tmp/", "w3c/test/foo"
25
+ end
26
+
27
+ it 'should be able to checkout two files' do
28
+ b = @client1.checkout "/tmp/", [ "w3c/test/foo", "w3c/test/bar" ]
29
+ end
30
+
31
+ it 'should have issues to checkout a known file and an unkown one' do
32
+ b = @client1.checkout "/tmp/", [ "w3c/test/foo", "w3c/test/somethingthatisnotthere" ]
33
+ end
34
+
35
+ it 'should have issues to checkout a known file and an wrong module one' do
36
+ b = @client1.checkout "/tmp/", [ "w3c/test/foo", "somefakeroot/w3c/test/somethingthatisnotthere" ]
37
+ end
38
+
39
+ it 'should have issues to checkout a known file and an unkown one (again)' do
40
+ b = @client1.checkout "/tmp/", [ "w3c/test/foo", "/w3c/test/somethingthatisnotthere" ]
41
+ end
42
+
43
+ it 'should have issues to checkout a known file and an wrong module one (again)' do
44
+ b = @client1.checkout "/tmp/", [ "w3c/test/foo", "/somefakeroot/w3c/test/somethingthatisnotthere" ]
45
+ end
46
+
47
+ it 'should be fast getting a folder' do
48
+ 1.times do
49
+ FileUtils.rm_rf "/tmp/w3c/";
50
+ @client1.checkout "/tmp/", "w3c"
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bezebe::CVS::CVSClient do
4
+
5
+ it { should respond_to(:connect) }
6
+
7
+ describe "#connect" do
8
+
9
+ before :all do
10
+ #::Bezebe::CVS.stub!(:puts)
11
+ #::Bezebe::CVS.stub!(:p)
12
+ #stub!(:puts)
13
+ #stub!(:p)
14
+ end
15
+
16
+ context "regarding parameters" do
17
+ it "supports a hash" do
18
+ client = ::Bezebe::CVS::CVSClient.new
19
+ expect { client.connect @connection_details }.to_not raise_error (ArgumentError)
20
+ end
21
+
22
+ it "supports separate arguments" do
23
+ client = ::Bezebe::CVS::CVSClient.new
24
+ connection_details = FactoryGirl.build(:connection_details)
25
+ expect { client.connect connection_details.username,
26
+ connection_details.password,
27
+ connection_details.host,
28
+ connection_details.repository,
29
+ connection_details.port }.to_not raise_error (ArgumentError)
30
+ end
31
+ it "supports separate arguments with a default port" do
32
+ client = ::Bezebe::CVS::CVSClient.new
33
+ connection_details = FactoryGirl.build(:connection_details)
34
+ expect { client.connect connection_details.username,
35
+ connection_details.password,
36
+ connection_details.host,
37
+ connection_details.repository }.to_not raise_error (ArgumentError)
38
+ end
39
+ end
40
+
41
+ context "when using correct credentials" do
42
+ before :each do
43
+ @client1 = ::Bezebe::CVS::CVSClient.new
44
+ @result = @client1.connect FactoryGirl.attributes_for(:connection_details)
45
+ end
46
+
47
+ it "establishes a connection" do
48
+ @result.should be_true
49
+ end
50
+
51
+ describe "and the connection" do
52
+ it "is open" do
53
+ is_open = @client1.is_open?
54
+ is_open.should be_true
55
+ end
56
+ end
57
+
58
+ context "and when another connection is created" do
59
+ before :each do
60
+ @client2 = ::Bezebe::CVS::CVSClient.new
61
+ @result2 = @client2.connect FactoryGirl.attributes_for(:connection_details)
62
+ end
63
+
64
+ it "remains open and the new one is open as well" do
65
+ @client1.is_open?.should be_true
66
+ @client2.is_open?.should be_true
67
+ end
68
+ end
69
+
70
+ context "and when another connection fails to be created" do
71
+ before :each do
72
+ @client2 = ::Bezebe::CVS::CVSClient.new
73
+ @result2 = @client2.connect FactoryGirl.attributes_for(:connection_details, password: "wrongpassword")
74
+ end
75
+
76
+ it "remains opened while the new one doesn't" do
77
+ @client1.is_open?.should be_true
78
+ @client2.is_open?.should be_false
79
+ end
80
+ end
81
+ end
82
+
83
+ context "when using wrong credentials" do
84
+ before :each do
85
+ @client1 = ::Bezebe::CVS::CVSClient.new
86
+ @result = @client1.connect FactoryGirl.attributes_for(:connection_details, password: "wrongpassword")
87
+ end
88
+
89
+ it "doesn't establish a connection" do
90
+ @result.should be_false
91
+ end
92
+
93
+ it "correctly reports the error as an authentication error" do
94
+ @client1.last_error.should_not be_nil
95
+ @client1.last_error.should match /AUTHENTICATION/
96
+ end
97
+ end
98
+
99
+ context "when using wrong hostname" do
100
+ before :each do
101
+ @client1 = ::Bezebe::CVS::CVSClient.new
102
+ @result = @client1.connect FactoryGirl.attributes_for(:connection_details, host: "wrongdev.w3.org")
103
+ end
104
+
105
+ it "doesn't establish a connection" do
106
+ @result.should be_false
107
+ end
108
+
109
+ it "correctly reports the error as a configuration error" do
110
+ @client1.last_error.should_not be_nil
111
+ @client1.last_error.should match /CONFIGURATION/
112
+ end
113
+ end
114
+
115
+ end
116
+
117
+ end
data/spec/factories.rb ADDED
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :connection_details do
4
+ username "anonymous"
5
+ password "anonymous"
6
+ host "dev.w3.org"
7
+ repository "/sources/public"
8
+ end
9
+
10
+ end
data/spec/log_spec.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bezebe::CVS do
4
+ describe "when using a known repository (W3)" do
5
+
6
+ describe "with correct credentials" do
7
+ it "should work"
8
+ end
9
+
10
+ describe "with wrong credentials" do
11
+ it "shouldn't work"
12
+ end
13
+
14
+ before do
15
+ #::Bezebe::CVS.stub!(:puts)
16
+ #::Bezebe::CVS.stub!(:p)
17
+ #stub!(:puts)
18
+ #stub!(:p)
19
+ @client1 = ::Bezebe::CVS::CVSClient.new
20
+ @client1.connect FactoryGirl.attributes_for(:connection_details)
21
+ end
22
+
23
+ it 'should be able to get information from two known files' do
24
+ log = @client1.log "/tmp/w3c/test/", [ "/tmp/w3c/test/foo",
25
+ "/tmp/w3c/test/bar",
26
+ "/tmp/w3c/test/blah" ]
27
+
28
+ puts log.logInfo.to_yaml unless log.nil?
29
+ end
30
+
31
+ it 'should be able to get information from a known file' do
32
+ log = @client1.log "/tmp/w3c/test/", "/tmp/w3c/test/foo"
33
+
34
+ puts log.logInfo.to_yaml
35
+ puts "\nInformation from HEAD release\n"
36
+ puts log.logInfo.revisions.to_yaml
37
+ unless log.logInfo.symbolicNames.nil? or log.logInfo.symbolicNames.empty? then
38
+ puts "\nInformation from symbolic names\n"
39
+ names = log.logInfo.symbolicNames
40
+ names.each do |k, name|
41
+ puts "- NAME: #{name.name} FOR REVISION: #{name.revision} BRANCH?: #{name.isBranch?}"
42
+ end
43
+ puts "\n\n"
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
data/spec/rlog_spec.rb ADDED
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bezebe::CVS do
4
+ describe "when using a known repository (W3)" do
5
+
6
+ describe "with correct credentials" do
7
+ it "should work"
8
+ end
9
+
10
+ describe "with wrong credentials" do
11
+ it "shouldn't work"
12
+ end
13
+
14
+ before do
15
+ #::Bezebe::CVS.stub!(:puts)
16
+ #::Bezebe::CVS.stub!(:p)
17
+ stub!(:puts)
18
+ #stub!(:p)
19
+ @client1 = ::Bezebe::CVS::CVSClient.new
20
+ @client1.connect FactoryGirl.attributes_for(:connection_details)
21
+ end
22
+
23
+ it 'should be able to get information from a known file' do
24
+ rlog = @client1.rlog "w3c/test/foo"
25
+
26
+ puts rlog.logInfo.to_yaml
27
+ puts "\nInformation from HEAD release\n"
28
+ puts rlog.logInfo.revisions.to_yaml
29
+ unless rlog.logInfo.symbolicNames.nil? or rlog.logInfo.symbolicNames.empty? then
30
+ puts "\nInformation from symbolic names\n"
31
+ names = rlog.logInfo.symbolicNames
32
+ names.each do |k, name|
33
+ puts "- NAME: #{name.name} FOR REVISION: #{name.revision} BRANCH?: #{name.isBranch?}"
34
+ end
35
+ puts "\n\n"
36
+ end
37
+ end
38
+
39
+ it 'should be able to get information from two files' do
40
+ a = [ "w3c/test/foo", "w3c/test/bar" ]
41
+ rlog = @client1.rlog a
42
+
43
+ puts rlog.logInfo.to_yaml
44
+ puts "\nInformation from HEAD release\n"
45
+ puts rlog.logInfo.revisions.to_yaml
46
+ unless rlog.logInfo.symbolicNames.nil? or rlog.logInfo.symbolicNames.empty? then
47
+ puts "\nInformation from symbolic names\n"
48
+ names = rlog.logInfo.symbolicNames
49
+ names.each do |k, name|
50
+ puts "- NAME: #{name.name} FOR REVISION: #{name.revision} BRANCH?: #{name.isBranch?}"
51
+ end
52
+ puts "\n\n"
53
+ end
54
+ end
55
+
56
+ it 'should be able to get information from a known folder' do
57
+ rlog = @client1.rlog "w3c/test"
58
+
59
+ puts rlog.logInfo.to_yaml
60
+ puts "\nInformation from HEAD release\n"
61
+ puts rlog.logInfo.revisions.to_yaml
62
+ unless rlog.logInfo.symbolicNames.nil? or rlog.logInfo.symbolicNames.empty? then
63
+ puts "\nInformation from symbolic names\n"
64
+ names = rlog.logInfo.symbolicNames
65
+ names.each do |k, name|
66
+ puts "- NAME: #{name.name} FOR REVISION: #{name.revision} BRANCH?: #{name.isBranch?}"
67
+ end
68
+ puts "\n\n"
69
+ end
70
+ end
71
+
72
+ it 'should be able to get information from two known folders' do
73
+ rlog = @client1.rlog [ "w3c/test", "issues" ]
74
+
75
+ puts rlog.logInfo.to_yaml
76
+ puts "\nInformation from HEAD release\n"
77
+ puts rlog.logInfo.revisions.to_yaml
78
+ unless rlog.logInfo.symbolicNames.nil? or rlog.logInfo.symbolicNames.empty? then
79
+ puts "\nInformation from symbolic names\n"
80
+ names = rlog.logInfo.symbolicNames
81
+ names.each do |k, name|
82
+ puts "- NAME: #{name.name} FOR REVISION: #{name.revision} BRANCH?: #{name.isBranch?}"
83
+ end
84
+ puts "\n\n"
85
+ end
86
+ end
87
+
88
+ it 'should not be able to get information from an unknown file' do
89
+ @client1.rlog "w3c/test/this_doesnt_exist"
90
+ end
91
+ end
92
+
93
+ it 'should not connect if credentials are wrong'
94
+
95
+ it 'should be able to perform a rlog'
96
+
97
+ describe "when using rlog" do
98
+ it "should do something else"
99
+ end
100
+
101
+
102
+ describe "with proper credentials" do
103
+ it "should work"
104
+
105
+ it "should fail"
106
+ end
107
+
108
+ end
@@ -0,0 +1,13 @@
1
+ require 'rspec'
2
+ require 'factory_girl'
3
+
4
+ require 'bezebe-cvs'
5
+
6
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
+
8
+ RSpec.configure do |config|
9
+ config.color_enabled = true
10
+ config.formatter = 'documentation' if config.formatters.nil? || config.formatters.empty?
11
+ end
12
+
13
+ FactoryGirl.find_definitions
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bezebe::CVS do
4
+ describe "when using a known repository (W3)" do
5
+
6
+ describe "with correct credentials" do
7
+ it "should work"
8
+ end
9
+
10
+ describe "with wrong credentials" do
11
+ it "shouldn't work"
12
+ end
13
+
14
+ before do
15
+ #::Bezebe::CVS.stub!(:puts)
16
+ #::Bezebe::CVS.stub!(:p)
17
+ #stub!(:puts)
18
+ #stub!(:p)
19
+ @client1 = ::Bezebe::CVS::CVSClient.new
20
+ @client1.connect FactoryGirl.attributes_for(:connection_details)
21
+ end
22
+
23
+ it 'should be able to get information from a known file' do
24
+ status = @client1.status "/tmp/w3c/test/", "/tmp/w3c/test/foo"
25
+ puts status.logInfo.to_yaml unless status.nil?
26
+ end
27
+
28
+ it 'should be able to get information from two known files' do
29
+ status = @client1.status "/tmp/w3c/test/", [ "/tmp/w3c/test/foo", "/tmp/w3c/test/bar" ]
30
+ puts status.logInfo.to_yaml unless status.nil?
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -0,0 +1,3 @@
1
+ class ConnectionDetails
2
+ attr_accessor :username, :password, :host, :repository, :port
3
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Bezebe::CVS do
4
+ describe "when using a known repository (W3)" do
5
+
6
+ describe "with correct credentials" do
7
+ it "should work"
8
+ end
9
+
10
+ describe "with wrong credentials" do
11
+ it "shouldn't work"
12
+ end
13
+
14
+ before do
15
+ #::Bezebe::CVS.stub!(:puts)
16
+ #::Bezebe::CVS.stub!(:p)
17
+ #stub!(:puts)
18
+ #stub!(:p)
19
+ @client1 = ::Bezebe::CVS::CVSClient.new
20
+ @client1.connect FactoryGirl.attributes_for(:connection_details)
21
+ end
22
+
23
+ it 'should be able to get information from a known file' do
24
+ status = @client1.update "/tmp/w3c/test/foo"
25
+ puts status.logInfo.to_yaml unless status.nil?
26
+ end
27
+
28
+ it 'should be able to get information from two known files' do
29
+ status = @client1.update [ "/tmp/w3c/test/foo", "/tmp/w3c/test/bar" ]
30
+ puts status.logInfo.to_yaml unless status.nil?
31
+ end
32
+
33
+ end
34
+
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bezebe-cvs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-19 00:00:00.000000000 Z
12
+ date: 2012-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rjb
16
- requirement: &70365153988860 !ruby/object:Gem::Requirement
16
+ requirement: &70338856630240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70365153988860
24
+ version_requirements: *70338856630240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &70365153988200 !ruby/object:Gem::Requirement
27
+ requirement: &70338856629460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70365153988200
35
+ version_requirements: *70338856629460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70365153987660 !ruby/object:Gem::Requirement
38
+ requirement: &70338856628860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,29 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70365153987660
46
+ version_requirements: *70338856628860
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70338856627840 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70338856627840
58
+ - !ruby/object:Gem::Dependency
59
+ name: factory_girl
60
+ requirement: &70338856597420 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70338856597420
47
69
  description: a set of tools for the bussy bee - CVS
48
70
  email:
49
71
  - tnarik@gmail.com
@@ -52,18 +74,31 @@ extensions: []
52
74
  extra_rdoc_files: []
53
75
  files:
54
76
  - .gitignore
77
+ - .rvmrc
55
78
  - Gemfile
56
79
  - LICENSE
80
+ - README.md
57
81
  - bezebe-cvs.gemspec
58
82
  - lib/bezebe-cvs.rb
83
+ - lib/bezebe-cvs/cvs_client.rb
59
84
  - lib/bezebe-cvs/cvslistener.rb
60
- - lib/bezebe-cvs/loginfo.rb
85
+ - lib/bezebe-cvs/log_info.rb
61
86
  - lib/bezebe-cvs/revision.rb
87
+ - lib/bezebe-cvs/sym_name.rb
62
88
  - lib/bezebe-cvs/version.rb
63
89
  - lib/vendor/LICENSE_NETBEANS
64
90
  - lib/vendor/org-netbeans-lib-cvsclient.jar
91
+ - spec/checkout_spec.rb
92
+ - spec/connect_spec.rb
93
+ - spec/factories.rb
94
+ - spec/log_spec.rb
95
+ - spec/rlog_spec.rb
96
+ - spec/spec_helper.rb
97
+ - spec/status_spec.rb
98
+ - spec/support/models.rb
99
+ - spec/update_spec.rb
65
100
  - tasks/gem.thor
66
- homepage: http://tnarik.net/stuff/bezebe-cvs
101
+ homepage: http://github.com/tnarik/bezebe-cvs
67
102
  licenses:
68
103
  - MIT
69
104
  post_install_message:
@@ -78,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
113
  version: '0'
79
114
  segments:
80
115
  - 0
81
- hash: -1399969174001429062
116
+ hash: 3059795657089288219
82
117
  required_rubygems_version: !ruby/object:Gem::Requirement
83
118
  none: false
84
119
  requirements:
@@ -87,11 +122,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
122
  version: '0'
88
123
  segments:
89
124
  - 0
90
- hash: -1399969174001429062
125
+ hash: 3059795657089288219
91
126
  requirements: []
92
127
  rubyforge_project: bezebe
93
128
  rubygems_version: 1.8.17
94
129
  signing_key:
95
130
  specification_version: 3
96
131
  summary: bussy bee CVS
97
- test_files: []
132
+ test_files:
133
+ - spec/checkout_spec.rb
134
+ - spec/connect_spec.rb
135
+ - spec/factories.rb
136
+ - spec/log_spec.rb
137
+ - spec/rlog_spec.rb
138
+ - spec/spec_helper.rb
139
+ - spec/status_spec.rb
140
+ - spec/support/models.rb
141
+ - spec/update_spec.rb
@@ -1,19 +0,0 @@
1
- module Bezebe
2
- module CVS
3
- class LogInfo
4
- attr_accessor :headRevision, :totalRevisions, :description, :repositoryFilename, :file
5
-
6
- def initialize(logInformation = nil)
7
- if logInformation.kind_of? Rjb::Rjb_JavaProxy then
8
- if logInformation._classname == "org.netbeans.lib.cvsclient.command.log.LogInformation" then
9
- @headRevision = logInformation.getHeadRevision
10
- @totalRevisions = logInformation.getTotalRevisions
11
- @description = logInformation.getDescription
12
- @repositoryFilename = logInformation.getRepositoryFilename
13
- @file = logInformation.getFile
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end