Class: PodLibCreate::Main
- Inherits:
-
Object
- Object
- PodLibCreate::Main
- Defined in:
- lib/pod_lib_create.rb
Instance Method Summary collapse
- #ask(question) ⇒ Object
- #check_config ⇒ Object
- #create_pod_lib ⇒ Object
- #pod_name ⇒ Object
- #run ⇒ Object
Instance Method Details
#ask(question) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pod_lib_create.rb', line 14 def ask(question) answer = "" loop do puts "\n#{question}?" print " > " answer = STDIN.gets.chomp break if answer.length > 0 print "\nYou need to provide an answer." end answer end |
#check_config ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pod_lib_create.rb', line 29 def check_config need_save = false path = File.("~/.pod_lib_create_config.yaml") config = Hash.new if File.exist?(path) config = YAML::load_file(path) if not config config = Hash.new end else File.open(path, 'w') {|f| f.write config.to_yaml } end if not config["user"] config["user"] = Hash.new config["user"]["name"] = ask("What is your name") config["user"]["email"] = ask("What is your email") need_save = true end if not config["spec"] config["spec"] = Hash.new config["spec"]["home"] = ask("What is your source code git homepage") config["spec"]["src"] = ask("What is your source code git uri") config["spec"]["prefix"] = ask("What is your class prefix") need_save = true end if need_save File.open(path, 'w') {|f| f.write config.to_yaml } end end |
#create_pod_lib ⇒ Object
73 74 75 76 77 |
# File 'lib/pod_lib_create.rb', line 73 def create_pod_lib cmd = "pod lib create " + pod_name + " --template-url=https://github.com/shunchengGit/pod_lib_create_template" puts cmd system cmd end |
#pod_name ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/pod_lib_create.rb', line 62 def pod_name the_name = '' if ARGV and ARGV.size >= 1 the_name = ARGV[0].lstrip.rstrip end if not the_name or the_name.length < 1 the_name = ask("What is your pod name") end the_name end |
#run ⇒ Object
9 10 11 12 |
# File 'lib/pod_lib_create.rb', line 9 def run check_config create_pod_lib end |