Class: Produce::DeveloperCenter

Inherits:
Object
  • Object
show all
Defined in:
lib/produce/developer_center.rb

Instance Method Summary collapse

Instance Method Details

#app_identifierObject



42
43
44
# File 'lib/produce/developer_center.rb', line 42

def app_identifier
  Produce.config[:app_identifier].to_s
end

#create_new_appObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/produce/developer_center.rb', line 11

def create_new_app
  ENV["CREATED_NEW_APP_ID"] = Time.now.to_i.to_s

  if app_exists?
    Helper.log.info "[DevCenter] App '#{Produce.config[:app_name]}' already exists, nothing to do on the Dev Center".green
    ENV["CREATED_NEW_APP_ID"] = nil
    # Nothing to do here
  else
    app_name = valid_name_for(Produce.config[:app_name])
    Helper.log.info "Creating new app '#{app_name}' on the Apple Dev Center".green

    app = Spaceship.app.create!(bundle_id: app_identifier,
                                     name: app_name)

    Helper.log.info "Created app #{app.app_id}"

    raise "Something went wrong when creating the new app - it's not listed in the apps list" unless app_exists?

    ENV["CREATED_NEW_APP_ID"] = Time.now.to_i.to_s

    Helper.log.info "Finished creating new app '#{app_name}' on the Dev Center".green
  end

  return true
end

#runObject



6
7
8
9
# File 'lib/produce/developer_center.rb', line 6

def run
  
  create_new_app
end

#valid_name_for(input) ⇒ Object



37
38
39
40
# File 'lib/produce/developer_center.rb', line 37

def valid_name_for(input)
  latinazed = input.to_slug.transliterate.to_s # remove accents
  latinazed.gsub(/[^0-9A-Za-z\d\s]/, '') # remove non-valid characters
end