rsvn 0.0.1

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.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .ruby-version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rsvn.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012, Brian D. Nelson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,80 @@
1
+ # Rsvn
2
+
3
+ ## Description
4
+ Gem to provide basic access to Subversion information (wraps Ruby SVN bindings).
5
+ It assumes standard Subversion usage is in effect (i.e. branches, tags, trunk) and
6
+ only interacts with the repository in a read-only manner. The gem was written
7
+ to be used with Ruby on Rails, but can be used whereever it is needed.
8
+
9
+ ## Why?
10
+ I ran into this need a couple of times while working with deployment and build
11
+ scripts and decided to roll the functionality up into a gem for easier use.
12
+
13
+ ## Requirements
14
+ This gem depends on the SVN ruby bindings being installed.
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'rsvn'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install rsvn
29
+
30
+ ## Configuration
31
+
32
+ The gem takes a minimial configuration. Simply specify the authentication type
33
+ (and supporting information) to be used for the connection:
34
+ * `:anonymous` - no authentication information will be passed
35
+ * `:basic` - username and password is required
36
+
37
+ In a Rails application, you should create an initializer for your Subversion
38
+ connection information (`config/initializers/rsvn.rb`).
39
+
40
+ ### Anonymous Connection
41
+ ```ruby
42
+ # No additional information is required.
43
+ Rsvn::Config.authentication_method = :anonymous
44
+ ```
45
+
46
+ ### Basic Authentication Connection
47
+ ```ruby
48
+ # Username and password are required
49
+ Rsvn::Config.authentication_method = :basic
50
+ Rsvn::Config.username = 'username'
51
+ Rsvn::Config.password = 'password'
52
+ ```
53
+
54
+ ## Usage
55
+
56
+ ### Get Branches List
57
+
58
+ ```ruby
59
+ # Get branches list
60
+ branches = Rsvn.branches("http://svn.apache.org/repos/asf/subversion")
61
+ ```
62
+
63
+ ### Get Tags List
64
+
65
+ ```ruby
66
+ # Get tags list
67
+ tags = Rsvn.tags("http://svn.apache.org/repos/asf/subversion")
68
+ ```
69
+
70
+ ## Contributing
71
+
72
+ 1. Fork it
73
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
74
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
75
+ 4. Push to the branch (`git push origin my-new-feature`)
76
+ 5. Create new Pull Request
77
+
78
+ ## Links
79
+
80
+
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "yard/rake/yardoc_task"
4
+
5
+ Rake::TestTask.new {|t| t.libs << 'test'}
6
+
7
+ YARD::Rake::YardocTask.new
@@ -0,0 +1,44 @@
1
+ require "svn/core"
2
+ require "svn/client"
3
+
4
+ require "rsvn/version"
5
+ require "rsvn/config"
6
+
7
+ require "rsvn/version_object"
8
+ require "rsvn/branch"
9
+ require "rsvn/tag"
10
+
11
+ module Rsvn
12
+ def self.get_context
13
+ context = Svn::Client::Context.new()
14
+ context.add_simple_provider
15
+
16
+ if Rsvn::Config.authentication_method == :basic
17
+ context.auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_USERNAME] = Rsvn::Config.username
18
+ context.auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_PASSWORD] = Rsvn::Config.password
19
+ end
20
+
21
+ return context
22
+ end
23
+
24
+ def self.branches(uri)
25
+ branches = Rsvn.get_context.
26
+ ls("#{uri}/branches").
27
+ first.
28
+ map {|x,y| x if y.directory?}.
29
+ compact.
30
+ sort {|x,y| x <=> y} rescue []
31
+
32
+ branches.map {|x| Rsvn::Branch.new(x, uri)}
33
+ end
34
+
35
+ def self.tags(uri)
36
+ tags = Rsvn.get_context.
37
+ ls("#{uri}/tags").
38
+ first.
39
+ map {|x,y| x if y.directory?}.
40
+ compact.
41
+ sort {|x,y| x <=> y} rescue []
42
+ tags.map {|x| Rsvn::Tag.new(x, uri)}
43
+ end
44
+ end
@@ -0,0 +1,4 @@
1
+ module Rsvn
2
+ class Branch < Rsvn::VersionObject
3
+ end
4
+ end
@@ -0,0 +1,31 @@
1
+ module Rsvn
2
+ module Config
3
+ @authentication_method = :anonymous
4
+ @username = nil
5
+ @password = nil
6
+
7
+ def self.authentication_method
8
+ @authentication_method
9
+ end
10
+
11
+ def self.authentication_method=(m)
12
+ @authentication_method = m
13
+ end
14
+
15
+ def self.username
16
+ @username
17
+ end
18
+
19
+ def self.username=(u)
20
+ @username = u
21
+ end
22
+
23
+ def self.password
24
+ @password
25
+ end
26
+
27
+ def self.password=(p)
28
+ @password = p
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ module Rsvn
2
+ class Tag < Rsvn::VersionObject
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Rsvn
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ module Rsvn
2
+ class VersionObject
3
+ attr_reader :base_url, :name
4
+
5
+ def initialize(name, base_url)
6
+ @name = name
7
+ @base_url
8
+ end
9
+
10
+ def url
11
+ "#{@base_url}/branches/#{@name}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rsvn/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rsvn"
8
+ gem.version = Rsvn::VERSION
9
+ gem.authors = ["Brian D. Nelson"]
10
+ gem.email = ["bdnelson@bdnsolutions.com"]
11
+ gem.description = %q{Gem to provide basic access to Subversion information (wraps Ruby SVN bindings).}
12
+ gem.summary = %q{Gem to provide basic access to Subversion information (wraps Ruby SVN bindings).}
13
+ gem.homepage = "https://github.com/bdnelson/rsvn"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,10 @@
1
+ require 'test/unit'
2
+ require 'rsvn'
3
+
4
+ class RsvnTest < Test::Unit::TestCase
5
+
6
+ def test_got_branches
7
+ @branches = Rsvn.branches("http://svn.apache.org/repos/asf/subversion")
8
+ assert !@branches.empty?
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+ require 'rsvn'
3
+
4
+ class RsvnTest < Test::Unit::TestCase
5
+ def test_got_tags
6
+ @tags = Rsvn.tags("http://svn.apache.org/repos/asf/subversion")
7
+ assert !@tags.empty?
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rsvn
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Brian D. Nelson
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-01-21 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Gem to provide basic access to Subversion information (wraps Ruby SVN bindings).
23
+ email:
24
+ - bdnelson@bdnsolutions.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE.txt
35
+ - README.md
36
+ - Rakefile
37
+ - lib/rsvn.rb
38
+ - lib/rsvn/branch.rb
39
+ - lib/rsvn/config.rb
40
+ - lib/rsvn/tag.rb
41
+ - lib/rsvn/version.rb
42
+ - lib/rsvn/version_object.rb
43
+ - rsvn.gemspec
44
+ - test/test_branches.rb
45
+ - test/test_tags.rb
46
+ has_rdoc: true
47
+ homepage: https://github.com/bdnelson/rsvn
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ requirements: []
74
+
75
+ rubyforge_project:
76
+ rubygems_version: 1.6.2
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Gem to provide basic access to Subversion information (wraps Ruby SVN bindings).
80
+ test_files:
81
+ - test/test_branches.rb
82
+ - test/test_tags.rb