autobuilder 1.0.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/bin/autobuild +129 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 66acc727246dda7acdaee7f1b402860f1928bea6
|
4
|
+
data.tar.gz: eae251998bbe99acb5ce7ef328af306ddd83e3a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d2b525ef8744d780dfc99c258b2fe6005f4354b99dc13939c14788fb87e90749eff68d50260b45e36282777aaa102bba9d5178ca5bd7ce61dd4acff335e5809a
|
7
|
+
data.tar.gz: c0de55932fdfb04d2640f5a4fbff9bd5c9c58db038820a3a05357dec9989366f62b81fd4fdfb03e3ab9cdcbedd743b842761f414fbc4815e997368bd683959f7
|
data/bin/autobuild
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# autobuild
|
3
|
+
# (C) 2013 jtRIPper
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation; either version 1, or (at your option)
|
8
|
+
# any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
18
|
+
|
19
|
+
require 'inotify'
|
20
|
+
require 'optparse'
|
21
|
+
|
22
|
+
# print a command with two spaces before each line.
|
23
|
+
def pp_cmd(cmd)
|
24
|
+
puts ""
|
25
|
+
`#{cmd}`.split("\n").each { |line|
|
26
|
+
puts " #{line}"
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# wait for an event on a directory
|
31
|
+
def wait_edit(directory)
|
32
|
+
inotify = Inotify.new
|
33
|
+
inotify.recursive_add_watch(directory, InotifyEvents::IN_MODIFY|InotifyEvents::IN_CLOSE_WRITE)
|
34
|
+
|
35
|
+
inotify.wait_for_event() { |path, mask, name|
|
36
|
+
yield path, name
|
37
|
+
}
|
38
|
+
|
39
|
+
inotify.rm_all_watches()
|
40
|
+
end
|
41
|
+
|
42
|
+
# loop over events
|
43
|
+
def loop_edits(directory)
|
44
|
+
while 1
|
45
|
+
wait_edit(directory) { |path, name|
|
46
|
+
yield path, name
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# returns true if the regex in a list matches the string
|
52
|
+
def match_re_list?(string, list)
|
53
|
+
return list.select { |re| re.match(string) }.length > 0
|
54
|
+
end
|
55
|
+
|
56
|
+
# parse the configuration file
|
57
|
+
def parse_config(path)
|
58
|
+
def get_option(name)
|
59
|
+
AutobuildConfig.class_variable_get "@@#{name}".to_sym
|
60
|
+
end
|
61
|
+
|
62
|
+
require path
|
63
|
+
|
64
|
+
options = {}
|
65
|
+
begin
|
66
|
+
options["project_dir"] = get_option("project_directory")
|
67
|
+
options["build"] = get_option("build")
|
68
|
+
options["execute"] = get_option("execute")
|
69
|
+
options["include_files"] = get_option("include_files")
|
70
|
+
options["exclude_files"] = get_option("exclude_files")
|
71
|
+
rescue NameError
|
72
|
+
puts "Required options:"
|
73
|
+
puts " project_directory"
|
74
|
+
puts " build"
|
75
|
+
puts " execute"
|
76
|
+
puts " include_files"
|
77
|
+
puts " exclude_files"
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
options
|
81
|
+
end
|
82
|
+
|
83
|
+
options = {}
|
84
|
+
|
85
|
+
opt_parse = OptionParser.new do |opts|
|
86
|
+
opts.banner = "Usage: #{$0} [options]"
|
87
|
+
opts.on("-c", "--config CONFIG", "Configuration file") do |c|
|
88
|
+
options[:config] = c
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
opt_parse.parse!
|
93
|
+
|
94
|
+
unless options[:config]
|
95
|
+
puts opt_parse
|
96
|
+
exit
|
97
|
+
end
|
98
|
+
|
99
|
+
full_path = File.expand_path("#{options[:config]}", Dir.pwd)
|
100
|
+
if File.exists? full_path
|
101
|
+
options = parse_config(full_path)
|
102
|
+
else
|
103
|
+
puts "#{full_path} does not exist."
|
104
|
+
exit
|
105
|
+
end
|
106
|
+
|
107
|
+
puts " [*] Project directory: #{options["project_dir"]}"
|
108
|
+
puts " [*] Build command: #{options["build"]}"
|
109
|
+
puts " [*] Execute command: #{options["execute"]}"
|
110
|
+
|
111
|
+
Dir.chdir options["project_dir"]
|
112
|
+
|
113
|
+
begin
|
114
|
+
loop_edits(options["project_dir"]) { |path, name|
|
115
|
+
# make sure that the path matches the include_files
|
116
|
+
next unless match_re_list?("#{path}/#{name}", options["include_files"])
|
117
|
+
# make sure that the exclude_files do not match
|
118
|
+
next if match_re_list?("#{path}/#{name}", options["exclude_files"])
|
119
|
+
|
120
|
+
# build and execute
|
121
|
+
puts "\n [*] #{path}/#{name} edited."
|
122
|
+
puts " [*] Building..."
|
123
|
+
pp_cmd(options["build"])
|
124
|
+
puts "\n [*] Executing..."
|
125
|
+
pp_cmd(options["execute"])
|
126
|
+
}
|
127
|
+
rescue Interrupt
|
128
|
+
puts "\nCaught ^C, quitting."
|
129
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: autobuilder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jtripper
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: inotify
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: automatically build project on file save
|
28
|
+
email: jack@jtripper.net
|
29
|
+
executables:
|
30
|
+
- autobuild
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/autobuild
|
35
|
+
homepage: https://github.com/jtripper/autobuild
|
36
|
+
licenses:
|
37
|
+
- GPLv2
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.0.3
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: autobuild
|
59
|
+
test_files: []
|