Sha256: c7813bae219e8af0987999d6d181732cdaf396a99c194ee11c3a5fac9f792e98

Contents?: true

Size: 1.5 KB

Versions: 41

Compression:

Stored size: 1.5 KB

Contents

module Redcar
  class Runnables
    class TreeMirror
      include Redcar::Tree::Mirror

      attr_accessor :last_loaded

      def initialize(project)
        @project = project
      end

      def runnable_file_paths
        @project.config_files("runnables/*.json")
      end

      def last_updated
        runnable_file_paths.map{ |p| File.mtime(p) }.max
      end

      def changed?
        !last_loaded || last_loaded < last_updated
      end

      def custom_command
        custom_info = {}
        custom_info["command"] = PARAMS
        custom_info["output"] = 'tab'
        custom = Runnable.new("Custom Command",@project.path,custom_info)
        [custom]
      end

      def load
        begin
          groups = {}
          runnable_file_paths.each do |path|
            runnables = []
            name = File.basename(path,".json")
            json = File.read(path)
            this_runnables = JSON(json)["commands"]
            runnables += this_runnables || []
            groups[name.to_s] = runnables.to_a
          end
        rescue Object => e
          Redcar::Application::Dialog.message_box("There was an error parsing Runnables: #{e.message}")
          groups = {}
        end

        if groups.any?
          groups.map do |name, runnables|
            RunnableGroup.new(name,@project.path,runnables)
          end
        else
          [HelpItem.new]
        end
      end

      def title
        TREE_TITLE
      end

      def top
        custom_command + load
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
redcar-0.13 plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.13.5dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.13.4dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.13.3dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.13.2dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.13.1dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-0.12.1 plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.13.0dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-0.12 plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.27dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.26dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.25dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.24dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.23dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.22dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.21dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.20dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.19dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.18dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb
redcar-dev-0.12.17dev plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb