upstart-exporter 0.0.1 → 0.0.2

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/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ *.sw?
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.8.7-p352
data/bin/upstart-export CHANGED
@@ -3,8 +3,10 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib/'))
3
3
 
4
4
  require 'upstart-exporter'
5
5
  require 'optparse'
6
+ require 'fileutils'
7
+ require 'yaml'
6
8
 
7
- USAGE = "Usage: upstart-export -p PROCFILE -n APPNAME"
9
+ USAGE = "Usage: upstart-export -p PROCFILE -n APPNAME\nor upstart-export -c -n APPNAME "
8
10
  options = {}
9
11
 
10
12
  OptionParser.new do |opts|
@@ -17,13 +19,20 @@ OptionParser.new do |opts|
17
19
  options[:app_name] = n
18
20
  end
19
21
 
22
+ opts.on("-c", "--clear", "Remove application scripts") do |n|
23
+ options[:clear] = true
24
+ end
20
25
  end.parse!
21
26
 
22
- abort(USAGE) unless options[:procfile] && options[:app_name]
27
+ abort(USAGE) if !options[:app_name] || (!options[:procfile] && !options[:clear]) || (options[:procfile] && options[:clear])
23
28
 
24
29
 
25
30
  begin
26
- Upstart::Exporter.new(options).export
31
+ if options[:clear]
32
+ Upstart::Exporter.new(options).clear
33
+ else
34
+ Upstart::Exporter.new(options).export
35
+ end
27
36
  rescue Upstart::ExportError => e
28
37
  abort(e.to_s)
29
38
  end
@@ -1,5 +1,5 @@
1
1
  module Upstart
2
2
  class Exporter
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -40,24 +40,29 @@ module Upstart
40
40
  end
41
41
 
42
42
  def process_opts(options)
43
- process_procfile(options[:procfile])
43
+ @commands = if options[:clear]
44
+ {}
45
+ else
46
+ process_procfile(options[:procfile])
47
+ end
44
48
  process_appname(options[:app_name])
45
49
  end
46
50
 
47
51
  def process_procfile(name)
48
52
  error "#{name} is not a readable file" unless FileTest.file?(name)
49
- @commands = {}
53
+ commands = {}
50
54
  content = File.read(name)
51
55
  content.lines.each do |line|
52
56
  line.chomp!
53
57
  if line =~ /^(\w+?):(.*)$/
54
58
  label = $1
55
59
  command = $2
56
- @commands[label] = command
60
+ commands[label] = command
57
61
  else
58
62
  error "procfile lines should have the following format: 'some_label: command'"
59
63
  end
60
64
  end
65
+ commands
61
66
  end
62
67
 
63
68
  def process_appname(app_name)
@@ -68,14 +73,6 @@ module Upstart
68
73
  def check_dir(dir)
69
74
  FileUtils.mkdir_p(dir) unless FileTest.directory?(dir)
70
75
  error "Path #{dir} does not exist" unless FileTest.directory?(dir)
71
- elements = [''] + dir.split('/').select{|el| !el.empty?}
72
- path = ''
73
- elements.each do |el|
74
- path += (el + '/')
75
- if FileTest.world_writable?(path)
76
- error "Path #{path} (in #{dir}) is writable by others"
77
- end
78
- end
79
76
  end
80
77
 
81
78
  def export
@@ -16,4 +16,6 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
+ s.add_development_dependency("rake")
20
+ s.add_development_dependency("rspec")
19
21
  end
metadata CHANGED
@@ -1,53 +1,100 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: upstart-exporter
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Ilya Averyanov
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2011-12-08 00:00:00.000000000Z
13
- dependencies: []
17
+
18
+ date: 2011-12-09 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :development
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ version_requirements: *id001
33
+ name: rake
34
+ - !ruby/object:Gem::Dependency
35
+ type: :development
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ version_requirements: *id002
47
+ name: rspec
14
48
  description: Gem for converting Procfile-like files to upstart scripts
15
- email:
49
+ email:
16
50
  - ilya@averyanov.org
17
- executables:
51
+ executables:
18
52
  - upstart-export
19
53
  extensions: []
54
+
20
55
  extra_rdoc_files: []
21
- files:
56
+
57
+ files:
22
58
  - .gitignore
59
+ - .rbenv-version
23
60
  - Gemfile
24
61
  - Rakefile
25
62
  - bin/upstart-export
26
63
  - lib/upstart-exporter.rb
27
64
  - lib/upstart-exporter/version.rb
28
65
  - upstart-exporter.gemspec
29
- homepage: ''
66
+ homepage: ""
30
67
  licenses: []
68
+
31
69
  post_install_message:
32
70
  rdoc_options: []
33
- require_paths:
71
+
72
+ require_paths:
34
73
  - lib
35
- required_ruby_version: !ruby/object:Gem::Requirement
74
+ required_ruby_version: !ruby/object:Gem::Requirement
36
75
  none: false
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
84
  none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
47
92
  requirements: []
93
+
48
94
  rubyforge_project:
49
95
  rubygems_version: 1.8.10
50
96
  signing_key:
51
97
  specification_version: 3
52
98
  summary: Gem for converting Procfile-like files to upstart scripts
53
99
  test_files: []
100
+