class TogoStanza::CLI::GenspecUpdater

Public Class Methods

source_root() click to toggle source
# File lib/togostanza/cli.rb, line 206
def self.source_root
  File.expand_path('../../../templates/stanza', __FILE__)
end

Public Instance Methods

check_exist() click to toggle source
# File lib/togostanza/cli.rb, line 210
def check_exist
  unless File.exist?("#{file_name}")
    say("This provider doesn't have #{file_name}")
    exit
  end
  unless File.exist?("#{file_name}/metadata.json")
    template 'metadata.json.erb', "#{file_name}/metadata.json"
    say("metadata.json has just made.")
  end
end
replace_description() click to toggle source
# File lib/togostanza/cli.rb, line 221
def replace_description
  unless File.read("#{file_name}/#{file_name}.gemspec").include?("require\s'json'")
    insert_into_file("#{file_name}/#{file_name}.gemspec", "\nrequire\s'json'\n", :after=>"$LOAD_PATH.unshift(lib)\sunless\s$LOAD_PATH.include?(lib)\n")
    insert_into_file("#{file_name}/#{file_name}.gemspec", "metadata\s=\sopen('./metadata.json')\sdo\s|io|\n", :after=>"\nrequire\s'json'\n")
    insert_into_file("#{file_name}/#{file_name}.gemspec", "\s\sJSON.load\(io\)\nend\n", :after=>"metadata\s=\sopen('./metadata.json')\sdo\s|io|\n")
  end
  gsub_file("#{file_name}/#{file_name}.gemspec", /spec\.authors.*\n/, "spec.authors       = Array(metadata['author'])\n")
  gsub_file("#{file_name}/#{file_name}.gemspec", /spec\.email.*\n/, "spec.email         = Array(metadata['address'])\n")
  gsub_file("#{file_name}/#{file_name}.gemspec", /spec\.summary.*\n/, "spec.summary       = metadata['label']\n")
  gsub_file("#{file_name}/#{file_name}.gemspec", /spec\.description.*\n/, "spec.description   = metadata['definition']\n")
  gsub_file("#{file_name}/#{file_name}.gemspec", /spec\.license.*\n/, "spec.license       = metadata['license']\n")
end

Private Instance Methods

chop_slash() click to toggle source
# File lib/togostanza/cli.rb, line 236
def chop_slash
  if name[-1] == '/'
    name.chop
  else
    name
  end
end
file_name() click to toggle source
# File lib/togostanza/cli.rb, line 248
def file_name
  stanza_id + '_stanza'
end
stanza_id() click to toggle source
# File lib/togostanza/cli.rb, line 244
def stanza_id
  chop_slash.underscore.sub(/_stanza$/, '')
end