frank-cucumber 0.9.5.pre2 → 0.9.5.pre3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- frank-cucumber (0.9.4)
4
+ frank-cucumber (0.9.5.pre2)
5
5
  cucumber
6
6
  dnssd
7
7
  i18n
@@ -28,7 +28,10 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency( "json" ) # TODO: figure out how to be more permissive as to which JSON gems we allow
29
29
  s.add_dependency( "dnssd" )
30
30
  s.add_dependency( "thor" )
31
+ s.add_dependency( "xcodeproj" )
31
32
 
32
33
  s.add_development_dependency( "rr" )
33
34
  s.add_development_dependency( "yard" )
35
+ s.add_development_dependency( "pry" )
36
+ s.add_development_dependency( "pry-debugger" )
34
37
  end
@@ -1,6 +1,12 @@
1
+ begin
2
+ require 'pry'
3
+ rescue LoadError
4
+ end
5
+
1
6
  require 'thor'
2
7
  require 'frank-cucumber/launcher'
3
8
  require 'frank-cucumber/console'
9
+ require 'frank-cucumber/frankifier'
4
10
 
5
11
  module Frank
6
12
  class CLI < Thor
@@ -19,6 +25,8 @@ module Frank
19
25
  desc "setup", "set up your iOS app by adding a Frank subdirectory containing everything Frank needs"
20
26
  def setup
21
27
  directory ".", "Frank"
28
+
29
+ Frankifier.frankify!( File.expand_path('.') )
22
30
  end
23
31
 
24
32
  desc "update", "updates the frank server components inside your Frank directory"
@@ -0,0 +1,116 @@
1
+ require 'pathname'
2
+ require 'xcodeproj'
3
+
4
+ class Frankifier
5
+ include Thor::Shell
6
+
7
+ def self.frankify! root_dir
8
+ me = new(root_dir)
9
+ me.frankify!
10
+ me
11
+ end
12
+
13
+ def initialize( root_dir )
14
+ @root = Pathname.new( root_dir )
15
+ end
16
+
17
+ def frankify!
18
+ decide_on_project
19
+ decide_on_target
20
+ report_project_and_target
21
+ say ''
22
+ add_linker_flag
23
+ say ''
24
+ add_library_search_path
25
+ save_changes
26
+ end
27
+
28
+ private
29
+ def decide_on_project
30
+ projects = Pathname.glob( @root+'*.xcodeproj' )
31
+ xcodeproj = case projects.size
32
+ when 0
33
+ raise "There are no .xcodeproj files in this directory. Please move to your root project directory and try again."
34
+ when 1
35
+ projects.first
36
+ else
37
+ choice = ask_menu(
38
+ "I found more than one .xcodeproj. Which is the main app project that you wish to Frankify?",
39
+ projects.map(&:basename)
40
+ )
41
+ projects[choice]
42
+ end
43
+
44
+ @xcodeproj_path = xcodeproj
45
+ @project = Xcodeproj::Project.new(xcodeproj)
46
+ end
47
+
48
+ def decide_on_target
49
+ targets = @project.targets
50
+ @target = case targets.size
51
+ when 0
52
+ raise "Sorry, this project appears to contain no targets. Nothing I can do here."
53
+ when 1
54
+ targets.first
55
+ else
56
+ choice = ask_menu(
57
+ "I found more than one target in this project. Which is the main app target that you wish to Frankify?",
58
+ targets.map(&:name)
59
+ )
60
+ targets.to_a[choice]
61
+ end
62
+ end
63
+
64
+ def report_project_and_target
65
+ puts "Frankifying target [#{@target.name}] in project #{@xcodeproj_path.basename}"
66
+ end
67
+
68
+ def add_linker_flag
69
+ add_frank_entry_to_build_setting( 'OTHER_LDFLAGS', 'FRANK_LDFLAGS' )
70
+ end
71
+
72
+ def add_library_search_path
73
+ add_frank_entry_to_build_setting( 'LIBRARY_SEARCH_PATHS', 'FRANK_LIBRARY_SEARCH_PATHS' )
74
+ end
75
+
76
+ def add_frank_entry_to_build_setting( build_setting, entry_to_add )
77
+ setting_array = Array( debug_build_settings[build_setting] )
78
+
79
+ if setting_array.find{ |flag| flag.start_with? "$(FRANK_" }
80
+ say "It appears that your Debug configuration's #{build_setting} build setting already include some FRANK setup. Namely: #{setting_array.inspect}. I won't change anything here."
81
+ return
82
+ end
83
+
84
+ say "Adding $(inherited) and $(#{entry_to_add}) to your Debug configuration's #{build_setting} build setting ..."
85
+ setting_array.unshift "$(inherited)"
86
+ setting_array << "$(#{entry_to_add})"
87
+ setting_array.uniq! # mainly to avoid duplicate $(inherited) entries
88
+ say "... #{build_setting} is now: #{setting_array.inspect}"
89
+
90
+ debug_build_settings[build_setting] = setting_array
91
+ end
92
+
93
+ def debug_build_settings
94
+ @_debug_build_settings ||= @target.build_configuration_list.build_settings('Debug')
95
+ end
96
+
97
+ def save_changes
98
+ @project.save_as( @xcodeproj_path )
99
+ end
100
+
101
+ # TODO: send this as a pull request to thor
102
+ def ask_menu message, options
103
+ option_lines = options.each_with_index.map{ |o,i| "#{i+1}: #{o}" }
104
+ full_message = ([message,'']+option_lines+[">"]).join("\n")
105
+
106
+ allowed_range = (1..options.length)
107
+ valid_choice = nil
108
+ until valid_choice
109
+ choice = ask(full_message).to_i
110
+ valid_choice = choice if allowed_range.include?(choice)
111
+ say("You must choose an option between #{allowed_range.first} and #{allowed_range.last}") unless valid_choice
112
+ end
113
+ valid_choice-1
114
+ end
115
+
116
+ end
@@ -1,5 +1,5 @@
1
1
  module Frank
2
2
  module Cucumber
3
- VERSION = "0.9.5.pre2"
3
+ VERSION = "0.9.5.pre3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frank-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5.pre2
4
+ version: 0.9.5.pre3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -140,6 +140,22 @@ dependencies:
140
140
  - - ! '>='
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: xcodeproj
145
+ requirement: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ type: :runtime
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
143
159
  - !ruby/object:Gem::Dependency
144
160
  name: rr
145
161
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +188,38 @@ dependencies:
172
188
  - - ! '>='
173
189
  - !ruby/object:Gem::Version
174
190
  version: '0'
191
+ - !ruby/object:Gem::Dependency
192
+ name: pry
193
+ requirement: !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ type: :development
200
+ prerelease: false
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ - !ruby/object:Gem::Dependency
208
+ name: pry-debugger
209
+ requirement: !ruby/object:Gem::Requirement
210
+ none: false
211
+ requirements:
212
+ - - ! '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ none: false
219
+ requirements:
220
+ - - ! '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
175
223
  description: Use cucumber to test native iOS apps via Frank
176
224
  email:
177
225
  - gems@thepete.net
@@ -203,6 +251,7 @@ files:
203
251
  - lib/frank-cucumber/core_frank_steps.rb
204
252
  - lib/frank-cucumber/frank_helper.rb
205
253
  - lib/frank-cucumber/frank_localize.rb
254
+ - lib/frank-cucumber/frankifier.rb
206
255
  - lib/frank-cucumber/gateway.rb
207
256
  - lib/frank-cucumber/host_scripting.rb
208
257
  - lib/frank-cucumber/keyboard_helper.rb