cinchize 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/README.rdoc +31 -29
  2. data/VERSION +1 -1
  3. data/cinchize.gemspec +12 -14
  4. data/lib/cinchize.rb +17 -6
  5. metadata +5 -6
  6. data/.gitignore +0 -1
@@ -1,6 +1,8 @@
1
1
  = cinchize
2
2
 
3
- An early version of program which purpose is to daemonize Cinch ircbots from "simple" json config-files.
3
+ Cinchize scope is to easily get a daemonized irc-bot up and running using plugins where there shouldn't be any need to actually write code.
4
+
5
+ It should be noted that the program is currently considered to be in beta and may change both in how it's accessed and how the config logs is formed.
4
6
 
5
7
  == Installation
6
8
 
@@ -12,7 +14,7 @@ Basic
12
14
 
13
15
  cinchize --start network
14
16
 
15
- The config file can either be in the current working directory or in /etc, should be called cinchize.json, i.e. /etc/cinchize.json, use -s to look for the file in /etc
17
+ The config file can either be in the current working directory or in /etc and should be called cinchize.yml. Use the flag -s to tell cinchize to look for the config file at /etc/cinchize.yml.
16
18
 
17
19
  cinchize -s --start network
18
20
 
@@ -20,38 +22,38 @@ To daemonzize, use -d
20
22
 
21
23
  cinchize -d --start network
22
24
 
23
- Network is the name you call the a server config in the servers part of the config file, i.e. "freenode", "my_cute_bot", "quakenet" or similar.
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.
24
26
 
25
27
  --start, --restart, --stop and --status assumes that the config file is located in the current working directory unless -s is used.
26
28
 
27
29
  == Config-file
28
30
 
29
- All config options can be skipped and the bot will use the defaults, but it could always be nice to connect to a server that isn't localhost, right? Plugins can be skipped too, but then the bot wouldn't do anything other then just idle.
30
-
31
- {
32
- "options" : {
33
- "dir" : "/path/to/pid/dir",
34
- "dir_mode" : "normal",
35
- "log_output" : true
36
- },
37
- "servers" : {
38
- "freenode" : {
39
- "server" : "irc.freenode.net",
40
- "port" : 6667,
41
- "nick" : "Cinchbot",
42
- "channels" : ["#cinchbots"],
43
- "plugins" : [
44
- {
45
- "module" : "plugin-module",
46
- "class" : "Cinch::Plugins::User::SomePlugin",
47
- "options" : {
48
- "foo" : "bar"
49
- }
50
- }
51
- ]
52
- }
53
- }
54
- }
31
+ All config options to each server object is optional, except for the channels and plugins. All valid config options for a Cinch bot should work.
32
+
33
+ options:
34
+ log_output: true
35
+ dir_mode: normal
36
+ dir: "/path/to/pid/dir"
37
+ servers:
38
+ freenode:
39
+ server: irc.freenode.net
40
+ port: 6667
41
+ nick: CinchizeBot
42
+ channels:
43
+ - "#cinchbots"
44
+ plugins:
45
+ -
46
+ module: "cinch/plugins/some_plugin"
47
+ class: "Cinch::Plugins::SomePlugin"
48
+ options:
49
+ option: value
50
+ -
51
+ module: "cinch/plugins/another_plugin"
52
+ class: "Cinch::Plugins::AnotherPlugin"
53
+
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.
55
57
 
56
58
  === Options explained
57
59
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,36 +1,34 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cinchize}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Bergöö"]
12
- s.date = %q{2010-12-05}
12
+ s.date = %q{2011-02-26}
13
13
  s.default_executable = %q{cinchize}
14
14
  s.description = %q{Create dynamic Cinch IRC-bots and daemonize them, without the need of writing any code}
15
15
  s.email = %q{victor.bergoo@gmail.com}
16
16
  s.executables = ["cinchize"]
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.rdoc"
19
+ "README.rdoc"
20
20
  ]
21
21
  s.files = [
22
- ".gitignore",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/cinchize",
28
- "cinchize.gemspec",
29
- "examples/cinchize.init",
30
- "lib/cinchize.rb"
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/cinchize",
27
+ "cinchize.gemspec",
28
+ "examples/cinchize.init",
29
+ "lib/cinchize.rb"
31
30
  ]
32
31
  s.homepage = %q{http://github.com/netfeed/cinchize}
33
- s.rdoc_options = ["--charset=UTF-8"]
34
32
  s.require_paths = ["lib"]
35
33
  s.rubygems_version = %q{1.3.7}
36
34
  s.summary = %q{Create dynamic Cinch IRC-bots and daemonize them}
@@ -7,15 +7,15 @@ $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include? dir
7
7
 
8
8
  require 'cinch'
9
9
  require 'daemons'
10
- require 'json'
10
+ require 'yaml'
11
11
  require 'optparse'
12
12
 
13
13
  module Cinchize
14
14
  Options = {
15
15
  :ontop => true,
16
16
  :system => false,
17
- :local_config => File.join(Dir.pwd, 'cinchize.json'),
18
- :system_config => '/etc/cinchize.json',
17
+ :local_config => File.join(Dir.pwd, 'cinchize.yml'),
18
+ :system_config => '/etc/cinchize.yml',
19
19
  :action => nil,
20
20
  }
21
21
 
@@ -65,11 +65,20 @@ module Cinchize
65
65
 
66
66
  def self.config options, network
67
67
  config_file = options[:system] ? options[:system_config]: options[:local_config]
68
+ unless File.exists? config_file
69
+ config_file.gsub! /yml$/, "json"
70
+ end
68
71
 
69
- raise ArgumentError.new "the config file #{config_file} doesn't exist" unless File.exists? config_file
72
+ raise ArgumentError.new "there's no config file located at: #{config_file.gsub(/json$/, 'yml')}" unless File.exists? config_file
70
73
  raise ArgumentError.new "needs a network" if network.nil? or network.empty?
71
74
 
72
- cfg = JSON.parse File.open(config_file, "r").read()
75
+ if File.extname(config_file) == ".yml"
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
73
82
 
74
83
  raise ArgumentError.new "there's no server config in the config file" unless cfg.has_key? "servers"
75
84
  raise ArgumentError.new "the config file doesn't contain a config for #{network}" unless cfg["servers"].has_key? network
@@ -133,7 +142,7 @@ module Cinchize
133
142
  end
134
143
 
135
144
  def clean_app_name
136
- app_name.split('_').last
145
+ app_name.split('_', 2).last
137
146
  end
138
147
 
139
148
  def restart
@@ -199,6 +208,8 @@ module Cinchize
199
208
  pidfile = Daemons::PidFile.new dir, app_name
200
209
  return false if pidfile.pid.nil?
201
210
  return Process.kill(0, pidfile.pid) != 0
211
+ rescue Errno::ESRCH => e
212
+ return false
202
213
  end
203
214
  end
204
215
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Victor Berg\xC3\xB6\xC3\xB6"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-05 00:00:00 +01:00
17
+ date: 2011-02-26 00:00:00 +01:00
18
18
  default_executable: cinchize
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -66,7 +66,6 @@ extra_rdoc_files:
66
66
  - LICENSE
67
67
  - README.rdoc
68
68
  files:
69
- - .gitignore
70
69
  - LICENSE
71
70
  - README.rdoc
72
71
  - Rakefile
@@ -80,8 +79,8 @@ homepage: http://github.com/netfeed/cinchize
80
79
  licenses: []
81
80
 
82
81
  post_install_message:
83
- rdoc_options:
84
- - --charset=UTF-8
82
+ rdoc_options: []
83
+
85
84
  require_paths:
86
85
  - lib
87
86
  required_ruby_version: !ruby/object:Gem::Requirement
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- pkg