csd 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'rdoc'
3
4
 
4
5
  begin
5
6
  require 'jeweler'
@@ -11,12 +12,23 @@ begin
11
12
  gemspec.homepage = "http://github.com/csd/csd"
12
13
  gemspec.authors = ["Technology Transfer Alliance Team"]
13
14
  gemspec.add_dependency "term-ansicolor", ">= 0"
15
+ gemspec.add_dependency "active_record", ">= 0"
14
16
  gemspec.executables = ["csd"]
15
- gemspec.post_install_message = <<-END
16
- ========================================================================
17
- This is s test to see if ruby code is executed here. #{Gem.bindir}
18
- ========================================================================
19
- END
17
+ gemspec.post_install_message = %q{
18
+ ==============================================================================
19
+
20
+ Thank you for installing the Communication Systems Design Gem!
21
+
22
+ You can run it by just typing ´csd´ in your command line.
23
+
24
+ Note: On Debian and Ubuntu the executable ´csd´ is not in your PATH by default
25
+ You can fix this problem by creating a symlink with these two commands:
26
+
27
+ GEMBIN=$(gem env | grep "E D" | sed "s/[^\w]* //")
28
+ sudo ln -s "${GEMBIN}/csd" /usr/local/bin/csd
29
+
30
+ ==============================================================================
31
+ }
20
32
  end
21
33
  rescue LoadError
22
34
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.10
data/bin/csd CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems' # As a side note: Rubygems is already included for Ruby >= 1.9
4
- require 'csd'
4
+ #require 'csd'
5
5
 
6
- require File.join(File.dirname(__FILE__), '..', 'lib', 'csd') # For local development
6
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'csd')
7
7
 
8
- CSD::Loader.new
8
+ CSD::Init.new
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{csd}
8
- s.version = "0.0.8"
8
+ s.version = "0.0.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Technology Transfer Alliance Team"]
12
- s.date = %q{2010-06-11}
12
+ s.date = %q{2010-06-14}
13
13
  s.default_executable = %q{csd}
14
14
  s.description = %q{CSD stands for Communication Systems Design and is a project of the Telecommunication Systems Laboratory (TSLab) of the Royal Institute of Technology in Stockholm, Sweden. Within CSD many software tools are used to build up various networks and services. This gem is supposed to automate processes to handle the compilation and installation of these software tools. Technology Transfer Alliance (TTA) is the project team, which maintains this code.}
15
15
  s.email = %q{mtoday11@gmail.com}
@@ -27,20 +27,37 @@ Gem::Specification.new do |s|
27
27
  "VERSION",
28
28
  "bin/csd",
29
29
  "csd.gemspec",
30
- "lib/applications/minisip.rb",
31
30
  "lib/csd.rb",
32
- "lib/csd/installer.rb",
33
- "lib/csd/loader.rb",
34
- "lib/csd/shared.rb",
31
+ "lib/csd/applications/base.rb",
32
+ "lib/csd/applications/minisip/darwin/minisip_darwin.rb",
33
+ "lib/csd/applications/minisip/init.rb",
34
+ "lib/csd/applications/minisip/linux/minisip_linux.rb",
35
+ "lib/csd/applications/minisip/minisip.rb",
36
+ "lib/csd/init.rb",
37
+ "lib/csd/options.rb",
38
+ "lib/csd/path_struct.rb",
39
+ "lib/extensions/array.rb",
40
+ "lib/extensions/string.rb",
35
41
  "publish",
36
42
  "test/helper.rb",
37
43
  "test/test_csd.rb"
38
44
  ]
39
45
  s.homepage = %q{http://github.com/csd/csd}
40
- s.post_install_message = %q{ ========================================================================
41
- This is s test to see if ruby code is executed here. /usr/bin
42
- ========================================================================
43
- }
46
+ s.post_install_message = %q{
47
+ ==============================================================================
48
+
49
+ Thank you for installing the Communication Systems Design Gem!
50
+
51
+ You can run it by just typing ´csd´ in your command line.
52
+
53
+ Note: On Debian and Ubuntu the executable ´csd´ is not in your PATH by default
54
+ You can fix this problem by creating a symlink with these two commands:
55
+
56
+ GEMBIN=$(gem env | grep "E D" | sed "s/[^\w]* //")
57
+ sudo ln -s "${GEMBIN}/csd" /usr/local/bin/csd
58
+
59
+ ==============================================================================
60
+ }
44
61
  s.rdoc_options = ["--charset=UTF-8"]
45
62
  s.require_paths = ["lib"]
46
63
  s.rubygems_version = %q{1.3.7}
@@ -56,11 +73,14 @@ Gem::Specification.new do |s|
56
73
 
57
74
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
75
  s.add_runtime_dependency(%q<term-ansicolor>, [">= 0"])
76
+ s.add_runtime_dependency(%q<active_record>, [">= 0"])
59
77
  else
60
78
  s.add_dependency(%q<term-ansicolor>, [">= 0"])
79
+ s.add_dependency(%q<active_record>, [">= 0"])
61
80
  end
62
81
  else
63
82
  s.add_dependency(%q<term-ansicolor>, [">= 0"])
83
+ s.add_dependency(%q<active_record>, [">= 0"])
64
84
  end
65
85
  end
66
86
 
data/lib/csd.rb CHANGED
@@ -1 +1,2 @@
1
- require File.join(File.dirname(__FILE__), 'csd', 'loader')
1
+ Dir.glob(File.join(File.dirname(__FILE__), 'extensions', '*.rb')) { |file| require file }
2
+ require File.join(File.dirname(__FILE__), 'csd', 'init')
@@ -0,0 +1,54 @@
1
+ require 'rbconfig'
2
+
3
+ module CSD
4
+ module Application
5
+
6
+ # This is the root parent of all Applications
7
+ #
8
+ class Base
9
+
10
+ include Gem::UserInteraction
11
+
12
+ attr_reader :gem_version, :options
13
+ attr_accessor :path
14
+
15
+ def initialize(options={})
16
+ @gem_version = options[:gem_version]
17
+ @options = options[:options]
18
+ @path = options[:path]
19
+ self
20
+ end
21
+
22
+ def introduction
23
+ say "CSD Gem Version: #{gem_version}"
24
+ say
25
+ say "The working directory is:"
26
+ say path.root
27
+ end
28
+
29
+ def test_command(*args)
30
+ say "Testing command for success: #{args.join(' ')}".cyan
31
+ system(*args)
32
+ end
33
+
34
+ def run_command(cmd)
35
+ log "Running command: #{cmd} in #{Dir.pwd}".magenta
36
+ ret = ''
37
+ unless options.dry
38
+ IO.popen(cmd) do |stdout|
39
+ stdout.each do |line|
40
+ say line
41
+ ret << line
42
+ end
43
+ end
44
+ end
45
+ ret
46
+ end
47
+
48
+ def log(msg="")
49
+ say msg.yellow unless options.silent
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'minisip')
2
+
3
+ module CSD
4
+ module Application
5
+ module Minisip
6
+ class MinisipDarwin < Minisip
7
+
8
+
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__), 'minisip')
2
+ Dir.glob(File.join(File.dirname(__FILE__), '**', '*.rb')) { |file| require file }
3
+
4
+ module CSD
5
+ module Application
6
+ module Minisip
7
+ class Init
8
+
9
+ def self.application(*args)
10
+ case Gem::Platform.local
11
+ when 'linux'
12
+ MinisipLinux.new(*args)
13
+ when 'darwin'
14
+ MinisipDarwin.new(*args)
15
+ else
16
+ Minisip.new(*args)
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'minisip')
2
+
3
+ module CSD
4
+ module Application
5
+ module Minisip
6
+ class MinisipLinux < Minisip
7
+
8
+ def build!
9
+ define_paths
10
+ create_working_dir
11
+ install_aptitude_dependencies
12
+ checkout_repository
13
+ fix_aclocal_dirlist
14
+ ldconfig_and_gtkgui
15
+ make_libraries
16
+ end
17
+
18
+ def install_aptitude_dependencies
19
+ ['git-core', 'subversion', 'automake', 'libssl-dev', 'libtool', 'libglademm-2.4-dev'].each do |apt|
20
+ run_command("sudo apt-get --yes install #{apt}")
21
+ end
22
+ end
23
+
24
+ def fix_aclocal_dirlist
25
+ run_command "sudo echo /usr/local/share/aclocal >> /usr/share/aclocal/dirlist"
26
+ end
27
+
28
+ def ldconfig_and_gtkgui
29
+ run_command("ldconfig /usr/local/lib/libminisip.so.0")
30
+ run_command("minisip_gtkgui")
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,75 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'base')
2
+
3
+ module CSD
4
+ module Application
5
+ module Minisip
6
+ class Minisip < CSD::Application::Base
7
+
8
+ def introduction
9
+ super
10
+ log
11
+ log "Hello, I'm the application #{self.class.name}"
12
+ exit unless ask_yes_no("Continue?", true)
13
+ build!
14
+ end
15
+
16
+ def build!
17
+ define_paths
18
+ create_working_dir
19
+ checkout_repository
20
+ make_libraries
21
+ end
22
+
23
+ def define_paths
24
+ path.work = File.expand_path(File.join(path.root, 'minisip_building'))
25
+ path.repository = File.expand_path(File.join(path.work, 'repository'))
26
+ end
27
+
28
+ def create_working_dir
29
+ if File.directory?(path.work)
30
+ log "Working directory ´#{path.work}´ already exists."
31
+ else
32
+ log "Creating working directory ´#{path.work}´"
33
+ Dir.mkdir(path.work)
34
+ end
35
+ Dir.chdir(path.work)
36
+ end
37
+
38
+ def checkout_repository
39
+ if File.directory?(path.repository)
40
+ log "The minisip repository already exists in ´#{path.repository}´"
41
+ else
42
+ log "Checking out minisip repository to ´#{path.repository}´"
43
+ #run_command("git clone http://github.com/csd/minisip.git repository")
44
+ if test_command('svn', 'info', 'svn://minisip.org/minisip/trunk')
45
+ run_command("svn co svn://minisip.org/minisip/trunk #{path.repository}")
46
+ else
47
+ log "Sorry, something is wrong with subversion.".red.bold
48
+ exit
49
+ end
50
+ end
51
+ end
52
+
53
+ def make_libraries
54
+ ['libmutil', 'libmnetutil', 'libmcrypto', 'libmikey', 'libmsip', 'libmstun', 'libminisip'].each do |lib|
55
+ lib_dir = File.join(path.repository, lib)
56
+ if File.directory?(lib_dir)
57
+ Dir.chdir(lib_dir)
58
+ log "Bootstrapping #{lib}".green.bold
59
+ run_command("./bootstrap")
60
+ log "Configuring #{lib}".green.bold
61
+ run_command("./configure")
62
+ log "Make #{lib}".green.bold
63
+ run_command("make")
64
+ log "Make install #{lib}".green.bold
65
+ #run_command("make install")
66
+ else
67
+ log "Skipping ´#{lib}´ because ´#{lib_dir}´ could not be found".red.bold
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,64 @@
1
+ # Include all files in the same directory
2
+ Dir.glob(File.join(File.dirname(__FILE__), '*.rb')) { |file| require file }
3
+ require File.join(File.dirname(__FILE__), 'applications', 'base')
4
+
5
+ require 'ostruct'
6
+ require 'tmpdir'
7
+ require 'active_support/core_ext'
8
+
9
+ module CSD
10
+ class Init
11
+
12
+ include Gem::UserInteraction
13
+
14
+ attr_reader :gem_version, :options, :path, :application
15
+
16
+ def initialize
17
+ @options = Options.parse
18
+ @path = path_struct
19
+ @gem_version = File.new(File.join(path.gem_root, 'VERSION')).read
20
+ validate_arguments
21
+ @application = initialize_application
22
+ @application.introduction
23
+ self
24
+ end
25
+
26
+ def path_struct
27
+ path = PathStruct.new
28
+ if options.path
29
+ if File.directory?(options.path)
30
+ path.root = File.expand_path(options.path)
31
+ else
32
+ say "The path ´#{options.path}´ doesn't exist."
33
+ exit
34
+ end
35
+ else
36
+ path.root = options.temp ? Dir.mktmpdir : Dir.pwd
37
+ end
38
+ path
39
+ end
40
+
41
+ def validate_arguments
42
+ case ARGV.size
43
+ when 0
44
+ say "Please specify an action."
45
+ exit
46
+ when 1
47
+ say "Please specify an application."
48
+ exit
49
+ end
50
+ end
51
+
52
+ def initialize_application
53
+ directory_name = ARGV.second.underscore
54
+ begin
55
+ require File.join(File.join(path.applications, "#{directory_name}"), 'init.rb')
56
+ "CSD::Application::#{directory_name.camelize}::Init".constantize.application(:gem_version => @gem_version, :options => @options, :path => @path)
57
+ rescue LoadError
58
+ say "Unknown application: #{directory_name}"
59
+ exit
60
+ end
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,64 @@
1
+ require 'optparse'
2
+ require 'optparse/time'
3
+ require 'ostruct'
4
+
5
+ module CSD
6
+ class Options
7
+
8
+ #
9
+ # Returns a structure describing the options.
10
+ #
11
+ def self.parse
12
+ # Default options
13
+ options = OpenStruct.new
14
+ options.temp = false
15
+ options.silent = false
16
+ options.dry = false
17
+
18
+ # Parse the command line options
19
+ OptionParser.new do |opts|
20
+ opts.banner = "Usage: csd [action] [application] [options]"
21
+ opts.separator ""
22
+ opts.separator "Actions:"
23
+ opts.separator " install"
24
+ opts.separator ""
25
+ opts.separator "Applications:"
26
+ opts.separator " minisip"
27
+ opts.separator ""
28
+ opts.separator "Options:"
29
+
30
+ opts.on("-t", "--temp",
31
+ "Use a subdirectory in the system's temporary directory",
32
+ "to download files and not the current directory") do |value|
33
+ options.temp = value
34
+ end
35
+
36
+ opts.on("-d", "--dry","Don't execute any commands, just show them") do |value|
37
+ options.dry = value
38
+ end
39
+
40
+ opts.on("-p", "--path [PATH]",
41
+ "Defines the working directory manually.",
42
+ "(This will override the --temp option)") do |value|
43
+ options.path = value
44
+ end
45
+
46
+ opts.on("-s", "--silent","Don't show any output") do |value|
47
+ options.silent = value
48
+ end
49
+
50
+ opts.on_tail("-h", "--help", "Show this message") do
51
+ puts opts
52
+ exit
53
+ end
54
+
55
+ opts.on_tail("-v", "--version", "Show version") do
56
+ puts "CSD Gem Version: #{CSD::Init::GEM_VERSION}"
57
+ exit
58
+ end
59
+ end.parse!
60
+ options
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,15 @@
1
+ require 'ostruct'
2
+
3
+ module CSD
4
+ class PathStruct < OpenStruct
5
+
6
+ def gem_root
7
+ File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
8
+ end
9
+
10
+ def applications
11
+ File.expand_path(File.join(gem_root, 'lib', 'csd', 'applications'))
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module ArrayExtensions
2
+
3
+ end
4
+
5
+ class Array #:nodoc:
6
+ include ArrayExtensions
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'term/ansicolor'
2
+ #require 'active_support'
3
+
4
+ module StringExtensions
5
+
6
+ #def constantize
7
+ # ActiveSupport::Inflector.constantize(self)
8
+ #end
9
+
10
+ end
11
+
12
+ class String #:nodoc:
13
+ include Term::ANSIColor
14
+ include StringExtensions
15
+ end
data/publish CHANGED
@@ -5,12 +5,25 @@ unless ARGV.is_a?(Array) and ARGV.size > 0
5
5
  exit
6
6
  end
7
7
 
8
- `git status`
9
- `git add .`
10
- `git add -u`
11
- `git commit -m "#{ARGV.first}"`
12
-
13
- `rake version:bump:patch`
14
- `rake release`
15
- `rake build`
8
+ def run_command(cmd)
9
+ puts "================"
10
+ puts "Running command: #{cmd}"
11
+ puts "================"
12
+ ret = ''
13
+ IO.popen(cmd) do |stdout|
14
+ stdout.each do |line|
15
+ puts line
16
+ ret << line
17
+ end
18
+ end
19
+ ret
20
+ end
16
21
 
22
+ [ 'git status',
23
+ 'git add .',
24
+ 'git add -u',
25
+ 'git commit -m "#{ARGV.first}"',
26
+ 'rake version:bump:patch',
27
+ 'rake release',
28
+ 'rake build'
29
+ ].each { |cmd| run_command(cmd) }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csd
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Technology Transfer Alliance Team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-11 00:00:00 +02:00
18
+ date: 2010-06-14 00:00:00 +02:00
19
19
  default_executable: csd
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,20 @@ dependencies:
32
32
  version: "0"
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: active_record
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
35
49
  description: CSD stands for Communication Systems Design and is a project of the Telecommunication Systems Laboratory (TSLab) of the Royal Institute of Technology in Stockholm, Sweden. Within CSD many software tools are used to build up various networks and services. This gem is supposed to automate processes to handle the compilation and installation of these software tools. Technology Transfer Alliance (TTA) is the project team, which maintains this code.
36
50
  email: mtoday11@gmail.com
37
51
  executables:
@@ -50,11 +64,17 @@ files:
50
64
  - VERSION
51
65
  - bin/csd
52
66
  - csd.gemspec
53
- - lib/applications/minisip.rb
54
67
  - lib/csd.rb
55
- - lib/csd/installer.rb
56
- - lib/csd/loader.rb
57
- - lib/csd/shared.rb
68
+ - lib/csd/applications/base.rb
69
+ - lib/csd/applications/minisip/darwin/minisip_darwin.rb
70
+ - lib/csd/applications/minisip/init.rb
71
+ - lib/csd/applications/minisip/linux/minisip_linux.rb
72
+ - lib/csd/applications/minisip/minisip.rb
73
+ - lib/csd/init.rb
74
+ - lib/csd/options.rb
75
+ - lib/csd/path_struct.rb
76
+ - lib/extensions/array.rb
77
+ - lib/extensions/string.rb
58
78
  - publish
59
79
  - test/helper.rb
60
80
  - test/test_csd.rb
@@ -62,7 +82,7 @@ has_rdoc: true
62
82
  homepage: http://github.com/csd/csd
63
83
  licenses: []
64
84
 
65
- post_install_message: " ========================================================================\n This is s test to see if ruby code is executed here. /usr/bin\n ========================================================================\n"
85
+ post_install_message: "\n ==============================================================================\n\n Thank you for installing the Communication Systems Design Gem!\n \n You can run it by just typing \xC2\xB4csd\xC2\xB4 in your command line.\n \n Note: On Debian and Ubuntu the executable \xC2\xB4csd\xC2\xB4 is not in your PATH by default\n You can fix this problem by creating a symlink with these two commands:\n \n GEMBIN=$(gem env | grep \"E D\" | sed \"s/[^\\w]* //\")\n sudo ln -s \"${GEMBIN}/csd\" /usr/local/bin/csd\n \n ==============================================================================\n "
66
86
  rdoc_options:
67
87
  - --charset=UTF-8
68
88
  require_paths:
@@ -1,55 +0,0 @@
1
- module CSD
2
- class Minisip
3
-
4
- include Shared
5
-
6
- def initialize(options={})
7
- @options = options[:options]
8
-
9
- unless Gem::Platform.local.os == 'linux'
10
- puts "Sorry, Linux only at the moment"
11
- exit 1
12
- end
13
-
14
- unless File.directory?('minisip')
15
- log "Creating directory minisip"
16
- Dir.mkdir('minisip')
17
- end
18
-
19
- Dir.chdir('minisip')
20
- root_dir = Dir.pwd
21
-
22
- ['git-core', 'subversion', 'automake', 'libssl-dev', 'libtool', 'libglademm-2.4-dev'].each do |apt|
23
- run_command("sudo apt-get --yes install #{apt}")
24
- end
25
-
26
- unless File.directory?('repository')
27
- log "Checking out minisip repository"
28
- checkout_repository
29
- end
30
-
31
- run_command "sudo echo /usr/local/share/aclocal >> /usr/share/aclocal/dirlist"
32
-
33
- ['libmutil', 'libmnetutil', 'libmcrypto', 'libmikey', 'libmsip', 'libmstun', 'libminisip'].each do |lib|
34
- Dir.chdir File.join(root_dir, 'repository', lib)
35
- log "Going through #{Dir.pwd}"
36
- run_command("./bootstrap")
37
- run_command("./configure")
38
- run_command("make")
39
- run_command("make install")
40
- end
41
-
42
- run_command("ldconfig /usr/local/lib/libminisip.so.0")
43
- run_command("minisip_gtkgui")
44
-
45
- end
46
-
47
- def checkout_repository
48
- #run_command("git clone http://github.com/csd/minisip.git repository")
49
- run_command("svn co svn://minisip.org/minisip/trunk repository")
50
- end
51
-
52
- end
53
-
54
-
55
- end
@@ -1,23 +0,0 @@
1
- module CSD
2
- class Installer
3
-
4
- def initialize(options={})
5
- @options = options[:options]
6
- @actions = options[:actions]
7
-
8
- case @actions.first
9
- when 'minisip'
10
- Minisip.new :options => @options
11
- else
12
- p "Unknown application: #{@actions.first}"
13
- end
14
-
15
-
16
- self
17
- end
18
-
19
-
20
-
21
-
22
- end
23
- end
@@ -1,47 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'shared')
2
- require File.join(File.dirname(__FILE__), 'installer')
3
- require File.join(File.dirname(__FILE__), '..', 'apps', 'minisip')
4
-
5
- require 'optparse'
6
- require 'term/ansicolor'
7
-
8
- module CSD
9
- class Loader
10
-
11
- include Gem::UserInteraction
12
-
13
- def initialize
14
- @options = {}
15
- @actions = ARGV
16
- OptionParser.new do |opts|
17
- opts.banner = "Usage: csd [options]"
18
- opts.on("-s", "--silent", "Don't run verbosely") do |v|
19
- @options[:verbose] = !v
20
- end
21
- end.parse!
22
-
23
- introduction
24
-
25
- case @actions.shift
26
- when 'install'
27
- Installer.new :options => @options, :actions => @actions
28
- else
29
- puts "Unknown action, try 'csd install'"
30
- end
31
- self
32
- end
33
-
34
- def introduction
35
- puts
36
- puts "The current working directory is:"
37
- puts Dir.pwd
38
- puts
39
- exit unless ask_yes_no("Continue?", true)
40
- end
41
-
42
- end
43
- end
44
-
45
- class String
46
- include Term::ANSIColor
47
- end
@@ -1,26 +0,0 @@
1
- require 'term/ansicolor'
2
- require 'rbconfig'
3
-
4
- module CSD
5
- module Shared
6
-
7
- include Term::ANSIColor
8
-
9
- def run_command(cmd)
10
- log "Running command: #{cmd} in #{Dir.pwd}".green.bold
11
- ret = ''
12
- IO.popen(cmd) do |stdout|
13
- stdout.each do |line|
14
- log line
15
- ret << line
16
- end
17
- end
18
- ret
19
- end
20
-
21
- def log(msg)
22
- puts msg if @options[:verbose]
23
- end
24
-
25
- end
26
- end