txpadmin 0.0.1

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/README.markdown ADDED
@@ -0,0 +1,5 @@
1
+ README
2
+ ======
3
+
4
+ Txpadmin is a script to handle textpattern instances.
5
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'rubygems'
2
+ require 'rake'
data/bin/txpadmin ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'txp_admin'
4
+ require 'optparse'
5
+ # require 'optparse/time'
6
+ require 'pp'
7
+
8
+ # http://rubyforge.org/docman/view.php/632/170/index.html
9
+
10
+ include TxpAdmin
11
+
12
+ options = {}
13
+
14
+ op = OptionParser.new do |opts|
15
+ opts.banner = "Usage: "
16
+
17
+ opts.on("-h", "--help", "Print this message") do |v|
18
+ puts opts
19
+ exit
20
+ end
21
+
22
+ opts.on("-V", "--version", "Print version") do |v|
23
+ puts "TxpAdmin gem version #{Gem.searcher.find('txp_admin').version.to_s}"
24
+ exit
25
+ end
26
+
27
+ opts.on(nil, "--console", "Connect to mysql database") do |v|
28
+ config = TxpAdmin::Config.new.options
29
+ password = config[:pass].strip != "" ? " -p#{config[:pass]}" : ""
30
+
31
+ # FIXME: how do a mysql alias evaluated in exec?
32
+ # Example: mysql='mysql --socket=/Applications/xampp/xamppfiles/var/mysql/mysql.sock'
33
+ config[:host] = config[:host] == "localhost" ? "127.0.0.1" : config[:host]
34
+
35
+ commandline = "mysql -u#{config[:user]} #{password} -h#{config[:host]} #{config[:db]}"
36
+ puts "executing command: #{commandline}"
37
+ exec(commandline)
38
+ exit
39
+ end
40
+
41
+ opts.on(nil, "--config", "Print txp configuration") do |v|
42
+ begin
43
+ config = `cat textpattern/config.php`
44
+ rescue => e
45
+ puts "Not a textpattern directory"
46
+ exit
47
+ end
48
+ end
49
+
50
+ end
51
+
52
+ args = ARGV
53
+ args = ["-h"] if ARGV.size == 0
54
+
55
+ begin
56
+ op.parse(args)
57
+ rescue OptionParser::AmbiguousOption => e
58
+ op.parse(["-h"])
59
+ rescue TxpAdmin::ConfigNotFound => e
60
+ puts "Config file not found"
61
+ end
62
+
63
+
64
+
65
+
data/lib/txp_admin.rb ADDED
@@ -0,0 +1,38 @@
1
+ module TxpAdmin
2
+
3
+ class ConfigNotFound < Exception
4
+ end
5
+
6
+
7
+
8
+ class Config
9
+
10
+ attr_accessor :options
11
+
12
+ def initialize
13
+ @options = self.class.parse_config_file
14
+ end
15
+
16
+ def self.parse_config_file(path=".")
17
+
18
+ config_file = "#{path}/textpattern/config.php"
19
+ raise TxpAdmin::ConfigNotFound unless File.exists?(config_file)
20
+ config = `cat #{config_file}`
21
+ txpcfg = {}
22
+ config.gsub!("<?php", "")
23
+ config.gsub!("?>", "")
24
+ config.gsub!("$txpcfg", "txpcfg")
25
+ eval(config)
26
+
27
+ txpcfg.each do |key,value|
28
+ txpcfg[key.to_sym] = value
29
+ end
30
+
31
+
32
+ # puts txpcfg.inspect
33
+ return txpcfg
34
+ end
35
+
36
+ end
37
+
38
+ end
data/txpadmin.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{txpadmin}
5
+ s.version = "0.0.1"
6
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.3") if s.respond_to? :required_rubygems_version=
7
+ s.authors = ["Fabrizio Regini"]
8
+ s.date = %q{2009-12-26}
9
+ s.default_executable = %q{rg}
10
+ s.description = %q{Textpattern admin tool.}
11
+ s.email = %q{freegenie@gmail.com}
12
+ s.executables = ["txpadmin"]
13
+ s.extra_rdoc_files = [
14
+ "README.markdown"
15
+ ]
16
+ s.files = [
17
+ "README.markdown",
18
+ "Rakefile",
19
+ "bin/txpadmin",
20
+ "lib/txp_admin.rb",
21
+ "Rakefile",
22
+ "txpadmin.gemspec"
23
+ ]
24
+ s.homepage = %q{http://github.com/freegenie/txpadmin}
25
+ s.rdoc_options = ["--charset=UTF-8"]
26
+ s.require_paths = ["lib"]
27
+ s.rubygems_version = %q{1.3.5}
28
+ s.summary = %q{Txpadmin helps textpattern management from command line.}
29
+
30
+ if s.respond_to? :specification_version then
31
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
32
+ s.specification_version = 3
33
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
34
+ else
35
+ end
36
+ else
37
+ end
38
+ end
39
+
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: txpadmin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Fabrizio Regini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-26 00:00:00 +01:00
13
+ default_executable: rg
14
+ dependencies: []
15
+
16
+ description: Textpattern admin tool.
17
+ email: freegenie@gmail.com
18
+ executables:
19
+ - txpadmin
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.markdown
24
+ files:
25
+ - README.markdown
26
+ - Rakefile
27
+ - bin/txpadmin
28
+ - lib/txp_admin.rb
29
+ - txpadmin.gemspec
30
+ has_rdoc: true
31
+ homepage: http://github.com/freegenie/txpadmin
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options:
36
+ - --charset=UTF-8
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "1.3"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.3.5
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Txpadmin helps textpattern management from command line.
58
+ test_files: []
59
+