svn-downloader 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e92aeff9d51d03c41634ec25af24807d11909272
4
+ data.tar.gz: 49cb36a804bbec912c8d5ed5dceb6821479f60d7
5
+ SHA512:
6
+ metadata.gz: 904546447a0af8398b135346174a23834f769f17a72d740532c3be5e03d1540c0e1c66ebb79614bea86744f3043fdd7ed6a1dad0dc1a82ba868b6573ab067cd8
7
+ data.tar.gz: 3376e1e4f1ba3fc9b9ea18397448e525ffe28eccf61be9a4ecbb96245bae0bc2bffca4e94a702a3f3d985c8847c5daf1ef0bb6eef9c0f03deb233487e14e53bf
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - rbx-19mode
6
+ - ruby-head
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in svn-downloader.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # SVN::Downloader
2
+
3
+ SVN::Downloader is a library for downloading remote SVN repositories
4
+
5
+ SVN repositories can be downloaded over HTTP protocol, but SVN protocol isn't implemented yet.
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'svn-downloader'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install svn-downloader
21
+
22
+ ### Dependencies
23
+
24
+ gems:
25
+
26
+ * `net_dav` (required)
27
+
28
+
29
+ ## Usage
30
+
31
+ ```ruby
32
+ require 'svn/downloader'
33
+
34
+ SVN::Downloader.download('http://svn.example.com/repo/', './local_path/')
35
+ ```
36
+
37
+
38
+ ## Code status
39
+
40
+ [![Build Status](https://travis-ci.org/davispuh/SVN-Downloader.png?branch=master)](https://travis-ci.org/davispuh/SVN-Downloader)
41
+ [![Dependency Status](https://gemnasium.com/davispuh/SVN-Downloader.png)](https://gemnasium.com/davispuh/SVN-Downloader)
42
+ [![Code Climate](https://codeclimate.com/github/davispuh/SVN-Downloader.png)](https://codeclimate.com/github/davispuh/SVN-Downloader)
43
+
44
+ ## Unlicense
45
+
46
+ ![Copyright-Free](http://unlicense.org/pd-icon.png)
47
+
48
+ All text, documentation, code and files in this repository are in public domain (including this text, README).
49
+
50
+ It means you can copy, modify, distribute and include in your own work/code, even for commercial purposes, all without asking permission.
51
+
52
+ [About Unlicense](http://unlicense.org/)
53
+
54
+ ## Contributing
55
+
56
+ Feel free to improve anything.
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
63
+
64
+
65
+ **Warning**: By sending pull request to this repository you dedicate any and all copyright interest in pull request (code files and all other) to the public domain. (files will be in public domain even if pull request doesn't get merged)
66
+
67
+ Also before sending pull request you acknowledge that you own all copyrights or have authorization to dedicate them to public domain.
68
+
69
+ If you don't want to dedicate code to public domain or if you're not allowed to (eg. you don't own required copyrights) then DON'T send pull request.
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'yard'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc 'Run specs'
9
+ RSpec::Core::RakeTask.new(:spec) do |t|
10
+ end
11
+
12
+ YARD::Rake::YardocTask.new(:doc) do |t|
13
+ end
data/UNLICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,86 @@
1
+ require 'svn/downloader/version'
2
+ require 'net/dav'
3
+ require 'uri'
4
+
5
+ # SVN module for SVN related functionality
6
+ module SVN
7
+ # Downloader module for SVN repository downloading
8
+ module Downloader
9
+ # XML header
10
+ XML_HEAD = '<?xml version="1.0" encoding="utf-8"?>'
11
+ # WebDAV Namespace
12
+ DAV_NS = 'DAV:'
13
+ # WebDAV SVN Namespace
14
+ SVN_DAV_PROP_NS_DAV = 'http://subversion.tigris.org/xmlns/dav/'
15
+ # XML Namespaces
16
+ NAMESPACES = { 'D' => DAV_NS }
17
+
18
+ protected
19
+
20
+ def self.propfindData(props = [])
21
+ str = XML_HEAD
22
+ str += "<propfind xmlns=\"#{DAV_NS}\">"
23
+ str << '<prop>'
24
+ props.each do |data|
25
+ str << "<#{data.first} xmlns=#{data.last.encode(:xml => :attr)} />"
26
+ end
27
+ str << '</prop>'
28
+ str << '</propfind>'
29
+ str
30
+ end
31
+
32
+ public
33
+
34
+ # download files from remote repository
35
+ # @param [String] url The URL to the remote repository
36
+ # @param [String] path The local path where to save downloaded repository
37
+ def self.download(url, path = './tmp/')
38
+ uri = URI.parse(url)
39
+ case uri.scheme
40
+ when 'http','https'
41
+ fromHTTP(uri, path)
42
+ when 'svn'
43
+ fromSVN(uri, path)
44
+ else
45
+ raise RuntimeError.new('Unrecognized protocol ' + uri.scheme)
46
+ end
47
+ end
48
+
49
+ # download files from remote repository over HTTP protocol
50
+ # @param [String] uri The URI to the remote repository
51
+ # @param [String] path The local path where to save downloaded repository
52
+ def self.fromHTTP(uri, path)
53
+ Net::DAV.start(uri) do |dav|
54
+ downloadFolder(dav, uri.path, path)
55
+ end
56
+ end
57
+
58
+ # download files from remote repository over SVN protocol
59
+ # @param [String] uri The URI to the remote repository
60
+ # @param [String] path The local path where to save downloaded repository
61
+ def self.fromSVN(uri, path)
62
+ # TODO
63
+ raise RuntimeError.new('SVN protocol is not implemented yet')
64
+ end
65
+
66
+ protected
67
+
68
+ def self.downloadFolder(dav, url, path)
69
+ doc = dav.propfind(url, propfindData([['resourcetype', DAV_NS]]))
70
+ doc.xpath('.//D:response', NAMESPACES).each do |item|
71
+ href = item.%('./D:href', NAMESPACES).content
72
+ isFolder = item.%('.//D:collection', NAMESPACES) ? true : false
73
+ location = path + File::SEPARATOR + href.split('/').last
74
+ next if href.chomp('/') == url.chomp('/')
75
+ FileUtils.mkdir_p(path) unless File.exists?(path)
76
+ if isFolder
77
+ downloadFolder(dav, href, location)
78
+ else
79
+ data = dav.get(href)
80
+ File.open(location, 'wb') { |f| f.write(data) }
81
+ puts href
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,6 @@
1
+ module SVN
2
+ module Downloader
3
+ # Version
4
+ VERSION = '0.0.1'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ # encoding: UTF-8
2
+ require 'simplecov'
3
+
4
+ SimpleCov.start
5
+ require_relative '../lib/svn/downloader'
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+
4
+ describe SVN::Downloader do
5
+ describe '.download' do
6
+ it 'should download repository' do
7
+ #SVN::Downloader.download('http://.../', '/tmp/')
8
+ end
9
+
10
+ it 'should raise exception' do
11
+ expect { SVN::Downloader.download('git://test/') }.to raise_error(RuntimeError)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'svn/downloader/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'svn-downloader'
8
+ spec.version = SVN::Downloader::VERSION
9
+ spec.authors = ['Dāvis']
10
+ spec.email = ['davispuh@gmail.com']
11
+ spec.description = 'Simple way to automatically download files from SVN repositories from remote locations'
12
+ spec.summary = 'Library for downloading SVN repositories'
13
+ spec.homepage = 'https://github.com/davispuh/svn-downloader'
14
+ spec.license = 'UNLICENSE'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'net_dav'
22
+
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'yard'
27
+ spec.add_development_dependency 'simplecov'
28
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: svn-downloader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dāvis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net_dav
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Simple way to automatically download files from SVN repositories from
98
+ remote locations
99
+ email:
100
+ - davispuh@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .travis.yml
107
+ - .yardopts
108
+ - Gemfile
109
+ - README.md
110
+ - Rakefile
111
+ - UNLICENSE
112
+ - lib/svn/downloader.rb
113
+ - lib/svn/downloader/version.rb
114
+ - spec/spec_helper.rb
115
+ - spec/svn_downloader_spec.rb
116
+ - svn-downloader.gemspec
117
+ homepage: https://github.com/davispuh/svn-downloader
118
+ licenses:
119
+ - UNLICENSE
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.0.14
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Library for downloading SVN repositories
141
+ test_files:
142
+ - spec/spec_helper.rb
143
+ - spec/svn_downloader_spec.rb
144
+ has_rdoc: