Sha256: d671ea29f20ee2b1d05303d0d5d0129174676f8f54808cb15685d777d7fc9df8

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

module Pione
  module Util
    module Misc
      # Ignores all exceptions of the block execution.
      # @yield []
      #   target block
      # @return [void]
      def ignore_exception(*exceptions, &b)
        exceptions = [Exception] if exceptions.empty?
        b.call
      rescue *exceptions => e
        Log::Debug.ignored_exception(e)
        return false
      end

      def error?(option={}, &b)
        sec = option[:timeout]
        begin
          timeout(sec) do
            b.call
            false
          end
        rescue Object => e
          true
        end
      end

      # Returns the hostname of the machine.
      # @return [String]
      #   hostname
      def hostname
        Socket.gethostname
      end

      def parse_features(textual_features)
        stree = Lang::DocumentParser.new.expr.parse(textual_features)
        opt = {package_name: "*Feature*", filename: "*Feature*"}
        Lang::DocumentTransformer.new.apply(stree, opt)
      end

      def parse_param_set(textual_param_set)
        stree = Lang::DocumentParser.new.parameter_set.parse(textual_param_set)
        opt = {package_name: "*ParamSet*", filename: "*ParamSet*"}
        params = Lang::DocumentTransformer.new.apply(stree, opt)
      end
    end

    extend Misc
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pione-0.5.0 lib/pione/util/misc.rb
pione-0.5.0.alpha.2 lib/pione/util/misc.rb
pione-0.5.0.alpha.1 lib/pione/util/misc.rb
pione-0.4.2 lib/pione/util/misc.rb
pione-0.4.1 lib/pione/util/misc.rb
pione-0.4.0 lib/pione/util/misc.rb
pione-0.3.2 lib/pione/util/misc.rb