xforge 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,14 @@
1
1
  = XForge Changelog
2
2
 
3
+ == Version 0.1.6
4
+
5
+ This release of XForge improves scm browser capabilities.
6
+
7
+ * Added ViewCvs.uri(path, options) method to get an URI to a file on the web
8
+ * Added an rspec suite
9
+ * Added logic for parsing top-level CVS modules
10
+ * Made Rake Release task use RubyForge by default
11
+
3
12
  == Version 0.1.5
4
13
 
5
14
  This release of XForge adds functionality to access scm browsers (ViewCvs) and RSCM objects.
data/Rakefile CHANGED
@@ -15,8 +15,16 @@ require 'rake/clean'
15
15
  require 'rake/testtask'
16
16
  require 'rake/rdoctask'
17
17
 
18
+ # Versioning scheme: MAJOR.MINOR.PATCH
19
+ # MAJOR bumps when API is broken backwards
20
+ # MINOR bumps when the API is broken backwards in a very slight/subtle (but not fatal) way
21
+ # -OR when a new release is made and propaganda is sent out.
22
+ # PATCH is bumped for every API addition and/or bugfix (ideally for every commit)
23
+ # Later DamageControl can bump PATCH automatically.
24
+ #
25
+ # REMEMBER TO KEEP PKG_VERSION IN SYNC WITH CHANGELOG
18
26
  PKG_NAME = "xforge"
19
- PKG_VERSION = "0.1.5"
27
+ PKG_VERSION = "0.1.6"
20
28
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
21
29
  PKG_FILES = FileList[
22
30
  '[A-Z]*',
@@ -5,9 +5,9 @@ module Rake
5
5
  class Base
6
6
  attr_writer :user_name, :password
7
7
 
8
- def initialize(project_name, xforge_host="rubyforge.org")
8
+ def initialize(project_name, host=::XForge::RubyForge.new)
9
9
  @project_name = project_name
10
- @host = ::XForge::Host.new(xforge_host)
10
+ @host = host
11
11
 
12
12
  set_defaults
13
13
 
@@ -1,24 +1,48 @@
1
1
  module ScmWeb
2
+ # TODO: implement RSCM API via HTTP ala CVSGrab
2
3
  class ViewCvs
3
4
 
4
- attr_reader :uri, :project
5
+ attr_reader :project
5
6
 
6
- def initialize(uri, project)
7
- @uri, @project = uri, project
7
+ def initialize(uri_specs, project, module_regexp)
8
+ @uri_specs, @project, @module_regexp = uri_specs, project, module_regexp
8
9
  end
9
10
 
10
11
  def scms
11
12
  unless(@scms)
12
13
  require 'rscm'
13
- cvs_root = open(uri) { |data| data.read }
14
14
 
15
15
  @scms = []
16
- scm = RSCM::Cvs.new
17
- scm.root = ":pserver:anonymous@#{project.host.cvs_host_name}:#{project.host.cvs_path}/#{project.name}"
18
- scm.mod = project.name
19
- @scms << scm
16
+ cvs_root = open(uri) do |data|
17
+ data.each_line do |line|
18
+ if line =~ @module_regexp
19
+ mod = $1
20
+ unless(mod == "CVSROOT")
21
+ scm = RSCM::Cvs.new
22
+ scm.root = ":pserver:anonymous@#{project.host.cvs_host_name}:#{project.host.cvs_path}/#{mod}"
23
+ scm.mod = project.name
24
+ @scms << scm
25
+ end
26
+ end
27
+ end
28
+ end
20
29
  end
21
30
  @scms
22
31
  end
32
+
33
+ # Returns the URI for the file at +path+.
34
+ # Options are:
35
+ # :type (can be one of :overview, :raw or :html)
36
+ # :revision (the revision of the file. must be specified when :type is :raw or :html)
37
+ def uri(path="", options={:type=>:overview})
38
+ type = options[:type]
39
+ raise "No :type specified" unless type
40
+ uri_spec = @uri_specs[type]
41
+ raise "No uri_spec for #{type}" unless uri_spec
42
+
43
+ project_name = project.name
44
+ revision = options[:revision]
45
+ eval("\"#{uri_spec}\"", binding)
46
+ end
23
47
  end
24
48
  end
@@ -1,4 +1,5 @@
1
1
  require 'net/http'
2
+ require 'net/https'
2
3
  require 'open-uri'
3
4
 
4
5
  module XForge
@@ -15,7 +16,17 @@ module XForge
15
16
 
16
17
  # Logs in and returns a Session
17
18
  def login(user_name, password)
18
- login_response = Net::HTTP.start(@host.name, 80) do |http|
19
+ http = Net::HTTP.new(@host.name, host.login_port)
20
+
21
+ # http://www.ruby-lang.org/ja/man/index.cgi?cmd=view;name=net%2Fhttps.rb
22
+ if(host.login_port == 443)
23
+ http.use_ssl = true
24
+ http.ca_file = '/usr/share/ssl/cert.pem'
25
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
26
+ http.verify_depth = 5
27
+ end
28
+
29
+ login_response = http.start do |http|
19
30
  data = [
20
31
  "login=1",
21
32
  "form_loginname=#{user_name}",
@@ -1,8 +1,20 @@
1
1
  module XForge
2
2
  class RubyForge < Host
3
+ VIEW_CVS = "http://rubyforge.org/cgi-bin/viewcvs.cgi/"
4
+ PATH_CVSROOT = "\#{path}?cvsroot=\#{project_name}"
5
+ PATH_CVSROOT_REV = "#{PATH_CVSROOT}&rev=\#{revision}"
6
+
7
+ OVERVIEW = "#{VIEW_CVS}#{PATH_CVSROOT}"
8
+ RAW = "#{VIEW_CVS}*checkout*/#{PATH_CVSROOT_REV}"
9
+ HTML = "#{VIEW_CVS}#{PATH_CVSROOT_REV}&content-type=text/vnd.viewcvs-markup"
10
+
3
11
  def initialize
4
12
  super('rubyforge.org')
5
13
  end
14
+
15
+ def login_port
16
+ 80
17
+ end
6
18
 
7
19
  def cvs_path
8
20
  "/var/cvs"
@@ -13,8 +25,9 @@ module XForge
13
25
  end
14
26
 
15
27
  def scm_web(project)
16
- ::ScmWeb::ViewCvs.new("http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=#{project.name}", project)
28
+ module_regexp = /href=\"(\w+)\/\?cvsroot=#{project.name}/
29
+ ::ScmWeb::ViewCvs.new({:overview => OVERVIEW, :raw => RAW, :html => HTML}, project, module_regexp)
17
30
  end
18
31
 
19
32
  end
20
- end
33
+ end
@@ -1,10 +1,21 @@
1
1
  module XForge
2
-
3
2
  class SourceForge < Host
3
+ VIEW_CVS = "http://cvs.sourceforge.net/viewcvs.py/"
4
+ PROJECT_PATH = "\#{project_name}/\#{path}"
5
+ REV = "rev=\#{revision}"
6
+
7
+ OVERVIEW = "#{VIEW_CVS}#{PROJECT_PATH}"
8
+ RAW = "#{VIEW_CVS}*checkout*/#{PROJECT_PATH}?#{REV}"
9
+ HTML = "#{OVERVIEW}?#{REV}&view=markup"
10
+
4
11
  def initialize
5
12
  super("sourceforge.net")
6
13
  end
7
14
 
15
+ def login_port
16
+ 443
17
+ end
18
+
8
19
  def cvs_path
9
20
  "/cvsroot"
10
21
  end
@@ -14,9 +25,9 @@ module XForge
14
25
  end
15
26
 
16
27
  def scm_web(project)
17
- ::ScmWeb::ViewCvs.new("http://#{cvs_host_name}/viewcvs.py/#{project.name}/", project)
28
+ module_regexp = /viewcvs\.py\/#{project.name}\/(\w+)\//
29
+ ::ScmWeb::ViewCvs.new({:overview => OVERVIEW, :raw => RAW, :html => HTML}, project, module_regexp)
18
30
  end
19
31
 
20
32
  end
21
-
22
33
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.8
3
3
  specification_version: 1
4
4
  name: xforge
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.5
7
- date: 2005-08-12
6
+ version: 0.1.6
7
+ date: 2005-08-13
8
8
  summary: Ruby based make-like utility.
9
9
  require_paths:
10
10
  - lib