cocoapods-roulette 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocoapods_plugin.rb +2 -1
- data/lib/cocoapods_roulette.rb +2 -2
- data/lib/pod/command/roulettathon.rb +69 -0
- data/lib/pod/command/roulette.rb +114 -64
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d0511dbeb1992eb8e5b8df014f1be3ba72db5b9c
         | 
| 4 | 
            +
              data.tar.gz: 1ed98d91e3415c5c411d954d96bf1d5f3b9484bb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 34784c3b773040f887e23e3e1b13463612c9e91ac3395d6cd49af244a9633617398c7ebda0ab8f2c8415f88762c9ff0eb935d3f20b31cddef18a0e3ca36936dd
         | 
| 7 | 
            +
              data.tar.gz: ba684568dba5230164b7560fb43187cd87008701b9818c9aef192d93c57ef896e686bf8a8f15d38396e377ad6d33edd2d143c8017c43e0b2660d75e50d7b2667
         | 
    
        data/lib/cocoapods_plugin.rb
    CHANGED
    
    | @@ -1 +1,2 @@ | |
| 1 | 
            -
            require 'pod/command/roulette'
         | 
| 1 | 
            +
            require 'pod/command/roulette'
         | 
| 2 | 
            +
            require 'pod/command/roulettathon'
         | 
    
        data/lib/cocoapods_roulette.rb
    CHANGED
    
    | @@ -1,3 +1,3 @@ | |
| 1 1 | 
             
            class CocoapodsRoulette
         | 
| 2 | 
            -
              VERSION = "1.0. | 
| 3 | 
            -
            end
         | 
| 2 | 
            +
              VERSION = "1.0.2"
         | 
| 3 | 
            +
            end
         | 
| @@ -0,0 +1,69 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
            module Pod
         | 
| 3 | 
            +
              class Command
         | 
| 4 | 
            +
                class Roulettathon < Command
         | 
| 5 | 
            +
                  self.summary = "An easy entrypoint for taking part in a Roulettathon"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  self.description = <<-DESC
         | 
| 8 | 
            +
                    Only asks a few times before you have to settle for a podroulette configuration.
         | 
| 9 | 
            +
                  DESC
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  WINK = [0x1f609].pack("U*")
         | 
| 12 | 
            +
                  WEIRD_PROJECTS = %w(NotAGoodIdeaTableViewAspect)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def self.options
         | 
| 15 | 
            +
                    Roulette.options
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  attr_reader :roulette
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def initialize(argv)
         | 
| 21 | 
            +
                    @roulette = Roulette.new argv
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    def @roulette.last_chance=(last_chance)
         | 
| 24 | 
            +
                      @last_chance = last_chance
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    def @roulette.yesno(question, default = false)
         | 
| 28 | 
            +
                      question = "#{question} [#{'LAST CHANCE!'.red}]" if @last_chance
         | 
| 29 | 
            +
                      super question, default
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                    super
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def tries
         | 
| 36 | 
            +
                    3
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  def run
         | 
| 40 | 
            +
                    roulette.update_if_necessary!
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    UI.puts "Greetings, Roulettathon attendee!"
         | 
| 43 | 
            +
                    UI.puts
         | 
| 44 | 
            +
                    UI.puts "You have #{(tries.to_s + ' chances').green.underline} of finding you a project today."
         | 
| 45 | 
            +
                    UI.puts "If you reject your first #{tries - 1} chances you have to go with the last one,"
         | 
| 46 | 
            +
                    UI.puts "even if it's a #{WEIRD_PROJECTS.sample.magenta}. You've been warned! #{WINK}"
         | 
| 47 | 
            +
                    UI.puts
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                    catch :done do
         | 
| 50 | 
            +
                      (tries - 1).downto(0).each do |remaining|
         | 
| 51 | 
            +
                        if remaining >= 1
         | 
| 52 | 
            +
                          roulette.last_chance = (remaining == 1)
         | 
| 53 | 
            +
                          roulette.next_round do |success, configuration|
         | 
| 54 | 
            +
                            if success or remaining.zero?
         | 
| 55 | 
            +
                              configuration.create
         | 
| 56 | 
            +
                              throw :done
         | 
| 57 | 
            +
                            end
         | 
| 58 | 
            +
                          end
         | 
| 59 | 
            +
                        else
         | 
| 60 | 
            +
                          configuration = roulette.next_configuration
         | 
| 61 | 
            +
                          roulette.announce configuration
         | 
| 62 | 
            +
                          configuration.create
         | 
| 63 | 
            +
                        end
         | 
| 64 | 
            +
                      end
         | 
| 65 | 
            +
                    end
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
            end
         | 
    
        data/lib/pod/command/roulette.rb
    CHANGED
    
    | @@ -7,21 +7,23 @@ module Pod | |
| 7 7 | 
             
                  self.description = <<-DESC
         | 
| 8 8 | 
             
                    Creates a new iOS project with three random pods.
         | 
| 9 9 | 
             
                  DESC
         | 
| 10 | 
            -
             | 
| 10 | 
            +
             | 
| 11 11 | 
             
                  def self.options
         | 
| 12 12 | 
             
                    [[
         | 
| 13 13 | 
             
                      "--update", "Run `pod repo update` before rouletting",
         | 
| 14 14 | 
             
                    ]].concat(super)
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 |  | 
| 17 | 
            +
                  EMOJIS = [0x1F602, 0x1F604, 0x1F60D, 0x1F61C, 0x1F62E, 0x1F62F, 0x1F633, 0x1F640].pack("U*").chars
         | 
| 18 | 
            +
                  THINGS = [0x1f37a, 0x1f378, 0x1f377, 0x1f354, 0x1f35d, 0x1f368, 0x1f36d, 0x1f36c].pack("U*").chars
         | 
| 19 | 
            +
             | 
| 17 20 | 
             
                  def initialize(argv)
         | 
| 18 21 | 
             
                    @update = argv.flag?('update')
         | 
| 19 22 | 
             
                    super
         | 
| 20 23 | 
             
                  end
         | 
| 21 24 |  | 
| 22 | 
            -
                  def clear_prev_line | 
| 25 | 
            +
                  def clear_prev_line
         | 
| 23 26 | 
             
                    print "\r\e[A\e[K"
         | 
| 24 | 
            -
                    value
         | 
| 25 27 | 
             
                  end
         | 
| 26 28 |  | 
| 27 29 | 
             
                  def yesno(question, default = false)
         | 
| @@ -30,11 +32,13 @@ module Pod | |
| 30 32 | 
             
                    answer = UI.gets.chomp
         | 
| 31 33 |  | 
| 32 34 | 
             
                    if answer.empty?
         | 
| 33 | 
            -
                      clear_prev_line | 
| 35 | 
            +
                      clear_prev_line
         | 
| 36 | 
            +
                      default
         | 
| 34 37 | 
             
                    elsif /^y$/i =~ answer
         | 
| 35 | 
            -
                      clear_prev_line | 
| 38 | 
            +
                      clear_prev_line
         | 
| 39 | 
            +
                      true
         | 
| 36 40 | 
             
                    elsif /^n$/i =~ answer
         | 
| 37 | 
            -
                       | 
| 41 | 
            +
                      false
         | 
| 38 42 | 
             
                    else
         | 
| 39 43 | 
             
                      UI.puts "Please answer with 'y' or 'n'.".red
         | 
| 40 44 | 
             
                      yesno question, default
         | 
| @@ -59,27 +63,64 @@ module Pod | |
| 59 63 | 
             
                    end
         | 
| 60 64 | 
             
                  end
         | 
| 61 65 |  | 
| 62 | 
            -
                  def  | 
| 63 | 
            -
                     | 
| 64 | 
            -
                      Regexp.last_match[2].upcase
         | 
| 65 | 
            -
                    end
         | 
| 66 | 
            -
                    name = name.gsub /[^a-z]/i, ''
         | 
| 67 | 
            -
                    name.gsub /^[A-Z]*([A-Z][^A-Z].*)$/, '\1'
         | 
| 66 | 
            +
                  def all_specs
         | 
| 67 | 
            +
                    @all_specs ||= Pod::SourcesManager.master.first.pod_sets
         | 
| 68 68 | 
             
                  end
         | 
| 69 69 |  | 
| 70 | 
            -
                  def  | 
| 71 | 
            -
                     | 
| 72 | 
            -
             | 
| 70 | 
            +
                  def run
         | 
| 71 | 
            +
                    update_if_necessary!
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                    catch :done do
         | 
| 74 | 
            +
                      while true do
         | 
| 75 | 
            +
                        next_round do |success, configration|
         | 
| 76 | 
            +
                          if success
         | 
| 77 | 
            +
                            configration.create
         | 
| 78 | 
            +
                            throw :done
         | 
| 79 | 
            +
                          else
         | 
| 80 | 
            +
                            # continue forever
         | 
| 81 | 
            +
                          end
         | 
| 82 | 
            +
                        end
         | 
| 83 | 
            +
                      end
         | 
| 84 | 
            +
                    end
         | 
| 73 85 | 
             
                  end
         | 
| 74 86 |  | 
| 75 | 
            -
                   | 
| 76 | 
            -
                     | 
| 87 | 
            +
                  class Configuration
         | 
| 88 | 
            +
                    attr_reader :specs
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                    def initialize(specs)
         | 
| 91 | 
            +
                      @specs = specs
         | 
| 92 | 
            +
                    end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                    def name
         | 
| 95 | 
            +
                      specs.map do |spec|
         | 
| 96 | 
            +
                        self.class.humanize_pod_name spec.name
         | 
| 97 | 
            +
                      end.join ''
         | 
| 98 | 
            +
                    end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                    def create
         | 
| 101 | 
            +
                      UI.puts "\nPerfect, your project will use"
         | 
| 102 | 
            +
                      UI.puts (specs.map(&:name).join ", ") + "."
         | 
| 103 | 
            +
                      UI.puts "Just a few more questions before we start:\n\n"
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                      if create_project
         | 
| 106 | 
            +
                        sleep 0.1 # make sure all output from liftoff has been flushed
         | 
| 107 | 
            +
                        UI.puts "\n\n" + tweet_text(name) + "\n\n"
         | 
| 108 | 
            +
                      end
         | 
| 109 | 
            +
                    end
         | 
| 77 110 |  | 
| 78 | 
            -
                     | 
| 79 | 
            -
                       | 
| 80 | 
            -
                       | 
| 111 | 
            +
                    def tweet_text(project_name)
         | 
| 112 | 
            +
                      random_emoji = EMOJIS.sample
         | 
| 113 | 
            +
                      "#{random_emoji}  got '#{name}' from `pod roulette` by @sirlantis and @hbehrens - fun stuff from @uikonf"
         | 
| 81 114 | 
             
                    end
         | 
| 82 | 
            -
             | 
| 115 | 
            +
             | 
| 116 | 
            +
                    def pod_file_content
         | 
| 117 | 
            +
                      s = "platform :ios, '7.0'\n\n"
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                      specs.each do |spec|
         | 
| 120 | 
            +
                        pod = Pod::Specification::Set::Presenter.new spec
         | 
| 121 | 
            +
                        s += "pod '#{pod.name}', '~> #{pod.version}'\n"
         | 
| 122 | 
            +
                      end
         | 
| 123 | 
            +
                      s+= <<END
         | 
| 83 124 |  | 
| 84 125 | 
             
            target :unit_tests, :exclusive => true do
         | 
| 85 126 | 
             
              link_with 'UnitTests'
         | 
| @@ -90,71 +131,80 @@ target :unit_tests, :exclusive => true do | |
| 90 131 | 
             
            end
         | 
| 91 132 |  | 
| 92 133 | 
             
            END
         | 
| 93 | 
            -
                  end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                  def create_liftoff_templates(project_name, specs)
         | 
| 96 | 
            -
                    path = '.liftoff/templates'
         | 
| 97 | 
            -
                    FileUtils.mkdir_p path
         | 
| 98 | 
            -
                    File.open(path+'/Podfile', 'w') do |f|
         | 
| 99 | 
            -
                      f.puts pod_file_content(project_name, specs)
         | 
| 100 134 | 
             
                    end
         | 
| 101 | 
            -
                  end
         | 
| 102 135 |  | 
| 103 | 
            -
             | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 136 | 
            +
                    def create_liftoff_templates
         | 
| 137 | 
            +
                      # should we use Dir.home?
         | 
| 138 | 
            +
                      path = File.join '.liftoff', 'templates'
         | 
| 139 | 
            +
                      FileUtils.mkdir_p path
         | 
| 107 140 |  | 
| 108 | 
            -
             | 
| 109 | 
            -
             | 
| 141 | 
            +
                      File.open(File.join(path, 'Podfile'), 'w') do |f|
         | 
| 142 | 
            +
                        f.puts pod_file_content
         | 
| 143 | 
            +
                      end
         | 
| 144 | 
            +
                    end
         | 
| 110 145 |  | 
| 111 | 
            -
                     | 
| 146 | 
            +
                    def create_project
         | 
| 147 | 
            +
                      create_liftoff_templates
         | 
| 148 | 
            +
                      system "liftoff", "-n", name, '--cocoapods', '--strict-prompts', out: $stdout, in: $stdin
         | 
| 149 | 
            +
                    end
         | 
| 112 150 |  | 
| 113 | 
            -
                     | 
| 114 | 
            -
                       | 
| 115 | 
            -
                         | 
| 151 | 
            +
                    def self.humanize_pod_name(name)
         | 
| 152 | 
            +
                      name = name.gsub /(^|\W)(\w)/ do |match|
         | 
| 153 | 
            +
                        Regexp.last_match[2].upcase
         | 
| 116 154 | 
             
                      end
         | 
| 155 | 
            +
                      name = name.gsub /[^a-z]/i, ''
         | 
| 156 | 
            +
                      name.gsub /^[A-Z]*([A-Z][^A-Z].*)$/, '\1'
         | 
| 117 157 | 
             
                    end
         | 
| 118 158 | 
             
                  end
         | 
| 119 159 |  | 
| 120 | 
            -
                  def  | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
                           | 
| 160 | 
            +
                  def random_specs
         | 
| 161 | 
            +
                    [].tap do |picked_specs|
         | 
| 162 | 
            +
                      # yes, this looks ugly but filtering all_specs before takes 10s on a MBP 2011
         | 
| 163 | 
            +
                      while picked_specs.length < 3
         | 
| 164 | 
            +
                        picked_spec = all_specs.sample
         | 
| 165 | 
            +
                        unless picked_specs.include? picked_spec
         | 
| 166 | 
            +
                          if picked_spec.specification.available_platforms.map(&:name).include?(:ios)
         | 
| 167 | 
            +
                            picked_specs << picked_spec
         | 
| 168 | 
            +
                          end
         | 
| 129 169 | 
             
                        end
         | 
| 130 170 | 
             
                      end
         | 
| 131 171 | 
             
                    end
         | 
| 172 | 
            +
                  end
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                  def next_configuration
         | 
| 175 | 
            +
                    Configuration.new random_specs
         | 
| 176 | 
            +
                  end
         | 
| 132 177 |  | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 135 | 
            -
                    end.join ''
         | 
| 178 | 
            +
                  def announce(configration)
         | 
| 179 | 
            +
                    UI.puts "\n\n"
         | 
| 136 180 |  | 
| 137 | 
            -
                     | 
| 181 | 
            +
                    20.times do |n|
         | 
| 182 | 
            +
                      clear_prev_line
         | 
| 183 | 
            +
                      line = (0..(configration.name.size/2)).map { THINGS.sample }
         | 
| 184 | 
            +
                      UI.puts line.join(" ")
         | 
| 185 | 
            +
                      sleep 0.02
         | 
| 186 | 
            +
                    end
         | 
| 138 187 |  | 
| 139 | 
            -
                     | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
                      UI.puts "Just a few more questions before we start:\n\n"
         | 
| 188 | 
            +
                    clear_prev_line
         | 
| 189 | 
            +
                    UI.puts configration.name.green
         | 
| 190 | 
            +
                  end
         | 
| 143 191 |  | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 192 | 
            +
                  def next_round
         | 
| 193 | 
            +
                    raise "requires block" unless block_given?
         | 
| 194 | 
            +
             | 
| 195 | 
            +
                    configration = next_configuration
         | 
| 196 | 
            +
                    announce configration
         | 
| 148 197 |  | 
| 149 | 
            -
             | 
| 198 | 
            +
                    if yesno "Are you happy with that project?"
         | 
| 199 | 
            +
                      yield true, configration
         | 
| 150 200 | 
             
                    else
         | 
| 151 201 | 
             
                      clear_prev_line
         | 
| 152 202 | 
             
                      clear_prev_line
         | 
| 153 | 
            -
                      UI.puts  | 
| 203 | 
            +
                      UI.puts configration.name.cyan
         | 
| 204 | 
            +
                      yield false, configration
         | 
| 154 205 | 
             
                    end
         | 
| 155 | 
            -
             | 
| 156 206 | 
             
                  end
         | 
| 157 | 
            -
             | 
| 207 | 
            +
             | 
| 158 208 | 
             
                  def update_if_necessary!
         | 
| 159 209 | 
             
                    Repo.new(ARGV.new(["update"])).run if @update
         | 
| 160 210 | 
             
                  end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cocoapods-roulette
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Heiko Behrens
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2014- | 
| 12 | 
            +
            date: 2014-10-09 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: bundler
         | 
| @@ -50,6 +50,7 @@ extra_rdoc_files: [] | |
| 50 50 | 
             
            files:
         | 
| 51 51 | 
             
            - lib/cocoapods_plugin.rb
         | 
| 52 52 | 
             
            - lib/cocoapods_roulette.rb
         | 
| 53 | 
            +
            - lib/pod/command/roulettathon.rb
         | 
| 53 54 | 
             
            - lib/pod/command/roulette.rb
         | 
| 54 55 | 
             
            - LICENSE
         | 
| 55 56 | 
             
            homepage: http://sirlantis.github.io/cocoapods-roulette/
         |