{':/Upstart::Exporter#export_cmd_upstart_confso:$YARD::CodeObjects::MethodObject: @path"/Upstart::Exporter#export_cmd_upstart_confs:@visibility: public:@signature"+def export_cmd_upstart_confs(cmd_name):@source_type: ruby: @dynamicT: @scope: instance: @source"def export_cmd_upstart_confs(cmd_name) cmd_upstart_conf_content = COMMAND_TPL % [@app_name, @app_name] File.open(upstart_cmd_conf(cmd_name), 'w') do |f| f.write(cmd_upstart_conf_content) end cmd_upstart_conf_content_real = COMMAND_REAL_TPL % [app_cmd(cmd_name), app_cmd(cmd_name), @run_user, helper_cmd_conf(cmd_name), @app_name, cmd_name] File.open(upstart_cmd_conf(cmd_name + '-real'), 'w') do |f| f.write(cmd_upstart_conf_content_real) end end:@current_file_has_commentsF:@docstringIC:YARD::Docstring" : @object@:@hash_flagF: @summary0: @all": @tags[:@ref_tags[;[: @files[["lib/upstart-exporter.rbi:@parameters[[" cmd_name0: @name:export_cmd_upstart_confs:@explicitT:@namespaceo:#YARD::CodeObjects::ClassObject;"Upstart::Exporter;; : @aliases{; ; ; T: @groups[:@instance_mixinsIC:&YARD::CodeObjects::CodeObjectList[: @owner@:@superclasso:YARD::CodeObjects::Proxy : @imethod0:@origname0:@orignamespace0: @obj0;: Object;o:"YARD::CodeObjects::RootObject;";; ;!{; ; ;"[;#IC;$[;%@;F;IC;" ;@;F;0;";[;[;[:@class_mixinsIC;$[;%@:@attributesIC:SymbolHash{;IC;0{:@symbolize_valueT: classIC;0{;1T;1T;[;: root:@childrenIC;$[o:$YARD::CodeObjects::ModuleObject;" Upstart;; ;!{; ; ;"[;#IC;$[;%@+;F;IC;" ;@+;F;0;";[;[;[;.IC;$[;%@+;/IC;0{;IC;0{;1T;2IC;0{;1T;1T;[[@i["$lib/upstart-exporter/version.rbi;: Upstart;4IC;$[o; ;"Upstart::ExportError;; ;!{; ; ; T;"[;#IC;$[;%@>;&o;' ;(0;)0;*0;+0;:RuntimeError;@+;F;IC;" ;@>;F;0;";[;[;[;.IC;$[;%@>;/IC;0{;IC;0{;1T;2IC;0{;1T;1T;[[@i ;:ExportError;4IC;$[;%@>;@+@;%@+;@;%@;0;F;IC;" ;@;F;0;";[;[;[;.IC;$[;%@;/IC;0{;IC;0{:helper_dirIC;0{: writeo;;""Upstart::Exporter#helper_dir=;; ; "def helper_dir=(value); ; ; T:@docstring_extra0;;;"5def helper_dir=(value) @helper_dir = value end;F;IC;""Sets the attribute helper_dir ;@Y;F;0;"]Sets the attribute helper_dir @param value the value to set the attribute helper_dir to.;[o:YARD::Tags::Tag ;@Y:@tag_name" param: @types0;" value: @text"2the value to set the attribute helper_dir to.;[;[;[[@i;[[" value0;:helper_dir=;@: reado;;"!Upstart::Exporter#helper_dir;; ; "def helper_dir; ; ; T;;0;;;"%def helper_dir @helper_dir end;F;IC;".Returns the value of attribute helper_dir ;@k;F;0;".Returns the value of attribute helper_dir;[;[;[;[[@i;[;;9;@;1T:upstart_dirIC;0{;:o;;"#Upstart::Exporter#upstart_dir=;; ; "def upstart_dir=(value); ; ; T;;0;;;"7def upstart_dir=(value) @upstart_dir = value end;F;IC;"#Sets the attribute upstart_dir ;@x;F;0;"_Sets the attribute upstart_dir @param value the value to set the attribute upstart_dir to.;[o;< ;@x;=" param;>0;" value;?"3the value to set the attribute upstart_dir to.;[;[;[[@i;[[" value0;:upstart_dir=;@;Ao;;""Upstart::Exporter#upstart_dir;; ; "def upstart_dir; ; ; T;;0;;;"'def upstart_dir @upstart_dir end;F;IC;"/Returns the value of attribute upstart_dir ;@;F;0;"/Returns the value of attribute upstart_dir;[;[;[;[[@i;[;;B;@;1T: run_userIC;0{;:o;;" Upstart::Exporter#run_user=;; ; "def run_user=(value); ; ; T;;0;;;"1def run_user=(value) @run_user = value end;F;IC;" Sets the attribute run_user ;@;F;0;"YSets the attribute run_user @param value the value to set the attribute run_user to.;[o;< ;@;=" param;>0;" value;?"0the value to set the attribute run_user to.;[;[;[[@i;[[" value0;:run_user=;@;Ao;;"Upstart::Exporter#run_user;; ; "def run_user; ; ; T;;0;;;"!def run_user @run_user end;F;IC;",Returns the value of attribute run_user ;@;F;0;",Returns the value of attribute run_user;[;[;[;[[@i;[;;D;@;1T;1T;2IC;0{;1T;1T;[[@i [@ '/var/local/upstart_helpers/', 'upstart_dir' => '/etc/init/', 'run_user' => 'service' };"DEFAULTS = { 'helper_dir' => '/var/local/upstart_helpers/', 'upstart_dir' => '/etc/init/', 'run_user' => 'service' };F;IC;" ;@;F;0;";[;[;[;[[@i ;: DEFAULTS;@o;G;"Upstart::Exporter::CONF;; ; "(CONF = '/etc/upstart-exporter.yaml'; ; ; T;H"!'/etc/upstart-exporter.yaml';"(CONF = '/etc/upstart-exporter.yaml';F;IC;" ;@;F;0;";[;[;[;[[@i;: CONF;@@Y@k@x@@@o;;"!Upstart::Exporter#initialize;; ; "def initialize(options); ; ; T;;;"~def initialize(options) process_opts(options) read_global_opts check_dir(@helper_dir) check_dir(@upstart_dir) end;F;IC;" ;@;F;0;";[o;< ;@;=" return;>[" Exporter;0;?"a new instance of Exporter;[;[;[[@i;[[" options0;:initialize;T;@o;;"'Upstart::Exporter#read_global_opts;; ; "def read_global_opts; ; ; T;;;"def read_global_opts config = if FileTest.file?(CONF) YAML::load(File.read(CONF)) else STDERR.puts "#{CONF} not found" {} end %w{helper_dir upstart_dir run_user}.each do |param| value = if config[param] config[param] else STDERR.puts "Param #{param} is not set, taking default value #{DEFAULTS[param]}" DEFAULTS[param] end self.send "#{param}=", value end end;F;IC;" ;@;F;0;";[;[;[;[[@i;[;:read_global_opts;T;@o;;"#Upstart::Exporter#process_opts;; ; "def process_opts(options); ; ; T;;;"def process_opts(options) @commands = if options[:clear] {} else process_procfile(options[:procfile]) end process_appname(options[:app_name]) end;F;IC;" ;@;F;0;";[;[;[;[[@i/;[[" options0;:process_opts;T;@o;;"'Upstart::Exporter#process_procfile;; ; "def process_procfile(name); ; ; T;;;"def process_procfile(name) error "#{name} is not a readable file" unless FileTest.file?(name) commands = {} content = File.read(name) content.lines.each do |line| line.chomp! if line =~ /^(\w+?):(.*)$/ label = $1 command = $2 commands[label] = command elsif line =~ /^\s*$/ # do nothing else error "procfile lines should have the following format: 'some_label: command'" end end commands end;F;IC;" ;@;F;0;";[;[;[;[[@i8;[[" name0;:process_procfile;T;@o;;"&Upstart::Exporter#process_appname;; ; ""def process_appname(app_name); ; ; T;;;"def process_appname(app_name) error "Application name should contain only letters (and underscore) and be nonempty, so #{app_name.inspect} is not suitable" unless app_name =~ /^\w+$/ @app_name = "fb-#{app_name}" end;F;IC;" ;@;F;0;";[;[;[;[[@iK;[[" app_name0;:process_appname;T;@o;;" Upstart::Exporter#check_dir;; ; "def check_dir(dir); ; ; T;;;"def check_dir(dir) FileUtils.mkdir_p(dir) unless FileTest.directory?(dir) error "Path #{dir} does not exist" unless FileTest.directory?(dir) end;F;IC;" ;@;F;0;";[;[;[;[[@iP;[["dir0;:check_dir;T;@o;;"Upstart::Exporter#export;; ; "def export; ; ; T;;;"tdef export clear export_app @commands.each do |cmd_name, cmd| export_command(cmd_name, cmd) end end;F;IC;" ;@$;F;0;";[;[;[;[[@iU;[;: export;T;@o;G;""Upstart::Exporter::HELPER_TPL;; ; "#HELPER_TPL = "#!/bin/sh\n%s\n"; ; ; T;H""#!/bin/sh\n%s\n";"#HELPER_TPL = "#!/bin/sh\n%s\n";F;IC;" ;@0;F;0;";[;[;[;[[@i];:HELPER_TPL;@o;G;"Upstart::Exporter::APP_TPL;; ; "xAPP_TPL = "pre-start script\n\nbash << \"EOF\"\nmkdir -p /var/log/%s\nchown -R %s /var/log/%s\nEOF\n\nend script\n"; ; ; T;H"n"pre-start script\n\nbash << \"EOF\"\nmkdir -p /var/log/%s\nchown -R %s /var/log/%s\nEOF\n\nend script\n";"xAPP_TPL = "pre-start script\n\nbash << \"EOF\"\nmkdir -p /var/log/%s\nchown -R %s /var/log/%s\nEOF\n\nend script\n";F;IC;" ;@<;F;0;";[;[;[;[[@ic;: APP_TPL;@o;G;"#Upstart::Exporter::COMMAND_TPL;; ; "@COMMAND_TPL = "start on starting %s\nstop on stopping %s\n"; ; ; T;H"2"start on starting %s\nstop on stopping %s\n";"@COMMAND_TPL = "start on starting %s\nstop on stopping %s\n";F;IC;" ;@H;F;0;";[;[;[;[[@io;:COMMAND_TPL;@o;G;"(Upstart::Exporter::COMMAND_REAL_TPL;; ; "COMMAND_REAL_TPL = "start on starting %s\nstop on stopping %s\nrespawn\n\nexec sudo -u %s /bin/sh %s >> /var/log/%s/%s.log 2>&1\n"; ; ; T;H"t"start on starting %s\nstop on stopping %s\nrespawn\n\nexec sudo -u %s /bin/sh %s >> /var/log/%s/%s.log 2>&1\n";"COMMAND_REAL_TPL = "start on starting %s\nstop on stopping %s\nrespawn\n\nexec sudo -u %s /bin/sh %s >> /var/log/%s/%s.log 2>&1\n";F;IC;" ;@T;F;0;";[;[;[;[[@iv;:COMMAND_REAL_TPL;@o;;"#Upstart::Exporter#upstart_conf;; ; "def upstart_conf; ; ; T;;;"Hdef upstart_conf File.join(@upstart_dir, "#{@app_name}.conf") end;F;IC;" ;@`;F;0;";[;[;[;[[@i;[;:upstart_conf;T;@o;;"Upstart::Exporter#app_cmd;; ; "def app_cmd(cmd_name); ; ; T;;;";def app_cmd(cmd_name) "#{@app_name}-#{cmd_name}" end;F;IC;" ;@l;F;0;";[;[;[;[[@i~;[[" cmd_name0;: app_cmd;T;@o;;"'Upstart::Exporter#upstart_cmd_conf;; ; "#def upstart_cmd_conf(cmd_name); ; ; T;;;"^def upstart_cmd_conf(cmd_name) File.join(@upstart_dir, "#{app_cmd(cmd_name)}.conf") end;F;IC;" ;@z;F;0;";[;[;[;[[@i;[[" cmd_name0;:upstart_cmd_conf;T;@o;;"&Upstart::Exporter#helper_cmd_conf;; ; ""def helper_cmd_conf(cmd_name); ; ; T;;;"Zdef helper_cmd_conf(cmd_name) File.join(@helper_dir, "#{app_cmd(cmd_name)}.sh") end;F;IC;" ;@;F;0;";[;[;[;[[@i;[[" cmd_name0;:helper_cmd_conf;T;@o;;"Upstart::Exporter#clear;; ; "def clear; ; ; T;;;"def clear FileUtils.rm(upstart_conf) if FileTest.file?(upstart_conf) Dir[upstart_cmd_conf('*')].each do |f| FileUtils.rm(f) end Dir[helper_cmd_conf('*')].each do |f| FileUtils.rm(f) end end;F;IC;" ;@;F;0;";[;[;[;[[@i;[;: clear;T;@o;;"!Upstart::Exporter#export_app;; ; "def export_app; ; ; T;;;"def export_app app_conf = APP_TPL % [@app_name, @run_user, @app_name] File.open(upstart_conf, 'w') do |f| f.write(app_conf) end end;F;IC;" ;@;F;0;";[;[;[;[[@i;[;:export_app;T;@o;;"(Upstart::Exporter#export_cmd_helper;; ; ")def export_cmd_helper(cmd_name, cmd); ; ; T;;;"def export_cmd_helper(cmd_name, cmd) helper_script_cont = HELPER_TPL % [cmd] File.open(helper_cmd_conf(cmd_name), 'w') do |f| f.write(helper_script_cont) end end;F;IC;" ;@;F;0;";[;[;[;[[@i;[[" cmd_name0["cmd0;:export_cmd_helper;T;@@o;;"%Upstart::Exporter#export_command;; ; "&def export_command(cmd_name, cmd); ; ; T;;;"rdef export_command(cmd_name, cmd) export_cmd_helper(cmd_name, cmd) export_cmd_upstart_confs(cmd_name) end;F;IC;" ;@;F;0;";[;[;[;[[@i;[[" cmd_name0["cmd0;:export_command;T;@o;;"Upstart::Exporter#error;; ; "def error(msg); ; ; T;;;":def error(msg) raise Upstart::ExportError, msg end;F;IC;" ;@;F;0;";[o;< ;@;=" raise;>["Upstart::ExportError;0;?";[;[;[[@i;[["msg0;: error;T;@o;G;"Upstart::Exporter::VERSION;; ; "VERSION = "0.0.4"; ; ; T;H" "0.0.4";"VERSION = "0.0.4";F;IC;" ;@;F;0;";[;[;[;[[@:"Upstart::Exporter::HELPER_TPL@0: Upstart::Exporter::DEFAULTS@:!Upstart::Exporter#export_app@:(Upstart::Exporter::COMMAND_REAL_TPL@T:"Upstart::Exporter#upstart_dir@:%Upstart::Exporter#export_command@:'Upstart::Exporter#upstart_cmd_conf@z:#Upstart::Exporter#process_opts@;6@+: Upstart::Exporter#check_dir@:Upstart::Exporter#run_user@:#Upstart::Exporter#upstart_dir=@x:Upstart::Exporter#error@:Upstart::Exporter::APP_TPL@<:!Upstart::Exporter#helper_dir@k:Upstart::Exporter::CONF@:(Upstart::Exporter#export_cmd_helper@:#Upstart::Exporter#upstart_conf@`:!Upstart::Exporter#initialize@: Upstart::Exporter#run_user=@;3@:Upstart::Exporter::VERSION@:&Upstart::Exporter#helper_cmd_conf@:'Upstart::Exporter#process_procfile@:"Upstart::Exporter#helper_dir=@Y:Upstart::Exporter#export@$:Upstart::Exporter#clear@:#Upstart::Exporter::COMMAND_TPL@H