wox 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,5 @@
1
+ # 0.0.7 (17 Apr 2011)
2
+ TestFlight task now more closely mimics TestFlight API. See README for new format
3
+
1
4
  # 0.0.6 (16 Apr 2011)
2
5
  Build now defaults to building the first target in the application. This can be overridden by setting :target
data/README.md CHANGED
@@ -56,7 +56,8 @@ Ok so there's a few more things you can do, like creating ipa files and publishi
56
56
  testflight :publish, :api_token => 'nphsZ6nVXMl0brDEsevLY0wRfU6iP0NLaQH3nqoh8jG',
57
57
  :team_token => 'Qfom2HnGGJnXrUVnOKAxKAmpNO3wdQ9panhtqcA',
58
58
  :notes => proc { File.read("CHANGELOG") },
59
- :notify => 'Internal'
59
+ :distribution_lists => %w[Internal QA],
60
+ :notify => true
60
61
 
61
62
  end
62
63
  end
@@ -12,32 +12,31 @@ module Wox
12
12
  attr_reader :info_plist, :build_dir, :default_sdk
13
13
 
14
14
  def initialize options
15
+ @options = options
16
+
15
17
  options[:info_plist] ||= 'Resources/Info.plist'
16
18
  options[:version] ||= Plist::parse_xml(options[:info_plist])['CFBundleVersion']
17
19
  options[:project_name] ||= xcodebuild_list.first.scan(/project\s\"([^\"]+)/i).flatten.first
20
+ options[:full_name] ||= "#{self[:project_name]} #{self[:version]}"
18
21
  options[:build_dir] ||= 'build'
19
22
  options[:sdk] ||= 'iphoneos'
20
23
  options[:configuration] ||= 'Release'
21
24
  options[:target] ||= targets.first
22
- @options = options
25
+
26
+ if options[:ipa_name]
27
+ options[:ipa_file] ||= File.join self[:build_dir],
28
+ [self[:project_name], self[:version], self[:configuration], self[:ipa_name]].join("-") + ".ipa"
29
+ end
23
30
  end
24
31
 
25
32
  def apply options, &block
26
33
  yield BuildEnvironment.new @options.merge(options)
27
34
  end
28
35
 
29
- def project_name
30
- self[:project_name]
31
- end
32
-
33
36
  def version
34
37
  self[:version]
35
38
  end
36
-
37
- def full_name
38
- "#{project_name} #{version}"
39
- end
40
-
39
+
41
40
  def sdks
42
41
  @sdks ||= `xcodebuild -showsdks`.scan(/-sdk (.*?$)/m).flatten
43
42
  end
@@ -60,17 +59,13 @@ module Wox
60
59
 
61
60
  def [](name)
62
61
  fail "You need to specify :#{name} in Rakefile" unless @options[name]
63
- @options[name]
64
- end
65
-
66
- def configuration_sym
67
- self[:configuration].gsub(' ', '_').downcase
62
+ @options[name].respond_to?(:call) ? @options[name].call : @options[name]
68
63
  end
69
64
 
70
- def ipa_file
71
- File.join self[:build_dir], "#{project_name}-#{version}-#{configuration_sym}-#{self[:ipa_name]}.ipa"
65
+ def has_entry? name
66
+ @options[name]
72
67
  end
73
-
68
+
74
69
  private
75
70
 
76
71
  def xcodebuild_list
@@ -5,7 +5,7 @@ module Wox
5
5
 
6
6
  def build
7
7
  configuration = environment[:configuration]
8
- puts "Building #{environment.full_name} configuration:#{configuration}"
8
+ puts "Building #{environment[:full_name]} configuration:#{configuration}"
9
9
 
10
10
  log_file = File.join environment[:build_dir], "build-#{configuration}.log"
11
11
 
@@ -0,0 +1,19 @@
1
+ module Wox
2
+ module NumberHelper
3
+ def plural count, singular, plural
4
+ count == 1 ? singular : plural
5
+ end
6
+
7
+ def bytes_to_human_size bytes, precision = 1
8
+ kb = 1024
9
+ mb = 1024 * kb
10
+ gb = 1024 * mb
11
+ case
12
+ when bytes < kb; "%d #{plural(bytes, 'byte', 'bytes')}" % bytes
13
+ when bytes < mb; "%.#{precision}f #{plural((bytes / kb), 'kilobyte', 'kilobytes')}" % (bytes / kb)
14
+ when bytes < gb; "%.#{precision}f #{plural((bytes / mb), 'megabyte', 'megabytes')}" % (bytes / mb)
15
+ when bytes >= gb; "%.#{precision}f #{plural((bytes / gb), 'gigabyte', 'gigabytes')}" % (bytes / gb)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,9 +3,9 @@ module Wox
3
3
  include Environment
4
4
 
5
5
  def package
6
- configuration, sdk, ipa_file, build_dir = environment[:configuration], environment[:sdk], environment.ipa_file, environment[:build_dir]
6
+ configuration, sdk, ipa_file, build_dir = environment[:configuration], environment[:sdk], environment[:ipa_file], environment[:build_dir]
7
7
 
8
- app_file = File.join build_dir, "#{configuration}-#{sdk}", "#{environment.project_name}.app"
8
+ app_file = File.join build_dir, "#{configuration}-#{sdk}", "#{environment[:project_name]}.app"
9
9
  fail "Couldn't find #{app_file}" unless File.exists? app_file
10
10
 
11
11
  provisioning_profile_file = find_matching_mobile_provision environment[:provisioning_profile]
@@ -41,7 +41,7 @@ module Wox
41
41
  environment.apply options do |e|
42
42
  t = nil
43
43
  namespace :build do
44
- desc "Build #{e.full_name} with #{e[:configuration]} configuration"
44
+ desc "Build #{e[:full_name]} with #{e[:configuration]} configuration"
45
45
  t = task(name) { Builder.new(e).build }
46
46
  end
47
47
  tasks = BuildTasks.new(e, t)
@@ -57,7 +57,7 @@ module Wox
57
57
  environment.apply options.merge({:ipa_name => name}) do |e|
58
58
  t = nil
59
59
  namespace :ipa do
60
- desc "Creates #{e.ipa_file}"
60
+ desc "Creates #{e[:ipa_file]}"
61
61
  t = task(name => parent_task) { Packager.new(e).package }
62
62
  end
63
63
 
@@ -73,7 +73,7 @@ module Wox
73
73
  def testflight name, options
74
74
  environment.apply options do |e|
75
75
  namespace :testflight do
76
- desc "Publishes #{e.ipa_file} to testflight"
76
+ desc "Publishes #{e[:ipa_file]} to testflight"
77
77
  task(name => parent_task) { TestFlight.new(e).publish }
78
78
  end
79
79
  end
@@ -1,32 +1,41 @@
1
+ require 'wox/helpers/number_helper'
2
+
1
3
  module Wox
2
4
  class TestFlight < Task
3
5
  include Environment
6
+ include NumberHelper
4
7
 
5
- def notes
6
- environment[:notes].respond_to?(:call) ? environment[:notes].call : environment[:notes]
7
- end
8
-
9
- def lists
10
- environment[:notify].respond_to?(:join) ? environment[:notify].join(",") : environment[:notify]
8
+ def arg_to_string arg
9
+ arg.respond_to?(:join) ? arg.join(",") : arg
11
10
  end
12
-
13
- def publish
11
+
12
+ def api_args
14
13
  args = {
15
- :file => "@#{environment.ipa_file}",
14
+ :file => "@#{environment[:ipa_file]}",
16
15
  :api_token => environment[:api_token],
17
16
  :team_token => environment[:team_token],
18
- :notes => notes
17
+ :notes => environment[:notes]
19
18
  }
20
- if environment[:notify]
21
- args[:notify] = "True"
22
- args[:distribution_lists] = lists
23
- end
24
19
 
25
- arg_string = args.map {|k,v| "-F #{k}='#{v}'"}.join(" ")
20
+ args[:distribution_lists] = environment[:distribution_lists].join(",") if environment.has_entry? :distribution_lists
21
+ args[:notify] = environment[:notify] if environment.has_entry? :notify
22
+ args
23
+ end
24
+
25
+ def curl_arg_string
26
+ api_args.map {|k,v| "-F #{k}='#{v}'"}.join(" ")
27
+ end
28
+
29
+ def publish
30
+ ipa_file = environment[:ipa_file]
31
+
32
+ puts "Publishing to TestFlight"
33
+ puts "File: #{ipa_file} (#{bytes_to_human_size File.size?(ipa_file)})"
34
+ puts "Accessible To: #{environment[:distribution_lists].join(", ")}" if environment.has_entry? :distribution_lists
35
+ puts "After publish will notify team members" if environment.has_entry? :notify
26
36
 
27
- puts "Uploading ipa to TestFlight"
28
37
  log_file = File.join environment[:build_dir], "testflight.log"
29
- run_command "curl --progress-bar #{arg_string} http://testflightapp.com/api/builds.json", :results => log_file
38
+ run_command "curl --progress-bar #{curl_arg_string} http://testflightapp.com/api/builds.json", :results => log_file
30
39
  end
31
40
 
32
41
  end
@@ -1,3 +1,3 @@
1
1
  module Wox
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wox
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dave Newman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-16 00:00:00 +10:00
18
+ date: 2011-04-17 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -79,6 +79,7 @@ files:
79
79
  - lib/wox.rb
80
80
  - lib/wox/build_environment.rb
81
81
  - lib/wox/builder.rb
82
+ - lib/wox/helpers/number_helper.rb
82
83
  - lib/wox/packager.rb
83
84
  - lib/wox/task.rb
84
85
  - lib/wox/tasks.rb