madx-ruacce 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +68 -0
- data/Rakefile +12 -0
- data/VERSION +1 -0
- data/bin/ruacce +5 -0
- data/lib/ruacce.rb +32 -0
- data/lib/ruacce/argv_parser.rb +146 -0
- data/lib/ruacce/config.rb +35 -0
- data/lib/ruacce/repository.rb +16 -0
- metadata +60 -0
data/README
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
|
2
|
+
ruacce -- the repository updater and custom command executer
|
3
|
+
|
4
|
+
-------------------------------------------------------------------------------
|
5
|
+
|
6
|
+
ruacce (pronounced "lu-ah-tché") is a small command line tool that helps you
|
7
|
+
with managing the repositories
|
8
|
+
you're tracking. You can also define rules that performs some actions on your
|
9
|
+
repositories (like building gems, running (R|M)akefiles,...)
|
10
|
+
|
11
|
+
ruacce is scm-agnostic so you can mix Git, Mercurial or Subversion repositories
|
12
|
+
without any worry.
|
13
|
+
|
14
|
+
** Install **
|
15
|
+
|
16
|
+
$ sudo gem install madx-ruacce --source=http://gems.github.com/
|
17
|
+
or
|
18
|
+
$ cd your/repos/folder/
|
19
|
+
$ git clone git://github.com/madx/ruacce.git
|
20
|
+
$ cd ruacce; rake
|
21
|
+
And a fresh gem will be placed in the pkg/ folder
|
22
|
+
|
23
|
+
** Usage **
|
24
|
+
|
25
|
+
First, run ruacce --help.
|
26
|
+
Then, cd to the folder where you keep your repos and run ruacce -C to generate
|
27
|
+
a blank config file (.ruacce_rules, created in the current folder)
|
28
|
+
|
29
|
+
Ok let's say you've got those awesome repositories in your folder:
|
30
|
+
|
31
|
+
shoes, merb-core, merb-more, dm-core, dm-more, haml and mtest (managed by git)
|
32
|
+
trac, lighttpd (managed by svn)
|
33
|
+
audacious (tracked by mercurial)
|
34
|
+
|
35
|
+
That's a big bunch of repositories, and when you want to update them all you
|
36
|
+
have to manually cd in the folder an run the appropriate command.
|
37
|
+
But wait. No. You just installed ruacce !!!
|
38
|
+
|
39
|
+
The first thing you may want to do is defining a command to fetch the latest
|
40
|
+
changes on you repos.
|
41
|
+
It's "git/hg pull" for Git and Mercurial and "svn update" for Subversion.
|
42
|
+
|
43
|
+
So for defining the actions for git repositories you could do a :
|
44
|
+
$ ruacce -s shoes,merb-more,merb-core,dm-core,dm-more,haml,mtest -A pull
|
45
|
+
|
46
|
+
This will add a rule "pull" for those repos. The system will ask you for the
|
47
|
+
command to be run when executing this rule. Type "git pull" and push Enter.
|
48
|
+
Since you've grasped how it works, you already added rules for your Mercurial
|
49
|
+
and Subversion repositories.
|
50
|
+
|
51
|
+
The important thing is that -s selects repositories, and the action will be
|
52
|
+
executed upon each of them.
|
53
|
+
|
54
|
+
You can show the rules defined on some projects using -R and selecting them
|
55
|
+
with -s
|
56
|
+
|
57
|
+
The -X switch is used to hide some folders from ruacce so it doesn't count them
|
58
|
+
as repositories.
|
59
|
+
|
60
|
+
Well, I think this should be enough to start, the --help switch will tell you
|
61
|
+
the rest.
|
62
|
+
|
63
|
+
** Bug reports/testimonials **
|
64
|
+
|
65
|
+
Feel free to send them on github (http://github.com/madx/ruacce) or drop me an
|
66
|
+
email. I also accept patches :)
|
67
|
+
If you're using ruacce and want to be in this README, write a funny testimonial
|
68
|
+
and email it to me.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
|
5
|
+
RUACCE_GEMSPEC = eval(File.read('ruacce.gemspec'))
|
6
|
+
|
7
|
+
Rake::GemPackageTask.new(RUACCE_GEMSPEC) do |pkg|
|
8
|
+
pkg.need_tar_bz2 = true
|
9
|
+
end
|
10
|
+
task :default => "pkg/#{RUACCE_GEMSPEC.name}-#{RUACCE_GEMSPEC.version}.gem" do
|
11
|
+
puts "generated latest version"
|
12
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/bin/ruacce
ADDED
data/lib/ruacce.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'optparse'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
dir = File.dirname(__FILE__)
|
7
|
+
$LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
|
8
|
+
|
9
|
+
require 'ruacce/argv_parser'
|
10
|
+
require 'ruacce/config'
|
11
|
+
require 'ruacce/repository'
|
12
|
+
|
13
|
+
module Ruacce
|
14
|
+
RULES_FILE = '.ruacce_rules'
|
15
|
+
|
16
|
+
module Formats
|
17
|
+
def self.included(parent)
|
18
|
+
{ :o => "33", :p => "35", :g => "32", :r => "1;31", :w => "1;37"}.
|
19
|
+
each do |meth, color|
|
20
|
+
parent.class_eval { define_method(meth) { "\e[#{color}m#{self}\e[00m" } }
|
21
|
+
end
|
22
|
+
parent.class_eval do
|
23
|
+
define_method(:i) do
|
24
|
+
self.ljust(78).split("\n").collect{|l| " #{l}"}.join("\n")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
String.send(:include, Formats)
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module Ruacce
|
2
|
+
class ArgvParser
|
3
|
+
|
4
|
+
def self.parse(args)
|
5
|
+
options = OpenStruct.new
|
6
|
+
options.repositories = []
|
7
|
+
options.quiet = false
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.banner = "Usage: ruacce [options] repos"
|
11
|
+
|
12
|
+
opts.separator ""
|
13
|
+
opts.separator "Specific options:"
|
14
|
+
|
15
|
+
opts.on('-s', '--select [REPO]', 'Select repository REPO') do |repo|
|
16
|
+
repo.split(',').each do |r|
|
17
|
+
options.repositories << Repository.new(r)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on('-a', '--all', 'Select every repository') do
|
22
|
+
Repository.repos.each do |repo|
|
23
|
+
options.repositories << Repository.new(repo)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on('-r', '--rule [RULE]', 'Execute RULE on each selected repo') do |rule|
|
28
|
+
rule = rule.to_sym
|
29
|
+
options.repositories.each do |repo|
|
30
|
+
puts "> #{repo.name}".w unless options.quiet
|
31
|
+
if repo.rules.is_a?(Hash) && repo.rules.key?(rule)
|
32
|
+
FileUtils.cd(repo.name) do
|
33
|
+
system repo.rules[rule]
|
34
|
+
end
|
35
|
+
else
|
36
|
+
puts " Warning: repository #{repo.name} has no rule #{rule}".p unless options.quiet
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on('-q', '--quiet', 'Disables output when executing rules, nice for using ruacce as a rule') do
|
42
|
+
options.quiet = true
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on('-R', '--rules', 'See available rules for the selected repos') do
|
46
|
+
unless options.repositories.empty?
|
47
|
+
options.repositories.each do |repo|
|
48
|
+
puts "> #{repo.name}".w
|
49
|
+
unless repo.rules.nil?
|
50
|
+
repo.rules.each do |name, command|
|
51
|
+
puts " #{name.to_s.o}: #{command}"
|
52
|
+
end
|
53
|
+
else
|
54
|
+
puts " no rules defined so far."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
err "Error: No repository specified."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on('-A', '--add-rule [NAME]', 'Add a rule NAME for the selected repo') do |name|
|
63
|
+
conf = Config.new
|
64
|
+
name = name.to_sym
|
65
|
+
unless options.repositories.empty?
|
66
|
+
print "Enter the command: ".o
|
67
|
+
rule = gets.chomp
|
68
|
+
options.repositories.each do |repo|
|
69
|
+
reposym = repo.name.to_sym
|
70
|
+
if conf.rules[reposym].is_a?(Hash) && conf.rules[reposym].key?(name)
|
71
|
+
print "#{reposym} already has a rule #{name}, overwrite ? (yes/no/all) ".o
|
72
|
+
ans = gets.chomp
|
73
|
+
if ! ans =~ /y(?:e(?:s))/i
|
74
|
+
abort "Aborting."
|
75
|
+
elsif ans == 'all'
|
76
|
+
break
|
77
|
+
end
|
78
|
+
end
|
79
|
+
(conf.rules[reposym] ||= {})[name] = rule
|
80
|
+
end
|
81
|
+
print "Added rule #{name} on: ".o
|
82
|
+
options.repositories.each {|repo| print repo.name+' ' }
|
83
|
+
conf.save
|
84
|
+
done "\nConfig file saved".g
|
85
|
+
else
|
86
|
+
err "Error: No repository specified.".r
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
opts.on('-X', '--exclude [DIR][,DIR]', 'Add DIR(s) to excluded folders') do |d|
|
91
|
+
conf = Config.new
|
92
|
+
conf.config[:exclude] ||= []
|
93
|
+
print "Add to exclude list: ".o
|
94
|
+
d.split(',').each do |dir|
|
95
|
+
print dir
|
96
|
+
conf.config[:exclude] << dir
|
97
|
+
end
|
98
|
+
conf.save
|
99
|
+
done "\nConfig file saved".g
|
100
|
+
end
|
101
|
+
|
102
|
+
opts.on('-C', '--config-stub', 'Generate a blank config file') do |p|
|
103
|
+
unless File.exist?(RULES_FILE)
|
104
|
+
File.open(RULES_FILE, 'w+') do |f|
|
105
|
+
f.write YAML.dump(Config.blank)
|
106
|
+
end
|
107
|
+
done "Blank config file generated (in .ruacce_rules)"
|
108
|
+
else
|
109
|
+
abord "A configuration file has been found, aborting"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
opts.separator ""
|
114
|
+
opts.separator "Common options:"
|
115
|
+
|
116
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
117
|
+
puts opts
|
118
|
+
puts "\nDescription:",
|
119
|
+
" ruacce -- This tool allows you to update your repositories",
|
120
|
+
" or automatically execute custom commands on them."
|
121
|
+
exit
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
opts.parse!(args)
|
127
|
+
options
|
128
|
+
end # self.parse()
|
129
|
+
|
130
|
+
def self.err(str)
|
131
|
+
puts str.r
|
132
|
+
exit
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.abort(str)
|
136
|
+
puts str.p
|
137
|
+
exit
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.done(str)
|
141
|
+
puts str.g
|
142
|
+
exit
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Ruacce
|
2
|
+
class Config
|
3
|
+
|
4
|
+
attr_reader :rules, :config
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
if File.exist?(RULES_FILE)
|
8
|
+
yaml = YAML.load(File.read(RULES_FILE))
|
9
|
+
@rules = yaml[:rules]
|
10
|
+
@config = yaml[:config]
|
11
|
+
else
|
12
|
+
raise "configuration file not found"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_rule(repo, name, script, obj=nil)
|
17
|
+
@rules[repo] = {name => script}
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_exclude(dir)
|
21
|
+
(@config[:excludes] ||= []) << dir
|
22
|
+
end
|
23
|
+
|
24
|
+
def save
|
25
|
+
File.open(RULES_FILE, 'w+') do |f|
|
26
|
+
f.write YAML.dump({}.merge(:rules => @rules).merge(:config => @config))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.blank
|
31
|
+
{:config => {}, :rules => {}}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ruacce
|
2
|
+
class Repository
|
3
|
+
|
4
|
+
attr_accessor :rules, :name
|
5
|
+
|
6
|
+
def initialize(name)
|
7
|
+
@name = name
|
8
|
+
@rules = Config.new.rules[name.to_sym]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.repos
|
12
|
+
Dir['*'].select{|d| File.directory?(d) }.sort - Config.new.config[:exclude]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: madx-ruacce
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Fran\xC3\xA7ois Vaux"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-25 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: ruacce is a small tool to automate repository update. It can work with any version control system and also provides custom scripts execution.
|
17
|
+
email: root+ruacce@yapok.org
|
18
|
+
executables:
|
19
|
+
- ruacce
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/ruacce.rb
|
26
|
+
- lib/ruacce/argv_parser.rb
|
27
|
+
- lib/ruacce/config.rb
|
28
|
+
- lib/ruacce/repository.rb
|
29
|
+
- bin/ruacce
|
30
|
+
- Rakefile
|
31
|
+
- README
|
32
|
+
- VERSION
|
33
|
+
has_rdoc: false
|
34
|
+
homepage: http://yapok.org/
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.2.0
|
56
|
+
signing_key:
|
57
|
+
specification_version: 2
|
58
|
+
summary: Repository Updater and Custom Command Executer
|
59
|
+
test_files: []
|
60
|
+
|