Sha256: 3ee706a5829c4a0a8899ecac8abbf2cb54d4fef9daa9d1537818018df834f81f

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require_relative '../base'

module Analytics
  module Serializer
    class ObjC < Base
      class Logger
        def initialize(src)
          @src = src
        end

        def save(path)
          @protocol_name = 'AnalyticsLogger'

          @file_name = @protocol_name + '.h'
          output_path = File.join(path, @file_name)
          File.write(output_path, render_h)
        end

        private

        def render_h
          ERB.new(template_h, nil, '-').result(binding)
        end

        def template_h
          <<~TEMPLATE
            <%= ERB.new(Analytics::Templates.tmpl_at('header.erb')).result(binding) %>

            #import <Foundation/Foundation.h>

            @class AnalyticsEvent;
            @class AnalyticsScreen;
            @class AnalyticsUserProperty;

            NS_ASSUME_NONNULL_BEGIN
            
            __swift_unavailable("This protocol is only available in ObjC.")
            @protocol <%= @protocol_name %> <NSObject>

            - (void)setEnabled:(BOOL)enabled;
            - (void)logEvent:(AnalyticsEvent *)event;
            - (void)trackScreen:(AnalyticsScreen *)screen;
            - (void)setUserProperty:(AnalyticsUserProperty *)userProperty;

            @end

            NS_ASSUME_NONNULL_END
          TEMPLATE
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ios_analytics_cli-1.1.0 lib/ios_analytics_cli/serializers/objc/logger.rb
ios_analytics_cli-1.0.0 lib/ios_analytics_cli/serializers/objc/logger.rb