cocoapods-roulette 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c8ac86bc800e201b5286ebbd68f24fe089ca9019
4
+ data.tar.gz: a648115bff5d2d289c0752a0b07ae3ad0e0d804a
5
+ SHA512:
6
+ metadata.gz: 044037c1c0726d3cd2bbf40d4cc48d52ada285bce03d0fd42242c94220723414c708a9ba4373a58920814a67dc4a46d3ede8f970d388c2b3790beeba4c83033c
7
+ data.tar.gz: 1e7c819911102f8dec75f75416f43c2818ea1469d0ce6fecf727195e21207396cae96293d194d9d06ca012b02cbf5c1ef2bb948261e433d214e0d753ce506d53
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fabio Pelosin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require 'pod/command/roulette'
@@ -0,0 +1,3 @@
1
+ class CocoapodsRoulette
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,163 @@
1
+ # encoding: utf-8
2
+ module Pod
3
+ class Command
4
+ class Roulette < Command
5
+ self.summary = "Creates a new iOS project with three random pods"
6
+
7
+ self.description = <<-DESC
8
+ Creates a new iOS project with three random pods.
9
+ DESC
10
+
11
+ def self.options
12
+ [[
13
+ "--update", "Run `pod repo update` before rouletting",
14
+ ]].concat(super)
15
+ end
16
+
17
+ def initialize(argv)
18
+ @update = argv.flag?('update')
19
+ super
20
+ end
21
+
22
+ def clear_prev_line(value = nil)
23
+ print "\r\e[A\e[K"
24
+ value
25
+ end
26
+
27
+ def yesno(question, default = false)
28
+ UI.print question
29
+ UI.print(default ? ' (Y/n) ' : ' (y/N) ')
30
+ answer = UI.gets.chomp
31
+
32
+ if answer.empty?
33
+ clear_prev_line default
34
+ elsif /^y$/i =~ answer
35
+ clear_prev_line true
36
+ elsif /^n$/i =~ answer
37
+ clear_prev_line false
38
+ else
39
+ UI.puts "Please answer with 'y' or 'n'.".red
40
+ yesno question, default
41
+ end
42
+ end
43
+
44
+ def liftoff_installed?
45
+ `which liftoff`
46
+ $?.exitstatus.zero?
47
+ end
48
+
49
+ def validate!
50
+ super
51
+
52
+ unless liftoff_installed?
53
+ help! [
54
+ 'PodRoulette requires Liftoff (which has to be installed through Homebrew). Please install it first.',
55
+ '',
56
+ '$ brew tap thoughtbot/formulae',
57
+ '$ brew install liftoff'
58
+ ].join("\n")
59
+ end
60
+ end
61
+
62
+ def humanize_pod_name(name)
63
+ name = name.gsub /(^|\W)(\w)/ do |match|
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'
68
+ end
69
+
70
+ def tweet_text(project_name)
71
+ random_emoji = [0x1F602, 0x1F604, 0x1F60D, 0x1F61C, 0x1F62E, 0x1F62F, 0x1F633, 0x1F640].pack("U*").split("").sample
72
+ "#{random_emoji} got '#{project_name}' from `pod roulette` by @sirlantis and @hbehrens - fun stuff from @uikonf"
73
+ end
74
+
75
+ def pod_file_content(project_name, specs)
76
+ s = "platform :ios, '7.0'\n\n"
77
+
78
+ specs.each do |spec|
79
+ pod = Pod::Specification::Set::Presenter.new spec
80
+ s += "pod '#{pod.name}', '~> #{pod.version}'\n"
81
+ end
82
+ s+= <<END
83
+
84
+ target :unit_tests, :exclusive => true do
85
+ link_with 'UnitTests'
86
+ pod 'Specta'
87
+ pod 'Expecta'
88
+ pod 'OCMock'
89
+ pod 'OHHTTPStubs'
90
+ end
91
+
92
+ 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
+ end
101
+ end
102
+
103
+ def create_project(project_name, specs)
104
+ create_liftoff_templates project_name, specs
105
+ system "liftoff", "-n", project_name, '--cocoapods', '--strict-prompts', out: $stdout, in: $stdin
106
+ end
107
+
108
+ def run
109
+ update_if_necessary!
110
+
111
+ @all_specs = Pod::SourcesManager.all_sets
112
+
113
+ catch :done do
114
+ while true do
115
+ next_round
116
+ end
117
+ end
118
+ end
119
+
120
+ def next_round
121
+
122
+ picked_specs = []
123
+ # yes, this looks ugly but filtering all_specs before takes 10s on a MBP 2011
124
+ while picked_specs.length < 3
125
+ picked_spec = @all_specs.sample
126
+ unless picked_specs.include? picked_spec
127
+ if picked_spec.specification.available_platforms.map(&:name).include?(:ios)
128
+ picked_specs << picked_spec
129
+ end
130
+ end
131
+ end
132
+
133
+ project_name = picked_specs.map do |random_spec|
134
+ humanize_pod_name random_spec.name
135
+ end.join ''
136
+
137
+ UI.puts "\n" + project_name.green
138
+
139
+ if yesno "Are you happy with that project?"
140
+ UI.puts "\nPerfect, your project will use"
141
+ UI.puts (picked_specs.map(&:name).join ", ") + "."
142
+ UI.puts "Just a few more questions before we start:\n\n"
143
+
144
+ if create_project project_name, picked_specs
145
+ sleep 0.1 # make sure all output from liftoff has been flushed
146
+ UI.puts "\n\n" + tweet_text(project_name) + "\n\n"
147
+ end
148
+
149
+ throw :done
150
+ else
151
+ clear_prev_line
152
+ clear_prev_line
153
+ UI.puts project_name.cyan
154
+ end
155
+
156
+ end
157
+
158
+ def update_if_necessary!
159
+ Repo.new(ARGV.new(["update"])).run if @update
160
+ end
161
+ end
162
+ end
163
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-roulette
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Heiko Behrens
8
+ - Marcel Jackwerth
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-05-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: A CocoaPods plugin which gives you a combination of three random pods
43
+ to build your app with.
44
+ email:
45
+ - mail@heikobehrens.net
46
+ - marceljackwerth@gmail.com
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - lib/cocoapods_plugin.rb
52
+ - lib/cocoapods_roulette.rb
53
+ - lib/pod/command/roulette.rb
54
+ - LICENSE
55
+ homepage: https://github.com/cocoapods/cocoapods-roulette
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.0.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Builds an empty project with three random gems.
79
+ test_files: []