repomen 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +9 -0
- data/lib/repomen.rb +25 -0
- data/lib/repomen/config.rb +54 -0
- data/lib/repomen/repo.rb +8 -0
- data/lib/repomen/repo/handler.rb +9 -0
- data/lib/repomen/repo/handler/base.rb +23 -0
- data/lib/repomen/repo/handler/git.rb +63 -0
- data/lib/repomen/repo/service.rb +23 -0
- data/lib/repomen/repo/service/base.rb +24 -0
- data/lib/repomen/repo/service/bit_bucket.rb +32 -0
- data/lib/repomen/repo/service/git_hub.rb +32 -0
- data/lib/repomen/repo/url.rb +19 -0
- data/lib/repomen/retriever.rb +44 -0
- data/lib/repomen/version.rb +3 -0
- data/repomen.gemspec +26 -0
- data/test/repomen/config_test.rb +23 -0
- data/test/repomen/repo/handler/git_test.rb +48 -0
- data/test/repomen/repo/handler_test.rb +8 -0
- data/test/repomen/repo/service/bit_bucket_test.rb +21 -0
- data/test/repomen/repo/service/git_hub_test.rb +21 -0
- data/test/repomen/repo/service_test.rb +17 -0
- data/test/repomen/retriever_test.rb +23 -0
- data/test/test_helper.rb +12 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 63ac43befeaebea67aa8343a8f243d2ff9b112b6
|
4
|
+
data.tar.gz: 2a2295e0dc6d2da195f433e9f7504021e0c3df04
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55440f797e16409a07b4d36c16a0199ddc6e4d37c1ee3c33fc46ebf3193722bec5421735c49eeac4c841f03d229ca9fa612637307cdff8d4367d9626e55ed256
|
7
|
+
data.tar.gz: 5527d4fde6febe9fb05e7d3c017452606a009da6935711d0582ddd3ce054ee2d66ee202d7778905ae33ce449221102308545bb87cac09494552d69c7b454008f
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
repomen
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 René Föhring
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Repomen
|
2
|
+
|
3
|
+
The Repomen are retrieving repos and can discard them at will.
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'repomen'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install repomen
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
The Repomen are retrieving repos and can discard them at will.
|
26
|
+
|
27
|
+
url = "git@bitbucket.org:atlassian_tutorial/helloworld.git"
|
28
|
+
Repomen.retrieve(url)
|
29
|
+
|
30
|
+
When called with a block, the repo is automatically deleted afterwards
|
31
|
+
|
32
|
+
Repomen.retrieve(url) do |local_path|
|
33
|
+
# repo is cloned in +local_path+
|
34
|
+
end
|
35
|
+
# repo is gone
|
36
|
+
|
37
|
+
You can set the directory where the repos are stored:
|
38
|
+
|
39
|
+
Repomen.config.work_dir = "tmp/"
|
40
|
+
|
41
|
+
The naming scheme for the cloned repos is `service/user/repo`. In the example `https://github.com/rrrene/sparkr.git` would be cloned to `tmp/github/rrrene/sparkr`.
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. [Fork it!](http://github.com/rrrene/repomen/fork)
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
## Author
|
56
|
+
|
57
|
+
René Föhring (@rrrene)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
Repomen is released under the MIT License. See the LICENSE.txt file for further
|
64
|
+
details.
|
data/Rakefile
ADDED
data/lib/repomen.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'repomen/version'
|
2
|
+
|
3
|
+
# The Repomen are retrieving repos and can discard them at will.
|
4
|
+
#
|
5
|
+
# url = "git@bitbucket.org:atlassian_tutorial/helloworld.git"
|
6
|
+
# Repomen.retrieve(url)
|
7
|
+
#
|
8
|
+
# When called with a block, the repo is automatically deleted afterwards
|
9
|
+
#
|
10
|
+
# Repomen.retrieve(url) do |local_path|
|
11
|
+
# # repo is cloned in +local_path+
|
12
|
+
# end
|
13
|
+
# # repo is gone
|
14
|
+
#
|
15
|
+
module Repomen
|
16
|
+
ROOT = File.join(File.dirname(__FILE__), "..")
|
17
|
+
|
18
|
+
def self.retrieve(url, &block)
|
19
|
+
Retriever.new(url, &block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'repomen/config'
|
24
|
+
require 'repomen/retriever'
|
25
|
+
require 'repomen/repo'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Repomen
|
2
|
+
# This module can be included to provide easy access to the global config
|
3
|
+
module WithDefaultConfig
|
4
|
+
# @return [Config] the global config
|
5
|
+
def default_config
|
6
|
+
Repomen.config
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
# @return [Config] the global config
|
12
|
+
def config
|
13
|
+
@config ||= Config.new({}, false)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @param config [Config,Hash]
|
17
|
+
# @return [Config]
|
18
|
+
def Config(config)
|
19
|
+
if config.is_a?(Hash)
|
20
|
+
Config.new(config)
|
21
|
+
else
|
22
|
+
config
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Config
|
28
|
+
include Repomen::WithDefaultConfig
|
29
|
+
|
30
|
+
attr_writer :work_dir
|
31
|
+
attr_accessor :only_last_revision
|
32
|
+
|
33
|
+
# @param options [Hash]
|
34
|
+
# @param merge_options [Boolean]
|
35
|
+
# true if the given options should be merged with the global ones
|
36
|
+
def initialize(options = {}, merge_options = true)
|
37
|
+
options = default_config.to_h.merge(options) if merge_options
|
38
|
+
options.each do |name, value|
|
39
|
+
send("#{name}=", value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def work_dir
|
44
|
+
@work_dir || Dir.pwd
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_h
|
48
|
+
{
|
49
|
+
:work_dir => work_dir,
|
50
|
+
:only_last_revision => only_last_revision
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/repomen/repo.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Repomen
|
2
|
+
module Repo
|
3
|
+
module Handler
|
4
|
+
class Base
|
5
|
+
include WithDefaultConfig
|
6
|
+
|
7
|
+
attr_reader :config
|
8
|
+
attr_reader :path
|
9
|
+
attr_reader :url
|
10
|
+
|
11
|
+
def initialize(url, path, _config = default_config)
|
12
|
+
@url = url
|
13
|
+
@config = Repomen::Config(_config)
|
14
|
+
@path = File.join(config.work_dir, path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def retrieve
|
18
|
+
raise NotImplementedError
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Repomen
|
4
|
+
module Repo
|
5
|
+
module Handler
|
6
|
+
# Handler for git repositories
|
7
|
+
#
|
8
|
+
# @todo Uses git's CLI, since Rugged is not playing nice GitHub
|
9
|
+
# Why is that?
|
10
|
+
class Git < Base
|
11
|
+
# Removes the repo from the filesystem
|
12
|
+
# @return [void]
|
13
|
+
def discard
|
14
|
+
FileUtils.rm_rf(path) if repo_exists?
|
15
|
+
end
|
16
|
+
|
17
|
+
# Retrieves the repo from +@url+
|
18
|
+
# @return [void]
|
19
|
+
def retrieve
|
20
|
+
if repo_exists?
|
21
|
+
update_repo
|
22
|
+
else
|
23
|
+
clone_repo
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def git(*args)
|
30
|
+
`git #{args.join(' ')}`
|
31
|
+
end
|
32
|
+
|
33
|
+
def clone_repo
|
34
|
+
FileUtils.mkdir_p path
|
35
|
+
git :clone, url, path, '--depth=1 --quiet'
|
36
|
+
end
|
37
|
+
|
38
|
+
def git_options
|
39
|
+
options = %w(--quiet)
|
40
|
+
if config.only_last_revision
|
41
|
+
options << '--depth=1'
|
42
|
+
end
|
43
|
+
options.join(' ')
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_repo
|
47
|
+
pull
|
48
|
+
end
|
49
|
+
|
50
|
+
def pull
|
51
|
+
old_dir = Dir.pwd
|
52
|
+
Dir.chdir path
|
53
|
+
git :pull, '--quiet'
|
54
|
+
Dir.chdir old_dir
|
55
|
+
end
|
56
|
+
|
57
|
+
def repo_exists?
|
58
|
+
File.exists?(path) && File.directory?(path)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Repomen
|
2
|
+
module Repo
|
3
|
+
module Service
|
4
|
+
class << self
|
5
|
+
def for(url)
|
6
|
+
services.each do |service_class|
|
7
|
+
s = service_class.new(url)
|
8
|
+
return s if s.applicable?
|
9
|
+
end
|
10
|
+
nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def services
|
14
|
+
[Service::GitHub, Service::BitBucket]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require_relative 'service/base'
|
22
|
+
require_relative 'service/git_hub'
|
23
|
+
require_relative 'service/bit_bucket'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Repomen
|
2
|
+
module Repo
|
3
|
+
module Service
|
4
|
+
class Base
|
5
|
+
SERVICE_REGEXP = //
|
6
|
+
|
7
|
+
attr_reader :url
|
8
|
+
|
9
|
+
# @param url [String]
|
10
|
+
def applicable?
|
11
|
+
url =~ SERVICE_REGEXP
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(url)
|
15
|
+
@url = url
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
self.class.to_s.split("::").last.underscore.to_sym
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Repomen
|
2
|
+
module Repo
|
3
|
+
module Service
|
4
|
+
class BitBucket < Base
|
5
|
+
SERVICE_REGEXP = /(https:\/\/|git\@)bitbucket.org[\:\/]([^\/]+)\/([^\.]+)\.git$/
|
6
|
+
|
7
|
+
# @param url [String]
|
8
|
+
def applicable?
|
9
|
+
url =~ SERVICE_REGEXP
|
10
|
+
end
|
11
|
+
|
12
|
+
def handler_class
|
13
|
+
Handler::Git
|
14
|
+
end
|
15
|
+
|
16
|
+
# overriding 'git_hub' here to make directories look prettier
|
17
|
+
def name
|
18
|
+
:bitbucket
|
19
|
+
end
|
20
|
+
|
21
|
+
def repo_name
|
22
|
+
url =~ SERVICE_REGEXP && $3
|
23
|
+
end
|
24
|
+
|
25
|
+
def user_name
|
26
|
+
url =~ SERVICE_REGEXP && $2
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Repomen
|
2
|
+
module Repo
|
3
|
+
module Service
|
4
|
+
class GitHub < Base
|
5
|
+
SERVICE_REGEXP = /(https:\/\/|git\@)github.com[\:\/]([^\/]+)\/([^\.]+)\.git$/
|
6
|
+
|
7
|
+
# @param url [String]
|
8
|
+
def applicable?
|
9
|
+
url =~ SERVICE_REGEXP
|
10
|
+
end
|
11
|
+
|
12
|
+
def handler_class
|
13
|
+
Handler::Git
|
14
|
+
end
|
15
|
+
|
16
|
+
# overriding 'git_hub' here to make directories look prettier
|
17
|
+
def name
|
18
|
+
:github
|
19
|
+
end
|
20
|
+
|
21
|
+
def repo_name
|
22
|
+
url =~ SERVICE_REGEXP && $3
|
23
|
+
end
|
24
|
+
|
25
|
+
def user_name
|
26
|
+
url =~ SERVICE_REGEXP && $2
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Repomen
|
2
|
+
# The Retriever retrieved repos and discards at will.
|
3
|
+
#
|
4
|
+
# url = "git@bitbucket.org:atlassian_tutorial/helloworld.git"
|
5
|
+
# Retriever.new(url)
|
6
|
+
#
|
7
|
+
# When called with a block, the repo is automatically deleted afterwards
|
8
|
+
#
|
9
|
+
# Retriever.new(url) do |local_path|
|
10
|
+
# # repo is cloned in +local_path+
|
11
|
+
# end
|
12
|
+
# # repo is gone
|
13
|
+
#
|
14
|
+
class Retriever
|
15
|
+
include WithDefaultConfig
|
16
|
+
|
17
|
+
attr_reader :url, :path
|
18
|
+
|
19
|
+
def initialize(url, config = default_config, &block)
|
20
|
+
service = Repo::Service.for(url)
|
21
|
+
@handler = service.handler_class.new(url, repo_dir(service), config)
|
22
|
+
@handler.retrieve
|
23
|
+
@path = @handler.path
|
24
|
+
if block
|
25
|
+
block.call(@path)
|
26
|
+
discard_repo
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Removes the repo from the filesystem
|
31
|
+
def discard_repo
|
32
|
+
@handler.discard
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def repo_dir(service)
|
38
|
+
parts = [
|
39
|
+
service.name, service.user_name, service.repo_name
|
40
|
+
].map(&:to_s)
|
41
|
+
File.join(*parts)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/repomen.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'repomen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "repomen"
|
8
|
+
spec.version = Repomen::VERSION
|
9
|
+
spec.authors = ["René Föhring"]
|
10
|
+
spec.email = ["rf@bamaru.de"]
|
11
|
+
spec.summary = %q{Interface wrapper for retrieving repos}
|
12
|
+
spec.description = %q{Interface wrapper for retrieving repos from GitHub and BitBucket}
|
13
|
+
spec.homepage = "http://trivelop.de/repomen/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "simplecov"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.2"
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
describe ::Repomen::Config do
|
4
|
+
let(:described_class) { ::Repomen::Config }
|
5
|
+
|
6
|
+
it "should set the global working dir" do
|
7
|
+
assert !Repomen.config.nil?
|
8
|
+
tmp_dir = File.join(Repomen::ROOT, "tmp")
|
9
|
+
Repomen.config.work_dir = tmp_dir
|
10
|
+
assert_equal tmp_dir, Repomen.config.work_dir
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return a default working dir if set to nil" do
|
14
|
+
Repomen.config.work_dir = nil
|
15
|
+
assert !Repomen.config.work_dir.nil?
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should set working dir" do
|
19
|
+
tmp_dir = File.join(Repomen::ROOT, "tmp")
|
20
|
+
config = Repomen::Config.new(:work_dir => tmp_dir)
|
21
|
+
assert_equal tmp_dir, config.work_dir
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
|
3
|
+
describe ::Repomen::Repo::Handler::Git do
|
4
|
+
before do
|
5
|
+
tmp_dir = File.join(Repomen::ROOT, "tmp")
|
6
|
+
Repomen.config.work_dir = tmp_dir
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:described_class) { ::Repomen::Repo::Handler::Git }
|
10
|
+
let(:dir) { "octocat/Hello-World" }
|
11
|
+
|
12
|
+
describe "#retrieve" do
|
13
|
+
it "should recognize a Github URL via git" do
|
14
|
+
url = "git@github.com:octocat/Hello-World.git"
|
15
|
+
handler = described_class.new(url, dir)
|
16
|
+
handler.retrieve
|
17
|
+
assert File.exists?(handler.path)
|
18
|
+
assert File.directory?(handler.path)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should recognize a Github URL via https" do
|
22
|
+
url = "https://github.com/octocat/Hello-World.git"
|
23
|
+
handler = described_class.new(url, dir)
|
24
|
+
handler.retrieve
|
25
|
+
assert File.exists?(handler.path)
|
26
|
+
assert File.directory?(handler.path)
|
27
|
+
|
28
|
+
handler.discard
|
29
|
+
assert !File.exists?(handler.path)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#git_options" do
|
34
|
+
it "should include --depth=1 if only_last_revision is set" do
|
35
|
+
url = "git@github.com:octocat/Hello-World.git"
|
36
|
+
handler = described_class.new(url, dir, {:only_last_revision => true})
|
37
|
+
options = handler.method(:git_options).call
|
38
|
+
assert options.include?('--depth=1')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should NOT include --depth=1 if only_last_revision is set" do
|
42
|
+
url = "git@github.com:octocat/Hello-World.git"
|
43
|
+
handler = described_class.new(url, dir, {:only_last_revision => false})
|
44
|
+
options = handler.method(:git_options).call
|
45
|
+
assert !options.include?('--depth=1')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
|
3
|
+
describe ::Repomen::Repo::Service::BitBucket do
|
4
|
+
let(:described_class) { ::Repomen::Repo::Service::BitBucket }
|
5
|
+
|
6
|
+
it "should recognize a Github URL via git" do
|
7
|
+
url = "git@bitbucket.org:atlassian_tutorial/helloworld.git"
|
8
|
+
service = described_class.new(url)
|
9
|
+
assert service.applicable?
|
10
|
+
assert_equal "atlassian_tutorial", service.user_name
|
11
|
+
assert_equal "helloworld", service.repo_name
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should recognize a Github URL via https" do
|
15
|
+
url = "https://bitbucket.org/atlassian_tutorial/helloworld.git"
|
16
|
+
service = described_class.new(url)
|
17
|
+
assert service.applicable?
|
18
|
+
assert_equal "atlassian_tutorial", service.user_name
|
19
|
+
assert_equal "helloworld", service.repo_name
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
|
3
|
+
describe ::Repomen::Repo::Service::GitHub do
|
4
|
+
let(:described_class) { ::Repomen::Repo::Service::GitHub }
|
5
|
+
|
6
|
+
it "should recognize a Github URL via git" do
|
7
|
+
url = "git@github.com:octocat/Hello-World.git"
|
8
|
+
service = described_class.new(url)
|
9
|
+
assert service.applicable?
|
10
|
+
assert_equal "octocat", service.user_name
|
11
|
+
assert_equal "Hello-World", service.repo_name
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should recognize a Github URL via https" do
|
15
|
+
url = "https://github.com/octocat/Hello-World.git"
|
16
|
+
service = described_class.new(url)
|
17
|
+
assert service.applicable?
|
18
|
+
assert_equal "octocat", service.user_name
|
19
|
+
assert_equal "Hello-World", service.repo_name
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
describe ::Repomen::Repo::Service do
|
4
|
+
let(:described_class) { ::Repomen::Repo::Service }
|
5
|
+
|
6
|
+
it "should recognize a GitHub URL via git" do
|
7
|
+
url = "git@github.com:octocat/Hello-World.git"
|
8
|
+
service = described_class.for(url)
|
9
|
+
assert_equal :github, service.name
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should recognize a BitBucket URL via git" do
|
13
|
+
url = "git@bitbucket.org:atlassian_tutorial/helloworld.git"
|
14
|
+
service = described_class.for(url)
|
15
|
+
assert_equal :bitbucket, service.name
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
describe ::Repomen::Retriever do
|
4
|
+
let(:described_class) { ::Repomen::Retriever }
|
5
|
+
let(:url) { "git@bitbucket.org:atlassian_tutorial/helloworld.git" }
|
6
|
+
|
7
|
+
it "should retrieve the repo" do
|
8
|
+
retriever = described_class.new(url)
|
9
|
+
assert File.exists?(retriever.path)
|
10
|
+
|
11
|
+
retriever.discard_repo
|
12
|
+
assert !File.exists?(retriever.path)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should retrieve the repo, yield to block and discard the repo" do
|
16
|
+
@path = nil
|
17
|
+
described_class.new(url) do |path|
|
18
|
+
@path = path
|
19
|
+
assert File.exists?(@path)
|
20
|
+
end
|
21
|
+
assert !File.exists?(@path)
|
22
|
+
end
|
23
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'bundler'
|
7
|
+
Bundler.require
|
8
|
+
require 'repomen'
|
9
|
+
|
10
|
+
def fixture_path(name)
|
11
|
+
File.join(File.dirname(__FILE__), "fixtures", name.to_s)
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: repomen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- René Föhring
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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: pry
|
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: simplecov
|
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: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.2'
|
83
|
+
description: Interface wrapper for retrieving repos from GitHub and BitBucket
|
84
|
+
email:
|
85
|
+
- rf@bamaru.de
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .ruby-gemset
|
92
|
+
- .ruby-version
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/repomen.rb
|
98
|
+
- lib/repomen/config.rb
|
99
|
+
- lib/repomen/repo.rb
|
100
|
+
- lib/repomen/repo/handler.rb
|
101
|
+
- lib/repomen/repo/handler/base.rb
|
102
|
+
- lib/repomen/repo/handler/git.rb
|
103
|
+
- lib/repomen/repo/service.rb
|
104
|
+
- lib/repomen/repo/service/base.rb
|
105
|
+
- lib/repomen/repo/service/bit_bucket.rb
|
106
|
+
- lib/repomen/repo/service/git_hub.rb
|
107
|
+
- lib/repomen/repo/url.rb
|
108
|
+
- lib/repomen/retriever.rb
|
109
|
+
- lib/repomen/version.rb
|
110
|
+
- repomen.gemspec
|
111
|
+
- test/repomen/config_test.rb
|
112
|
+
- test/repomen/repo/handler/git_test.rb
|
113
|
+
- test/repomen/repo/handler_test.rb
|
114
|
+
- test/repomen/repo/service/bit_bucket_test.rb
|
115
|
+
- test/repomen/repo/service/git_hub_test.rb
|
116
|
+
- test/repomen/repo/service_test.rb
|
117
|
+
- test/repomen/retriever_test.rb
|
118
|
+
- test/test_helper.rb
|
119
|
+
homepage: http://trivelop.de/repomen/
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.0.6
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Interface wrapper for retrieving repos
|
143
|
+
test_files:
|
144
|
+
- test/repomen/config_test.rb
|
145
|
+
- test/repomen/repo/handler/git_test.rb
|
146
|
+
- test/repomen/repo/handler_test.rb
|
147
|
+
- test/repomen/repo/service/bit_bucket_test.rb
|
148
|
+
- test/repomen/repo/service/git_hub_test.rb
|
149
|
+
- test/repomen/repo/service_test.rb
|
150
|
+
- test/repomen/retriever_test.rb
|
151
|
+
- test/test_helper.rb
|