Class: Pod::Generator::DummySource

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/generator/dummy_source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name_identifier) ⇒ DummySource

Returns a new instance of DummySource.



6
7
8
9
# File 'lib/cocoapods/generator/dummy_source.rb', line 6

def initialize(class_name_identifier)
  validated_class_name_identifier = class_name_identifier.gsub(/[^0-9a-z_]/i, '_')
  @class_name = "PodsDummy_#{validated_class_name_identifier}"
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



4
5
6
# File 'lib/cocoapods/generator/dummy_source.rb', line 4

def class_name
  @class_name
end

Instance Method Details

#generateString

Returns the string contents of the dummy source file.

Returns:

  • (String)

    the string contents of the dummy source file.



13
14
15
16
17
18
19
20
21
22
# File 'lib/cocoapods/generator/dummy_source.rb', line 13

def generate
  result = <<-source.strip_heredoc
    #import <Foundation/Foundation.h>
    @interface #{class_name} : NSObject
    @end
    @implementation #{class_name}
    @end
  source
  result
end

#save_as(pathname) ⇒ Object



24
25
26
27
28
# File 'lib/cocoapods/generator/dummy_source.rb', line 24

def save_as(pathname)
  pathname.open('w') do |source|
    source.write(generate)
  end
end