pullbot 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +29 -0
- data/README.md +2 -0
- data/bin/pullbot +6 -0
- data/lib/progress-bar/bar.rb +49 -0
- data/lib/pull-bundle/base.rb +37 -0
- data/lib/pull-bundle/repository.rb +69 -0
- data/lib/pullbot.rb +7 -0
- data/pullbot-0.0.1.gem +0 -0
- data/pullbot.gemspec +18 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60b84394a56c120b1aeac3104b3ba1ead16a1ccf
|
4
|
+
data.tar.gz: 69cc4ca662433907c8a8e044663607e887509e79
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b0a90500b7cb2ffa99090a9945406d0b4ca208b7b6d75abc0db969434865ecb25f6b2973a34d19b1709acd25334ae9f9662390a1076729bb285a0444bd1ab35
|
7
|
+
data.tar.gz: d59c7b37155deba0cb68b808584b204986960738745409b5ffe1007df98f9f6b63a13fc0cfe34185c69c7f791207acf38f979c21041f1f5691f1d276fdbdb61e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
coderay (1.0.9)
|
5
|
+
columnize (0.3.6)
|
6
|
+
debugger (1.6.2)
|
7
|
+
columnize (>= 0.3.1)
|
8
|
+
debugger-linecache (~> 1.2.0)
|
9
|
+
debugger-ruby_core_source (~> 1.2.3)
|
10
|
+
debugger-linecache (1.2.0)
|
11
|
+
debugger-ruby_core_source (1.2.3)
|
12
|
+
method_source (0.8.2)
|
13
|
+
open4 (1.3.0)
|
14
|
+
pry (0.9.12.2)
|
15
|
+
coderay (~> 1.0.5)
|
16
|
+
method_source (~> 0.8)
|
17
|
+
slop (~> 3.4)
|
18
|
+
pry-debugger (0.2.2)
|
19
|
+
debugger (~> 1.3)
|
20
|
+
pry (~> 0.9.10)
|
21
|
+
slop (3.4.6)
|
22
|
+
|
23
|
+
PLATFORMS
|
24
|
+
ruby
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
open4
|
28
|
+
pry
|
29
|
+
pry-debugger
|
data/README.md
ADDED
data/bin/pullbot
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module ProgressBar
|
2
|
+
|
3
|
+
class Bar
|
4
|
+
|
5
|
+
DEFAULT_OUTPUT_STREAM = $stdout
|
6
|
+
DEFAULT_LENGTH = 100
|
7
|
+
attr_accessor :length, :output, :format_string, :steps
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@output = options[:output] || DEFAULT_OUTPUT_STREAM
|
11
|
+
@length = options[:length] || DEFAULT_LENGTH
|
12
|
+
@steps = options[:steps] || 1
|
13
|
+
init_string
|
14
|
+
|
15
|
+
update(@output, @format_string)
|
16
|
+
end
|
17
|
+
|
18
|
+
def step sym
|
19
|
+
@format_string += "#{'=' * (step_length - 1) + sym}"
|
20
|
+
update @output, @format_string
|
21
|
+
end
|
22
|
+
|
23
|
+
def result
|
24
|
+
output.print @format_string
|
25
|
+
output.flush
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def init_string
|
31
|
+
@length = @length / @steps * @steps
|
32
|
+
@format_string = ""
|
33
|
+
end
|
34
|
+
|
35
|
+
def step_length
|
36
|
+
@length / @steps
|
37
|
+
end
|
38
|
+
|
39
|
+
def update(output, string)
|
40
|
+
output.print string
|
41
|
+
output.print "\r"
|
42
|
+
output.flush
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
ProgressBar::Bar.new
|
49
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative '../progress-bar/bar'
|
2
|
+
require_relative 'repository'
|
3
|
+
|
4
|
+
module PullBundle
|
5
|
+
|
6
|
+
class Base
|
7
|
+
|
8
|
+
DEFAULT_DIRECTORY = Dir.pwd
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@dir = options[:dir] || DEFAULT_DIRECTORY
|
12
|
+
@repositories = repositories(@dir)
|
13
|
+
run(@repositories)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(repositories)
|
17
|
+
repositories.each do |repository|
|
18
|
+
begin
|
19
|
+
repository.run()
|
20
|
+
puts "#{repository.name}: Success"
|
21
|
+
rescue Repository::CommandException => command_exception
|
22
|
+
puts "#{repository.name}: #{command_exception}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def repositories(dirs)
|
28
|
+
repositories = []
|
29
|
+
Dir.foreach(dirs) do |dir|
|
30
|
+
next if dir == '.' or dir == '..'
|
31
|
+
repositories << Repository.new(base: dirs, name: dir)
|
32
|
+
end
|
33
|
+
repositories
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'open4'
|
2
|
+
|
3
|
+
module PullBundle
|
4
|
+
|
5
|
+
class Repository
|
6
|
+
|
7
|
+
attr_accessor :name
|
8
|
+
|
9
|
+
ERRORS = ['ERROR', 'fatal']
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@name = options[:name]
|
13
|
+
@address = "#{options[:base]}/#{@name}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
if is_git_repository? and is_clean?
|
18
|
+
update
|
19
|
+
else
|
20
|
+
raise CommandException.new('Not a clean git repository.')
|
21
|
+
end
|
22
|
+
|
23
|
+
if is_ruby_repository?
|
24
|
+
install_gems
|
25
|
+
else
|
26
|
+
raise CommandException.new('Not a ruby repository.')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_ruby_repository?
|
31
|
+
File.exist?("#{@address}//Gemfile")
|
32
|
+
end
|
33
|
+
|
34
|
+
def is_git_repository?
|
35
|
+
Dir.exist?("#{@address}//.git")
|
36
|
+
end
|
37
|
+
|
38
|
+
def install_gems
|
39
|
+
run_command 'bundle install', 'Your bundle is complete!', CommandException.new('Could not install gems.')
|
40
|
+
end
|
41
|
+
|
42
|
+
def is_clean?
|
43
|
+
run_command 'git status', 'working directory clean', CommandException.new('Not a clean directory.')
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
def update
|
48
|
+
run_command 'git pull', '', CommandException.new('Could not update repository.')
|
49
|
+
run_command 'git status', 'working directory clean', CommandException.new('Could not update repository.')
|
50
|
+
end
|
51
|
+
|
52
|
+
def run_command(command, condition, exception)
|
53
|
+
Dir.chdir(@address)
|
54
|
+
status = Open4::popen4(command)
|
55
|
+
message = status[2].read
|
56
|
+
error = status[3].read
|
57
|
+
raise exception if not message.include?(condition) or not error.empty? or include_error_message?(message)
|
58
|
+
end
|
59
|
+
|
60
|
+
def include_error_message?(message)
|
61
|
+
not ERRORS.reduce(true) { |meta, error| meta and not message.include?(error) }
|
62
|
+
end
|
63
|
+
|
64
|
+
class CommandException < Exception
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
data/lib/pullbot.rb
ADDED
data/pullbot-0.0.1.gem
ADDED
Binary file
|
data/pullbot.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ['biq']
|
7
|
+
gem.email = 'du.just.it@gmail.com'
|
8
|
+
gem.description = 'Auto pull git repository and bundle ruby gems'
|
9
|
+
gem.name = 'pullbot'
|
10
|
+
gem.summary = 'pullbot'
|
11
|
+
gem.version = '0.0.2'
|
12
|
+
gem.homepage = 'http://rubygems.org/gems/pullbot'
|
13
|
+
|
14
|
+
gem.add_runtime_dependency 'open4'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pullbot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- biq
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: open4
|
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
|
+
description: Auto pull git repository and bundle ruby gems
|
28
|
+
email: du.just.it@gmail.com
|
29
|
+
executables:
|
30
|
+
- pullbot
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- README.md
|
38
|
+
- bin/pullbot
|
39
|
+
- lib/progress-bar/bar.rb
|
40
|
+
- lib/pull-bundle/base.rb
|
41
|
+
- lib/pull-bundle/repository.rb
|
42
|
+
- lib/pullbot.rb
|
43
|
+
- pullbot-0.0.1.gem
|
44
|
+
- pullbot.gemspec
|
45
|
+
homepage: http://rubygems.org/gems/pullbot
|
46
|
+
licenses: []
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.0.6
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: pullbot
|
68
|
+
test_files: []
|