<commit_before>##   RSence
 #   Copyright 2009 Riassence Inc.
 #   http://riassence.com/
 #
 #   You should have received a copy of the GNU General Public License along
 #   with this software package. If not, contact <EMAIL>
 ##


module RSence
  module Plugins
    
    # The CUIPlugin__ is actually available as +GUIPlugin+ from plugin bundle code using the {RSence::Plugins::GUIPlugin} class mimic method.
    #
    # GUIPlugin extends {Plugin__ Plugin} by automatically initializing an {GUIParser} instance as +@gui+.
    #
    # Read {Plugin__ Plugin} for usage of the API, {file:ExampleGuiPlugin Example GUIPlugin} for an example of use and {file:PluginBundles Plugin Bundles} for overall information about plugin bundle usage.
    #
    # * It implements automatic dependency loading based on the dependencies item in the YAML gui declaration.
    # * It inits the gui automatically.
    #
    # = User Interface -related hooks:
    # * {#init_ui +#init_ui+} -- Extend to implement logic when the {MainPlugin} plugin has started the client. The {GUIPlugin__ +GUIPlugin+} class extends this method to automatically load and initialize the user interface from a +GUITree+ data structure defined in the +gui/main.yaml+ document in the bundle directory.
    # * {#gui_params +#gui_params+} -- Extend to define your own params for the gui data.
    #
    class GUIPlugin__ < Plugin__
      
      # @private Class type identifier for the PluginManager.
      # @return [:GUIPlugin]
      def self.bundle_type; :GUIPlugin; end
      
      # In addition to {Plugin__#init Plugin#init}, also automatically initializes a {GUIParser} instance as +@gui+
      #
      # @return [nil]
      def init
        super
        yaml_src = false
        [ "#{@name}.yaml", 'gui.yaml',
          "gui/#{@name}.yaml", "gui/main.yaml"
        ].each do |yaml_name|
          yaml_src = file_read( yaml_name )
          break if yaml_src
        end
        if yaml_src
          @gui = GUIParser.new( self, yaml_src, @name )
        else
          @gui = nil
        end
        @client_pkgs = false
      end
  
      # Extend this method to return custom params to {GUIParser#init}.
      #
      # Called from {#init_ui}.
      #
      # By default assigns the session values as :values to use for +bind: :values.my_value_name+ in the YAML GUI file for client-side value bindings.
      #
      # @param [Message] msg The message is supplied by the system.
      # 
      # @return [Hash] Parameters for {GUIParser#init @gui#init}
      #
      # @example To provide extra parameters, do this:
      #   def gui_params( msg )
      #     params = super
      #     params[:extra] = {
      #       :foo => "Foo",       # use in the GUITree as :extra.foo
      #       :num => 124334,      # use in the GUITree as :extra.num
      #       :bar => {
      #         :barbar => "Bar"   # use in the GUITree as :extra.bar.barbar
      #       }
      #       :arr => [1,2,4,8]    # use in the GUITree as :extra.arr
      #     }
      #     params[:more] = "More" # use in the GUITree as :more
      #     return params
      #   end
      #
      def gui_params( msg )
        return unless @gui
        { :values => @gui.values( get_ses( msg ) ) }
      end
      
      # @private Method that implements +client_pkgs.yaml+ loading
      def install_client_pkgs
        if @client_pkgs
          warn "install_client_pkgs: called with @client_pkgs defined (#{@client_pkgs.inspect}); returning" if RSence.args[:debug]
          return
        end
        @client_pkgs = yaml_read( 'client_pkgs.yaml' )
        if @client_pkgs
          if @client_pkgs.has_key?(:src_dirs)
            @client_pkgs[:src_dirs].each do |src_dir|
              src_dir = bundle_path( src_dir[2..-1] ) if src_dir.start_with?('./')
              client_pkg.add_src_dir( src_dir )
            end
          end
          sleep 0.1 until client_pkg.ready?
          client_pkg.add_packages(       @client_pkgs[:packages      ] ) if @client_pkgs.has_key?(:packages      )
          client_pkg.add_compounds(      @client_pkgs[:compound_packages] ) if @client_pkgs.has_key?(:compound_packages)
          client_pkg.add_themes(         @client_pkgs[:theme_names   ] ) if @client_pkgs.has_key?(:theme_names   )
          client_pkg.add_gfx_formats(    @client_pkgs[:gfx_formats   ] ) if @client_pkgs.has_key?(:gfx_formats   )
          client_pkg.add_reserved_names( @client_pkgs[:reserved_names] ) if @client_pkgs.has_key?(:reserved_names)
          client_pkg.rebuild_client
        end
      end<commit_msg>Allows alternative syntax in client_pkgs.yaml<commit_after>##   RSence
 #   Copyright 2009 Riassence Inc.
 #   http://riassence.com/
 #
 #   You should have received a copy of the GNU General Public License along
 #   with this software package. If not, contact <EMAIL>
 ##


module RSence
  module Plugins
    
    # The CUIPlugin__ is actually available as +GUIPlugin+ from plugin bundle code using the {RSence::Plugins::GUIPlugin} class mimic method.
    #
    # GUIPlugin extends {Plugin__ Plugin} by automatically initializing an {GUIParser} instance as +@gui+.
    #
    # Read {Plugin__ Plugin} for usage of the API, {file:ExampleGuiPlugin Example GUIPlugin} for an example of use and {file:PluginBundles Plugin Bundles} for overall information about plugin bundle usage.
    #
    # * It implements automatic dependency loading based on the dependencies item in the YAML gui declaration.
    # * It inits the gui automatically.
    #
    # = User Interface -related hooks:
    # * {#init_ui +#init_ui+} -- Extend to implement logic when the {MainPlugin} plugin has started the client. The {GUIPlugin__ +GUIPlugin+} class extends this method to automatically load and initialize the user interface from a +GUITree+ data structure defined in the +gui/main.yaml+ document in the bundle directory.
    # * {#gui_params +#gui_params+} -- Extend to define your own params for the gui data.
    #
    class GUIPlugin__ < Plugin__
      
      # @private Class type identifier for the PluginManager.
      # @return [:GUIPlugin]
      def self.bundle_type; :GUIPlugin; end
      
      # In addition to {Plugin__#init Plugin#init}, also automatically initializes a {GUIParser} instance as +@gui+
      #
      # @return [nil]
      def init
        super
        yaml_src = false
        [ "#{@name}.yaml", 'gui.yaml',
          "gui/#{@name}.yaml", "gui/main.yaml"
        ].each do |yaml_name|
          yaml_src = file_read( yaml_name )
          break if yaml_src
        end
        if yaml_src
          @gui = GUIParser.new( self, yaml_src, @name )
        else
          @gui = nil
        end
        @client_pkgs = false
      end
  
      # Extend this method to return custom params to {GUIParser#init}.
      #
      # Called from {#init_ui}.
      #
      # By default assigns the session values as :values to use for +bind: :values.my_value_name+ in the YAML GUI file for client-side value bindings.
      #
      # @param [Message] msg The message is supplied by the system.
      # 
      # @return [Hash] Parameters for {GUIParser#init @gui#init}
      #
      # @example To provide extra parameters, do this:
      #   def gui_params( msg )
      #     params = super
      #     params[:extra] = {
      #       :foo => "Foo",       # use in the GUITree as :extra.foo
      #       :num => 124334,      # use in the GUITree as :extra.num
      #       :bar => {
      #         :barbar => "Bar"   # use in the GUITree as :extra.bar.barbar
      #       }
      #       :arr => [1,2,4,8]    # use in the GUITree as :extra.arr
      #     }
      #     params[:more] = "More" # use in the GUITree as :more
      #     return params
      #   end
      #
      def gui_params( msg )
        return unless @gui
        { :values => @gui.values( get_ses( msg ) ) }
      end
      
      # @private Method that implements +client_pkgs.yaml+ loading
      def install_client_pkgs
        if @client_pkgs
          warn "install_client_pkgs: called with @client_pkgs defined (#{@client_pkgs.inspect}); returning" if RSence.args[:debug]
          return
        end
        client_pkgs = yaml_read( 'client_pkgs.yaml' )
        if client_pkgs

          sleep 0.1 until client_pkg.ready?
          
          if client_pkgs.has_key?('src_dir')
            src_dirs = [ client_pkgs['src_dir'] ]
          elsif client_pkgs.has_key?('src_dirs')
            src_dirs = client_pkgs['src_dirs']
          elsif client_pkgs.has_key?(:src_dirs)
            src_dirs = client_pkgs[:src_dirs]
          else
            src_dirs = false
          end

          @client_pkgs = {}
          if src_dirs
            src_dirs.each do |src_dir|
              if src_dir.start_with?('./')
                src_dir = bundle_path( src_dir[2..-1] )
              end
              client_pkg.add_src_dir( src_dir )
            end
            @client_pkgs[:src_dirs] = src_dirs
          end
          
          if client_pkgs.has_key?('packages')
            packages = client_pkgs['packages']
          elsif client_pkgs.has_key?(:packages)
            packages = client_pkgs[:packages]
          else
            packages = false
          end

          if packages
            client_pkg.add_packages( packages )
            @client_pkgs[:packages] = packages
          end

          
          if client_pkgs.has_key?('compounds')
            compounds = client_pkgs['compounds']
          elsif client_pkgs.has_key?('compound_packages')
            compounds = client_pkgs['compound_packages']
          elsif client_pkgs.has_key?(:compound_packages)
            compounds = client_pkgs[:compound_packages]
          else
            compounds = false
          end

          if compounds
            client_pkg.add_compounds( compounds )
            @client_pkgs[:compound_packages] = compounds
          end

          
          if client_pkgs.has_key?('themes')
            theme_names = client_pkgs['themes']
          elsif client_pkgs.has_key?('theme_names')
            theme_names = client_pkgs['theme_names']
          elsif client_pkgs.has_key?(:theme_names)
            theme_names = client_pkgs[:theme_names]
          else
            theme_names = false
          end

          if theme_names
            client_pkg.add_themes( theme_names )
            @client_pkgs[:theme_names] = theme_names
          end


          if client_pkgs.has_key?('gfx_formats')
            gfx_formats = client_pkgs['gfx_formats']
          elsif client_pkgs.has_key?(:gfx_formats)
            gfx_formats = client_pkgs[:gfx_formats]
          else
            gfx_formats = false
          end

          if gfx_formats
            client_pkg.add_gfx_formats( gfx_formats )
            @client_pkgs[:gfx_formats] = gfx_formats
          end

          if client_pkgs.has_key?('reserved_names')
            reserved_names = client_pkgs['reserved_names']
          elsif client_pkgs.has_key?(:reserved_names)
            reserved_names = client_pkgs[:reserved_names]
          else
            reserved_names = false
          end

          if reserved_names
            client_pkg.add_reserved_names( reserved_names )
            @client_pkgs[:reserved_names] = reserved_names
          end

          client_pkg.rebuild_client
          
        end
      end
{'fraction_non_alphanumeric': 0.08878298473215074, 'fraction_numerical': 0.003177124702144559, 'mean_word_length': 2.078511274110296, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4989428', 'n_tokens_mistral': 3492, 'n_tokens_neox': 3390, 'n_words': 940}