<commit_before>require 'state_machine'

module Punchblock
  module Protocol
    class Ozone
      module Command
        extend ActiveSupport::Autoload

        autoload :Accept
        autoload :Answer
        autoload :Ask
        autoload :Conference
        autoload :Dial
        autoload :Hangup
        autoload :Record
        autoload :Redirect
        autoload :Reject
        autoload :Say
        autoload :Transfer

        InvalidActionError = Class.new StandardError

        class CommandNode < OzoneNode
          attr_accessor :events

          def initialize(*args)
            super
            @events = []
          end

          def add_event(event)
            event.original_command = self
            @events << event
            transition_state! event
          end

          def transition_state!(event)
            complete! if event.is_a? Ozone::Event::Complete
          end

          state_machine :state, :initial => :new do
            event :request do
              transition :new => :requested
            end

            event :execute do
              transition :requested => :executing
            end

            event :complete do
              transition :executing => :complete
            end
          end
        end # CommandNode

        class Action < OzoneNode # :nodoc:
          def self.new(options = {})
            super().tap do |new_node|
              new_node.command_id = options[:command_id]
              new_node.call_id = options[:call_id]
            end
          end
        end # Action
      end # Command
    end # Ozone
  end # Protocol<commit_msg>Action nodes should be considered commands, so that they can carry state<commit_after>require 'state_machine'

module Punchblock
  module Protocol
    class Ozone
      module Command
        extend ActiveSupport::Autoload

        autoload :Accept
        autoload :Answer
        autoload :Ask
        autoload :Conference
        autoload :Dial
        autoload :Hangup
        autoload :Record
        autoload :Redirect
        autoload :Reject
        autoload :Say
        autoload :Transfer

        InvalidActionError = Class.new StandardError

        class CommandNode < OzoneNode
          attr_accessor :events

          def initialize(*args)
            super
            @events = []
          end

          def add_event(event)
            event.original_command = self
            @events << event
            transition_state! event
          end

          def transition_state!(event)
            complete! if event.is_a? Ozone::Event::Complete
          end

          state_machine :state, :initial => :new do
            event :request do
              transition :new => :requested
            end

            event :execute do
              transition :requested => :executing
            end

            event :complete do
              transition :executing => :complete
            end
          end
        end # CommandNode

        class Action < CommandNode # :nodoc:
          def self.new(options = {})
            super().tap do |new_node|
              new_node.command_id = options[:command_id]
              new_node.call_id = options[:call_id]
            end
          end
        end # Action
      end # Command
    end # Ozone
  end # Protocol
{'fraction_non_alphanumeric': 0.059355227478156074, 'fraction_numerical': 0.0, 'mean_word_length': 1.4887556221889056, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2876096', 'n_tokens_mistral': 850, 'n_tokens_neox': 821, 'n_words': 240}