cinchize 0.3.0 → 0.4.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.
- data/LICENSE +1 -1
- data/README.rdoc +2 -8
- data/Rakefile +3 -8
- data/VERSION +1 -1
- data/bin/cinchize +73 -2
- data/cinchize.gemspec +15 -17
- data/lib/cinchize.rb +10 -73
- metadata +52 -70
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -18,13 +18,13 @@ The config file can either be in the current working directory or in /etc and sh
|
|
18
18
|
|
19
19
|
cinchize -s --start network
|
20
20
|
|
21
|
-
To
|
21
|
+
To daemonize, use -d
|
22
22
|
|
23
23
|
cinchize -d --start network
|
24
24
|
|
25
25
|
Network is the name you call the a server config in the servers part of the config file, i.e. "freenode", "super_duper_amazing_network", "quakenet" or similar.
|
26
26
|
|
27
|
-
--start, --restart, --stop and --status assumes that
|
27
|
+
--start, --restart, --stop and --status assumes that "cinchize.yml" is located in the current working directory unless -s is used, then we assume that it's located in "/etc/cinchize.yml" as stated above.
|
28
28
|
|
29
29
|
== Config-file
|
30
30
|
|
@@ -43,18 +43,12 @@ All config options to each server object is optional, except for the channels an
|
|
43
43
|
- "#cinchbots"
|
44
44
|
plugins:
|
45
45
|
-
|
46
|
-
module: "cinch/plugins/some_plugin"
|
47
46
|
class: "Cinch::Plugins::SomePlugin"
|
48
47
|
options:
|
49
48
|
option: value
|
50
49
|
-
|
51
|
-
module: "cinch/plugins/another_plugin"
|
52
50
|
class: "Cinch::Plugins::AnotherPlugin"
|
53
51
|
|
54
|
-
=== JSON deprecation
|
55
|
-
|
56
|
-
The JSON format has been deprecated and will be removed in a future release, YaML is the preferred format hence forth.
|
57
|
-
|
58
52
|
=== Options explained
|
59
53
|
|
60
54
|
dir: the save path, absolute or relative to either /var/run or to the current working directory
|
data/Rakefile
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rake'
|
5
|
-
|
6
3
|
begin
|
7
4
|
require 'jeweler'
|
8
5
|
Jeweler::Tasks.new do |gem|
|
@@ -11,13 +8,11 @@ begin
|
|
11
8
|
gem.description = %Q{Create dynamic Cinch IRC-bots and daemonize them, without the need of writing any code}
|
12
9
|
gem.email = "victor.bergoo@gmail.com"
|
13
10
|
gem.homepage = "http://github.com/netfeed/cinchize"
|
14
|
-
gem.authors = ["Victor
|
15
|
-
gem.add_dependency "cinch"
|
11
|
+
gem.authors = ["Victor Bergoo"]
|
12
|
+
gem.add_dependency "cinch", ">= 2.0.1"
|
16
13
|
gem.add_dependency "daemons"
|
17
|
-
gem.add_dependency "json"
|
18
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
14
|
end
|
20
|
-
Jeweler::
|
15
|
+
Jeweler::RubygemsDotOrgTasks.new
|
21
16
|
rescue LoadError
|
22
17
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
23
18
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/bin/cinchize
CHANGED
@@ -1,8 +1,79 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
# Copyright (c) 2010 Victor Bergöö
|
3
|
+
# Copyright (c) 2010-2012 Victor Bergöö
|
4
4
|
# This program is made available under the terms of the MIT License.
|
5
5
|
|
6
6
|
require File.expand_path('../../lib/cinchize', __FILE__)
|
7
7
|
|
8
|
-
|
8
|
+
require 'optparse'
|
9
|
+
|
10
|
+
Options = {
|
11
|
+
:ontop => true,
|
12
|
+
:system => false,
|
13
|
+
:local_config => File.join(Dir.pwd, 'cinchize.yml'),
|
14
|
+
:system_config => '/etc/cinchize.yml',
|
15
|
+
:action => nil,
|
16
|
+
}
|
17
|
+
|
18
|
+
options = Options.dup
|
19
|
+
|
20
|
+
ARGV.options do |o|
|
21
|
+
o.set_summary_indent ' '
|
22
|
+
o.banner = "Usage: #{File.basename $0} [Options] network"
|
23
|
+
|
24
|
+
o.on("-d", "--daemonize", "Daemonize") {
|
25
|
+
options[:ontop] = false
|
26
|
+
}
|
27
|
+
|
28
|
+
o.on("-r", "--running", "Show status for all bots") {
|
29
|
+
options[:action] = :show_running
|
30
|
+
}
|
31
|
+
|
32
|
+
o.on("-s", "--system-config", "Use system config") {
|
33
|
+
options[:system] = true
|
34
|
+
}
|
35
|
+
|
36
|
+
o.on("--start", "Start the bot") {
|
37
|
+
options[:action] = :start
|
38
|
+
}
|
39
|
+
|
40
|
+
o.on("--status", "Status of the bot") {
|
41
|
+
options[:action] = :status
|
42
|
+
}
|
43
|
+
|
44
|
+
o.on("--stop", "Stop the bot") {
|
45
|
+
options[:action] = :stop
|
46
|
+
}
|
47
|
+
|
48
|
+
o.on("--restart", "Restart the bot") {
|
49
|
+
options[:action] = :restart
|
50
|
+
}
|
51
|
+
|
52
|
+
o.parse!
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
if options[:action] == :show_running
|
57
|
+
config_file = options[:system] ? options[:system_config]: options[:local_config]
|
58
|
+
|
59
|
+
raise ArgumentError.new "no such file: #{config_file}" unless File.exists? config_file
|
60
|
+
cfg = YAML.load_file config_file
|
61
|
+
|
62
|
+
raise ArgumentError.new "#{config_file} doesn't seem to be a YaML file" unless cfg
|
63
|
+
raise ArgumentError.new "cinchize isn't configured correctly, please recheck #{config_file}" unless cfg.key? "servers"
|
64
|
+
raise ArgumentError.new "there's no networks configured, please recheck #{config_file}" unless cfg["servers"]
|
65
|
+
cfg["servers"].keys.sort.each do |key|
|
66
|
+
daemon = Cinchize::Cinchize.new *Cinchize.config(options, key)
|
67
|
+
daemon.status
|
68
|
+
end
|
69
|
+
else
|
70
|
+
daemon = Cinchize::Cinchize.new *Cinchize.config(options, ARGV.first)
|
71
|
+
daemon.send options[:action]
|
72
|
+
end
|
73
|
+
rescue NoMethodError => e
|
74
|
+
puts "Error: no such method"
|
75
|
+
exit 1
|
76
|
+
rescue ArgumentError => e
|
77
|
+
puts "Error: #{e}"
|
78
|
+
exit 1
|
79
|
+
end
|
data/cinchize.gemspec
CHANGED
@@ -4,15 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.
|
7
|
+
s.name = "cinchize"
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Victor
|
12
|
-
s.date =
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.email = %q{victor.bergoo@gmail.com}
|
11
|
+
s.authors = ["Victor Bergoo"]
|
12
|
+
s.date = "2012-03-27"
|
13
|
+
s.description = "Create dynamic Cinch IRC-bots and daemonize them, without the need of writing any code"
|
14
|
+
s.email = "victor.bergoo@gmail.com"
|
16
15
|
s.executables = ["cinchize"]
|
17
16
|
s.extra_rdoc_files = [
|
18
17
|
"LICENSE",
|
@@ -28,28 +27,27 @@ Gem::Specification.new do |s|
|
|
28
27
|
"examples/cinchize.init",
|
29
28
|
"lib/cinchize.rb"
|
30
29
|
]
|
31
|
-
s.homepage =
|
30
|
+
s.homepage = "http://github.com/netfeed/cinchize"
|
32
31
|
s.require_paths = ["lib"]
|
33
|
-
s.rubygems_version =
|
34
|
-
s.summary =
|
32
|
+
s.rubygems_version = "1.8.10"
|
33
|
+
s.summary = "Create dynamic Cinch IRC-bots and daemonize them"
|
35
34
|
|
36
35
|
if s.respond_to? :specification_version then
|
37
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
36
|
s.specification_version = 3
|
39
37
|
|
40
38
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
41
|
-
s.add_runtime_dependency(%q<
|
39
|
+
s.add_runtime_dependency(%q<jeweler>, [">= 0"])
|
40
|
+
s.add_runtime_dependency(%q<cinch>, [">= 2.0.1"])
|
42
41
|
s.add_runtime_dependency(%q<daemons>, [">= 0"])
|
43
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
44
42
|
else
|
45
|
-
s.add_dependency(%q<
|
43
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
44
|
+
s.add_dependency(%q<cinch>, [">= 2.0.1"])
|
46
45
|
s.add_dependency(%q<daemons>, [">= 0"])
|
47
|
-
s.add_dependency(%q<json>, [">= 0"])
|
48
46
|
end
|
49
47
|
else
|
50
|
-
s.add_dependency(%q<
|
48
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
49
|
+
s.add_dependency(%q<cinch>, [">= 2.0.1"])
|
51
50
|
s.add_dependency(%q<daemons>, [">= 0"])
|
52
|
-
s.add_dependency(%q<json>, [">= 0"])
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
data/lib/cinchize.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (c) 2010 Victor Bergöö
|
2
|
+
# Copyright (c) 2010-2012 Victor Bergöö
|
3
3
|
# This program is made available under the terms of the MIT License.
|
4
4
|
|
5
5
|
dir = File.dirname(__FILE__)
|
@@ -8,92 +8,31 @@ $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include? dir
|
|
8
8
|
require 'cinch'
|
9
9
|
require 'daemons'
|
10
10
|
require 'yaml'
|
11
|
-
require 'optparse'
|
12
11
|
|
13
12
|
module Cinchize
|
14
|
-
Options = {
|
15
|
-
:ontop => true,
|
16
|
-
:system => false,
|
17
|
-
:local_config => File.join(Dir.pwd, 'cinchize.yml'),
|
18
|
-
:system_config => '/etc/cinchize.yml',
|
19
|
-
:action => nil,
|
20
|
-
}
|
21
|
-
|
22
|
-
def self.run
|
23
|
-
options = Options.dup
|
24
|
-
|
25
|
-
ARGV.options do |o|
|
26
|
-
o.set_summary_indent ' '
|
27
|
-
o.banner = "Usage: #{File.basename $0} [Options] network"
|
28
|
-
|
29
|
-
o.on("-d", "--daemonize", "Daemonize") {
|
30
|
-
options[:ontop] = false
|
31
|
-
}
|
32
|
-
|
33
|
-
o.on("-s", "--system-config", "Use system config") {
|
34
|
-
options[:system] = true
|
35
|
-
}
|
36
|
-
|
37
|
-
o.on("--start", "Start the bot") {
|
38
|
-
options[:action] = :start
|
39
|
-
}
|
40
|
-
|
41
|
-
o.on("--status", "Status of the bot") {
|
42
|
-
options[:action] = :status
|
43
|
-
}
|
44
|
-
|
45
|
-
o.on("--stop", "Stop the bot") {
|
46
|
-
options[:action] = :stop
|
47
|
-
}
|
48
|
-
|
49
|
-
o.on("--restart", "Restart the bot") {
|
50
|
-
options[:action] = :restart
|
51
|
-
}
|
52
|
-
|
53
|
-
o.parse!
|
54
|
-
end
|
55
|
-
|
56
|
-
daemon = Cinchize.new *config(options, ARGV.first)
|
57
|
-
daemon.send options[:action]
|
58
|
-
rescue NoMethodError => e
|
59
|
-
puts "Error: no such method"
|
60
|
-
exit 1
|
61
|
-
rescue ArgumentError => e
|
62
|
-
puts "Error: #{e}"
|
63
|
-
exit 1
|
64
|
-
end
|
65
|
-
|
66
13
|
def self.config options, network
|
67
14
|
config_file = options[:system] ? options[:system_config]: options[:local_config]
|
68
|
-
unless File.exists? config_file
|
69
|
-
config_file.gsub! /yml$/, "json"
|
70
|
-
end
|
71
15
|
|
72
|
-
raise ArgumentError.new "there's no config file located at: #{config_file
|
16
|
+
raise ArgumentError.new "there's no config file located at: #{config_file}" unless File.exists? config_file
|
73
17
|
raise ArgumentError.new "needs a network" if network.nil? or network.empty?
|
74
18
|
|
75
|
-
|
76
|
-
cfg = YAML.load_file config_file
|
77
|
-
else
|
78
|
-
require 'json'
|
79
|
-
puts "WARNING: the json config format has be deprecated in favour of YaML"
|
80
|
-
cfg = JSON.parse open(config_file, 'r').read()
|
81
|
-
end
|
19
|
+
cfg = YAML.load_file config_file
|
82
20
|
|
83
21
|
raise ArgumentError.new "there's no server config in the config file" unless cfg.has_key? "servers"
|
22
|
+
raise ArgumentError.new "there's no networks configured, please recheck #{config_file}" unless cfg["servers"]
|
84
23
|
raise ArgumentError.new "the config file doesn't contain a config for #{network}" unless cfg["servers"].has_key? network
|
85
24
|
|
86
25
|
ntw = cfg["servers"][network]
|
87
26
|
|
88
27
|
plugins = []
|
89
28
|
plugin_options = {}
|
90
|
-
|
29
|
+
|
30
|
+
ntw["plugins"] ||= []
|
91
31
|
ntw.delete("plugins").each do |plugin|
|
92
32
|
begin
|
93
|
-
raise LoadError.new "the module can't be null" if plugin["module"].nil?
|
94
33
|
raise NameError.new "the class can't be null" if plugin["class"].nil?
|
95
34
|
|
96
|
-
require plugin["
|
35
|
+
require plugin["class"].downcase.gsub('::', '/')
|
97
36
|
|
98
37
|
clazz = nil
|
99
38
|
plugin["class"].split("::").inject(Object) { |m,n| clazz = m.const_get(n) }
|
@@ -107,8 +46,6 @@ module Cinchize
|
|
107
46
|
end
|
108
47
|
end
|
109
48
|
|
110
|
-
raise ArgumentError.new "no plugins loaded" if plugins.size == 0
|
111
|
-
|
112
49
|
cfg["options"] ||= {}
|
113
50
|
dir_mode = cfg["options"].key?("dir_mode") ? cfg["options"]["dir_mode"] : "normal"
|
114
51
|
|
@@ -165,14 +102,14 @@ module Cinchize
|
|
165
102
|
app = daemon.new_application :mode => :none, :log_output => options[:log_output]
|
166
103
|
app.start
|
167
104
|
|
168
|
-
network = @network
|
105
|
+
network = @network.keys.inject({}) { |memo, key| memo[key.to_sym] = @network[key]; memo }
|
169
106
|
plugins = @plugins
|
170
107
|
plugin_options = @plugin_options
|
171
108
|
|
172
109
|
loop do
|
173
110
|
bot = Cinch::Bot.new do
|
174
111
|
configure do |c|
|
175
|
-
|
112
|
+
c.load network
|
176
113
|
|
177
114
|
c.plugins.plugins = plugins
|
178
115
|
c.plugins.options = plugin_options
|
@@ -192,7 +129,7 @@ module Cinchize
|
|
192
129
|
pidfile = Daemons::PidFile.new dir, app_name
|
193
130
|
puts "* stopping #{clean_app_name}"
|
194
131
|
|
195
|
-
Process.kill(
|
132
|
+
Process.kill("QUIT", pidfile.pid)
|
196
133
|
File.delete(pidfile.filename)
|
197
134
|
end
|
198
135
|
|
metadata
CHANGED
@@ -1,71 +1,59 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinchize
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 3
|
8
|
-
- 0
|
9
|
-
version: 0.3.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
-
|
7
|
+
authors:
|
8
|
+
- Victor Bergoo
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
name: cinch
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-03-27 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jeweler
|
16
|
+
requirement: &70130010159940 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: daemons
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: *70130010159940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cinch
|
27
|
+
requirement: &70130010157280 !ruby/object:Gem::Requirement
|
37
28
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.1
|
44
33
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: json
|
48
34
|
prerelease: false
|
49
|
-
|
35
|
+
version_requirements: *70130010157280
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: daemons
|
38
|
+
requirement: &70130010156080 !ruby/object:Gem::Requirement
|
50
39
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
- 0
|
56
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
57
44
|
type: :runtime
|
58
|
-
|
59
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70130010156080
|
47
|
+
description: Create dynamic Cinch IRC-bots and daemonize them, without the need of
|
48
|
+
writing any code
|
60
49
|
email: victor.bergoo@gmail.com
|
61
|
-
executables:
|
50
|
+
executables:
|
62
51
|
- cinchize
|
63
52
|
extensions: []
|
64
|
-
|
65
|
-
extra_rdoc_files:
|
53
|
+
extra_rdoc_files:
|
66
54
|
- LICENSE
|
67
55
|
- README.rdoc
|
68
|
-
files:
|
56
|
+
files:
|
69
57
|
- LICENSE
|
70
58
|
- README.rdoc
|
71
59
|
- Rakefile
|
@@ -74,37 +62,31 @@ files:
|
|
74
62
|
- cinchize.gemspec
|
75
63
|
- examples/cinchize.init
|
76
64
|
- lib/cinchize.rb
|
77
|
-
has_rdoc: true
|
78
65
|
homepage: http://github.com/netfeed/cinchize
|
79
66
|
licenses: []
|
80
|
-
|
81
67
|
post_install_message:
|
82
68
|
rdoc_options: []
|
83
|
-
|
84
|
-
require_paths:
|
69
|
+
require_paths:
|
85
70
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
72
|
none: false
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
segments:
|
92
78
|
- 0
|
93
|
-
|
94
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
hash: -4552393900521943504
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
81
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
|
100
|
-
- 0
|
101
|
-
version: "0"
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
102
86
|
requirements: []
|
103
|
-
|
104
87
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.8.10
|
106
89
|
signing_key:
|
107
90
|
specification_version: 3
|
108
91
|
summary: Create dynamic Cinch IRC-bots and daemonize them
|
109
92
|
test_files: []
|
110
|
-
|