combat 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -20,9 +20,18 @@ This creates a new <tt>config.yml</tt>.
20
20
  To run a new deploy type
21
21
 
22
22
  combat deploy
23
+
24
+ # Configuration
25
+
26
+ Create a <tt>~/.combatrc</tt> with default configuration for all combat projects, like this example:
27
+
28
+ ---
29
+ :host: my.server.com
30
+ :path: /var/www/myserver/mobile_apps/
31
+ :url: http://my.server.com/mobile_apps
23
32
 
24
33
  # TODO
25
34
 
26
35
  Todo stuff:
27
36
 
28
- * Android support
37
+ * Test Android support
data/bin/combat CHANGED
@@ -18,18 +18,47 @@ class Combat < Thor
18
18
 
19
19
  desc "setup", "Setup a new mobile project for deploying"
20
20
  def setup
21
+ defaults = load_defaults
22
+ name = Dir['*.xcodeproj']
23
+
24
+ if name.size == 1
25
+ name.first.gsub(/.xcodeproj/, '')
26
+ type = 'iphone'
27
+ else
28
+ name = Dir['AndroidManifest.xml']
29
+
30
+ if name.size == 1
31
+ name = File.basename(Dir.pwd)
32
+ type = 'android'
33
+ else
34
+ name = 'New project'
35
+ type = 'iphone'
36
+ end
37
+ end
38
+
39
+ defaults[:path] = File.join(defaults[:path], type, name) if defaults[:path]
40
+ defaults[:url] = File.join(defaults[:url], type, name) if defaults[:url]
41
+
21
42
  settings = {
22
- :type => 'iphone',
23
- :name => 'New project',
24
- :host => 'my.hostname.com',
25
- :path => '/var/www/my.hostname.com/deploy_folder',
26
- :url => 'http://my.hostname.com/deploy_folder',
27
- :remote_user => 'www-data'
43
+ :type => type,
44
+ :name => name,
45
+ :host => defaults[:host] || 'my.hostname.com',
46
+ :path => defaults[:path] || '/var/www/my.hostname.com/deploy_folder',
47
+ :url => defaults[:url] || 'http://my.hostname.com/deploy_folder',
48
+ :remote_user => defaults[:remote_user] || 'www-data'
28
49
  }
29
50
 
30
51
  unless File.exists?('combat.yml')
31
52
  create_file 'combat.yml', settings.to_yaml
32
53
  end
54
+
55
+ system "mkdir -p deployed"
56
+
57
+ if settings[:type] == 'iphone'
58
+ say "Combat has been setup for #{name}. Copy your #{name}.mobileprovision, #{name}.plist and #{name}.ipa to the deploy/ folder"
59
+ else
60
+ say "Combat has been setup for #{name}."
61
+ end
33
62
  end
34
63
 
35
64
  desc "deploy", "Deploy a project to the server for testing"
@@ -39,13 +68,20 @@ class Combat < Thor
39
68
  if @config.valid?
40
69
  system "ssh #{@config.user_and_host} 'mkdir -p #{@config.path}'"
41
70
  system "ssh #{@config.user_and_host} 'rm -fr #{@config.path}/*'"
42
- File.open('index.html', 'w+'){|x|
43
- str = generate_html_file
71
+
72
+ if @config.type == 'iphone'
73
+ system "scp deployed/#{@config.provision_file_name} #{@config.user_and_host}:#{@config.path}"
74
+ system "scp deployed/#{@config.plist_file} #{@config.user_and_host}:#{@config.path}"
75
+ system "scp deployed/#{@config.ipa_file} #{@config.user_and_host}:#{@config.path}"
76
+ else
77
+ system "scp bin/*.apk #{@config.user_and_host}:#{@config.path}"
78
+ end
79
+
80
+ File.open('deployed/index.html', 'w+'){|x|
44
81
  x.puts generate_html_file
45
82
  }
46
- system "scp index.html #{@config.user_and_host}:#{@config.path}"
47
- remove_file 'index.html'
48
- # system "scp -r app/config www-data@vz1.infinum.hr:l/labs.infinum.hr/rba/stage/config"
83
+ system "scp deployed/index.html #{@config.user_and_host}:#{@config.path}"
84
+ remove_file 'deployed/index.html'
49
85
 
50
86
  say "Successfully deployed to #{@config.url}"
51
87
  else
@@ -54,6 +90,15 @@ class Combat < Thor
54
90
  end
55
91
 
56
92
  no_tasks do
93
+ def load_defaults
94
+ defaults_file_path = File.expand_path('~/.combatrc')
95
+ if File.exists?(defaults_file_path)
96
+ YAML::load(File.read(defaults_file_path))
97
+ else
98
+ {}
99
+ end
100
+ end
101
+
57
102
  def load_config
58
103
  string = File.read("combat.yml")
59
104
  yml = YAML::load(string)
@@ -1,19 +1,22 @@
1
1
  class Settings
2
- attr_accessor :name, :url, :path, :filename, :plist_file, :provision_file_name, :remote_user, :host, :type, :template_file
2
+ attr_accessor :name, :url, :path, :filename, :plist_file, :provision_file_name, :remote_user, :host, :type, :template_file, :ipa_file
3
3
 
4
4
  def initialize(options)
5
5
  @name = options[:name]
6
6
  @url = options[:url]
7
+ @url+= "/" unless @url.match(/\/$/)
7
8
  @host = options[:host]
8
9
  @path = options[:path]
9
10
  @type = options[:type]
10
11
  @remote_user = options[:remote_user]
11
12
 
12
- @filename = @name.downcase.gsub(" ", "_")
13
- @provision_file_name = "#{@filename}_AdHoc.mobileprovision"
13
+ @filename = @name.gsub(" ", "_")
14
+ @provision_file_name = "#{@filename}.mobileprovision"
14
15
  @plist_file = "#{@filename}.plist"
16
+ @ipa_file = "#{@filename}.ipa"
15
17
  @plist_file_url = "#{@url}#{@plist_file}"
16
- @template_file = "#{COMBAT_ROOT}/templates/template_#{@type}.erb"
18
+ @template_file = options[:template] || "#{COMBAT_ROOT}/templates/template.erb"
19
+ @qrcode = "http://qrcode.kaywa.com/img.php?s=8&d=#{ERB::Util.url_encode(@url)}"
17
20
  end
18
21
 
19
22
  def user_and_host
@@ -40,9 +40,14 @@
40
40
  <div id="container">
41
41
  <h1><%= @name %></h1>
42
42
  <p>
43
- To install <%= @name %> take 2 steps on your iPhone or iPad device:
43
+ <% if @type == 'iphone' %>
44
+ To install <%= @name %> take 2 steps on your iPhone or iPad device:
45
+ <% else %>
46
+ To install just click on the following link on your Android device:
47
+ <% end %>
44
48
  </p>
45
49
  <ol>
50
+ <% if @type == 'iphone' %>
46
51
  <li>
47
52
  <a href="<%= @provision_file_name %>">
48
53
  Install provisioning file<br/>
@@ -54,7 +59,18 @@
54
59
  Install <%= @name %>
55
60
  </a>
56
61
  </li>
62
+ <% else %>
63
+ <li>
64
+ <a href="<%= @filename %>.apk">
65
+ Install <%= @name %>
66
+ </a>
67
+ </li>
68
+ <% end %>
57
69
  </ol>
70
+ <p>
71
+ QR code to this page
72
+ <img src="<%= @qrcode %>" />
73
+ </p>
58
74
  </div>
59
75
  </body>
60
76
  </html>
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 7
8
- version: "0.7"
7
+ - 8
8
+ version: "0.8"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Tomislav Car
@@ -13,15 +13,15 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-07-08 00:00:00 +02:00
16
+ date: 2011-07-29 00:00:00 +02:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
20
20
  description: Deploy your iPhone and Android apps to clients with ease. It's like Capistrano, only for mobile apps.
21
21
  email:
22
22
  - tomislav@infinum.hr
23
- executables: []
24
-
23
+ executables:
24
+ - combat
25
25
  extensions: []
26
26
 
27
27
  extra_rdoc_files:
@@ -34,7 +34,7 @@ files:
34
34
  - Gemfile.lock
35
35
  - bin/combat
36
36
  - lib/settings.rb
37
- - templates/template_iphone.erb
37
+ - templates/template.erb
38
38
  has_rdoc: true
39
39
  homepage: http://github.com/infinum/combat
40
40
  licenses: []