Sha256: f480223ce8e81f8ebbd7f80667bcc70d3780a545385c15f94ab5dba2586e76f2
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
# encoding: utf-8 require 'target_method' module SublimeSunippetter # Dsl. this is dsl for Sunippetdefine. class Dsl attr_accessor :target_methods, :_scope, :_output_path, :requires # init default values def initialize @target_methods = [] @_scope = 'source.ruby' @_output_path = './' @requires = [] end # add sunippet information def add(method_name, *args) return if has_error?(method_name, *args) has_do_block = args.include?('block@d') has_brace_block = args.include?('block@b') args = delete_block_args args @target_methods << TargetMethod.new do |t| t.method_name = method_name t.args = args t.has_do_block = has_do_block t.has_brace_block = has_brace_block end end def add_requires(*filenames) @requires = filenames end # set sunippet scope def scope(_scope) return if _scope.nil? return if _scope.empty? @_scope = _scope end # set sunippet output path def output_path(_output_path) return if _output_path.nil? return if _output_path.empty? @_output_path = _output_path end private def has_error?(method_name, *args) return true if method_name.nil? return true if method_name.empty? return true if args.each.include?(nil) return true if args.each.include?('') false end def delete_block_args(args) args - ['block@b', 'block@d'] end end class SunippetterError < StandardError; end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sublime_sunippetter-0.0.5 | lib/sublime_sunippetter_dsl.rb |