apple_manifest_rails 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 697d45b8821e48c937d6c4e0b605c55fce1c5a1a
4
- data.tar.gz: 19f2f6e2939b48e17576dd25593c01b1bc666e04
5
- SHA512:
6
- metadata.gz: 069a1471eac1d5f5fad7c17dc44b63f47eaeb9f2575a4ca67cb1af0cad11a42daec32dce6ee6c4dff332d6ba50866d31208145b4b4ccac6c54b041eba4a53027
7
- data.tar.gz: 2363631a4ccca248568fafcd7ff189c0c73cf53fa581eb904c78b6f7a2518d88d4632bf72628eace78fa2ea0478e69f259e5cbe55f8fb49dbece0cc63316955e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGMyNGZjOTA5NzBiZmY5NGRiM2FjNDE0ZTFiOGU5MWRkZGFlYzIzYw==
5
+ data.tar.gz: !binary |-
6
+ OGMzYzM4M2QwY2FlOThjNmUyOGE5NDFkZDIwMmQ5ZGU3YmY0YzJhNg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZGVmZWQ0ZjEyOTBiN2UyMWM3Y2QzNmI3ZjE4MTA3MTc5N2E1M2Q2MDNjYmM2
10
+ OTdmNmZmY2RhMTcxOTVhMDEwYmU5NGM0NTUxNjRlZTZhYWZlYjEyNWU4NGM3
11
+ ZGIwMDJiYjJiY2ZiZmFjN2E5MTM2YTVkYmQ5NWI4MjYxMTk3Mzg=
12
+ data.tar.gz: !binary |-
13
+ ODk3OTA2NTNjYTNiYzhiNjQxMDBjNjZjYTliMjM3NGU5NjVhYmEwNzk2ZWZk
14
+ OWEwZjNlZjE4ZDAyZGEwYWU0YjIwMmFlY2ZmZWM4ZTg1N2Q5ZWZjNGFmNWNj
15
+ NWUwYWNiYTViZjlkYzQ3NGEyY2VmM2Y3ZTM5MjU5YzliMjVjNGY=
data/README.md CHANGED
@@ -4,17 +4,53 @@ Mountable Rails engine for capturing iOS UDID, check if IPA is installable, and
4
4
 
5
5
  Created for a Rails 3.2 app, might work in Rails 4, but I haven't tried. Let me know if it works!
6
6
 
7
+ ## Configuration
8
+
9
+ By default, the engine assumes the following directory structure in your rails project:
10
+
11
+ ```
12
+ rails_application/
13
+ app/
14
+ config/
15
+ ...
16
+ mobile_build/ <------------- config.template_dir
17
+ builds/
18
+ app.ipa <------------- config.ipa_path
19
+ manifest.plist
20
+ Profile.mobileconfig
21
+ ```
22
+
23
+ The app.ipa file is the actual compiled binary archive from Xcode. The engine will look at the embedded.mobileprovision to check if the client is installable.
24
+
25
+ ### Important Info
26
+
27
+ The plist and mobileconfig files are part of the UDID capture and install processes, they are templates that will be modified before being sent to the client. See the `templates` directory for what these files need to look like. Customize them to your liking and make sure they exist where expected.
28
+
29
+ The engine will not work without these.
30
+
31
+ ### Custom Initializer
32
+
33
+ Optionally, you can override these defaults by setting up an initializer in your rails app, e.g. `config/initializers/apple_manifest_rails.rb`
34
+
35
+ ```
36
+ AppleManifestRails.configure do |config|
37
+ config.page_title = "Who needs testflight? I've got apple_manifest_rails!"
38
+ config.template_dir = Rails.root.join('apple_manifest_rails', 'templates')
39
+ config.ipa_path = Rails.root.join('apple_manifest_rails', 'binaries', 'my_custom.ipa')
40
+ end
41
+ ```
42
+
7
43
  ## Install
8
44
 
9
- 1. Add to your rails gemfile
45
+ Step 1: Add to your rails gemfile
10
46
 
11
47
  ```ruby
12
48
  gem 'apple_manifest_rails'
13
49
  ```
14
50
 
15
- 2. Bundle
51
+ Step 2: `bundle install`
16
52
 
17
- 3. Mount the engine in `config/routes.rb`
53
+ Step 3: Mount the engine in `config/routes.rb`
18
54
 
19
55
  ```ruby
20
56
  Example::Application.routes.draw do
@@ -22,26 +58,7 @@ Example::Application.routes.draw do
22
58
  end
23
59
  ```
24
60
 
25
- 4. Start your server and navigate your iOS Safari browser to `/enroll`
26
-
27
- ## Configure
28
-
29
- The engine assumes the following directory structure in your rails project
30
- ```
31
- rails_application/
32
- app/
33
- config/
34
- ...
35
- mobile_build/
36
- builds/
37
- app.ipa
38
- manifest.plist
39
- Profile.mobileconfig
40
- ```
41
-
42
- The plist and mobileconfig files are part of the UDID capture and install processes, they are templates that will be modified before being sent to the client. See the `templates` directory for what these files need to look like. Customize them to your liking.
43
-
44
- The app.ipa file is the actual compiled binary archive from Xcode. The engine will look at the embedded.mobileprovision to check if the client is installable.
61
+ Step 4: Start your `rails server` and navigate iOS Safari to `/enroll` or `/install` (aliased)
45
62
 
46
63
  ## Contributing
47
64
 
@@ -8,13 +8,13 @@ module AppleManifestRails
8
8
  end
9
9
 
10
10
  def mobileconfig
11
- enroll = AppleManifest::Enroll::MobileConfig.new(request)
11
+ enroll = AppleManifestRails::Enroll::MobileConfig.new(request)
12
12
  enroll.write_mobileconfig
13
13
  send_file enroll.outfile_path, type: enroll.mime_type
14
14
  end
15
15
 
16
16
  def extract_udid
17
- parser = AppleManifest::Enroll::ResponseParser.new(request)
17
+ parser = AppleManifestRails::Enroll::ResponseParser.new(request)
18
18
  udid = parser.get 'UDID'
19
19
  version = parser.get 'VERSION'
20
20
  product = parser.get 'PRODUCT'
@@ -25,8 +25,8 @@ module AppleManifestRails
25
25
  # Check install
26
26
  def check_install
27
27
  @udid = params[:udid]
28
- @checker = AppleManifest::Install::Checker.new(@udid, 'app.ipa')
29
- set_itms_url if @checker.installable?
28
+ @checker = AppleManifestRails::Install::Checker.new
29
+ set_itms_url if @checker.installable?(@udid)
30
30
  end
31
31
 
32
32
  # Install (Send IPA)
@@ -36,7 +36,7 @@ module AppleManifestRails
36
36
  end
37
37
 
38
38
  def manifest
39
- install = AppleManifest::Install::IPA.new(request)
39
+ install = AppleManifestRails::Install::IPA.new(request)
40
40
  install.write_manifest
41
41
  send_file install.manifest_path
42
42
  end
@@ -47,12 +47,11 @@ module AppleManifestRails
47
47
 
48
48
  private
49
49
  def ipa_path
50
- filename = 'app.ipa'
51
- Rails.root.join('mobile_build', 'builds', filename).to_s
50
+ AppleManifestRails.ipa_path
52
51
  end
53
52
 
54
53
  def set_itms_url
55
- @itms_url = AppleManifest::Install::IPA.new(request).itms_uri
54
+ @itms_url = AppleManifestRails::Install::IPA.new(request).itms_uri
56
55
  end
57
56
  end
58
57
  end
@@ -1,4 +1,4 @@
1
- - if @checker.installable?
1
+ - if @checker.installable?(@udid)
2
2
  = javascript_tag "window.location.href = '#{@itms_url}'"
3
3
  - else
4
4
  Your device is not provisioned and so cannot install.
@@ -1,7 +1,7 @@
1
1
  - if @ios_device
2
2
  #device
3
3
  #header
4
- %h1#title Enroll Device
4
+ %h1#title Enroll Device / Install App
5
5
  #content
6
6
  %ol.instructions
7
7
  %li Tap Start to begin process
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>AppleManifestRails</title>
4
+ <title><%= AppleManifestRails.page_title %></title>
5
5
  <%= stylesheet_link_tag "apple_manifest_rails/application", :media => "all" %>
6
6
  <%= javascript_include_tag "apple_manifest_rails/application" %>
7
7
  <%= csrf_meta_tags %>
@@ -3,7 +3,7 @@ AppleManifestRails::Engine.routes.draw do
3
3
  get "/enroll/mobileconfig" => "manifest#mobileconfig"
4
4
  post "/enroll/mobileconfig/extract_udid" => "manifest#extract_udid"
5
5
  get "/enroll/mobileconfig/extract_udid/check_install" => "manifest#check_install"
6
- get "/install" => "manifest#install"
6
+ get "/install" => "manifest#enroll"
7
7
  get "/apple_manifest/manifest.plist" => "manifest#manifest"
8
- get "/install/(:appname).ipa" => "manifest#send_ipa"
9
- end
8
+ get "/install/app.ipa" => "manifest#send_ipa"
9
+ end
@@ -1,9 +1,41 @@
1
1
  require "apple_manifest_rails/engine"
2
2
 
3
- require "apple_manifest/enroll/mobile_config"
4
- require "apple_manifest/enroll/response_parser"
5
- require "apple_manifest/install/checker"
6
- require "apple_manifest/install/ipa"
3
+ require "apple_manifest_rails/enroll/mobile_config"
4
+ require "apple_manifest_rails/enroll/response_parser"
5
+ require "apple_manifest_rails/install/checker"
6
+ require "apple_manifest_rails/install/ipa"
7
+ require "apple_manifest_rails/template_dir"
7
8
 
8
9
  module AppleManifestRails
10
+ def self.configure
11
+ yield self
12
+ end
13
+
14
+ def self.page_title
15
+ @page_title ||= "AppleManifestRails v#{VERSION}"
16
+ end
17
+
18
+ def self.page_title=(str)
19
+ @page_title = str
20
+ end
21
+
22
+ def self.template_dir
23
+ @template_dir ||= TemplateDir.new(Rails.root.join('apple_manifest_templates'))
24
+ end
25
+
26
+ def self.template_dir=(path)
27
+ @template_dir ||= TemplateDir.new(path.to_s)
28
+ end
29
+
30
+ def self.template name
31
+ template_dir.join name
32
+ end
33
+
34
+ def self.ipa_path
35
+ @ipa_path ||= template_dir.join('builds', 'app.ipa')
36
+ end
37
+
38
+ def self.ipa_path= str
39
+ @ipa_path = str
40
+ end
9
41
  end
@@ -1,4 +1,4 @@
1
- module AppleManifest
1
+ module AppleManifestRails
2
2
  module Enroll
3
3
  class MobileConfig
4
4
  attr_accessor :next_url
@@ -25,7 +25,7 @@ module AppleManifest
25
25
 
26
26
  private
27
27
  def template_path
28
- Rails.root.join('mobile_build', 'Profile.mobileconfig').to_s
28
+ AppleManifestRails.template('Profile.mobileconfig')
29
29
  end
30
30
  end
31
31
  end
@@ -1,4 +1,4 @@
1
- module AppleManifest
1
+ module AppleManifestRails
2
2
  module Enroll
3
3
  class ResponseParser
4
4
  attr_accessor :body
@@ -1,17 +1,21 @@
1
1
  require 'fileutils'
2
2
  require 'zip/zipfilesystem'
3
3
 
4
- module AppleManifest
4
+ module AppleManifestRails
5
5
  module Install
6
6
  class Checker
7
7
  attr_accessor :mobileprovision
8
8
 
9
- def initialize udid, appname
10
- ipa_path = Rails.root.join('mobile_build', 'builds', appname).to_s
9
+ def initialize
10
+ ipa_path = AppleManifestRails.ipa_path
11
11
  extract_mobileprovision_from ipa_path
12
- @installable = self.mobileprovision.include? udid
13
12
  end
14
13
 
14
+ def installable? udid
15
+ self.mobileprovision.include? udid
16
+ end
17
+
18
+ private
15
19
  def extract_mobileprovision_from ipa_path
16
20
  tempfile = File.join('tmp', 'embedded.mobileprovision')
17
21
  FileUtils.rm tempfile if File.exists? tempfile
@@ -26,10 +30,6 @@ module AppleManifest
26
30
  File.open(tempfile) {|f| self.mobileprovision = f.read }
27
31
  FileUtils.rm tempfile
28
32
  end
29
-
30
- def installable?
31
- @installable
32
- end
33
33
  end
34
34
  end
35
35
  end
@@ -1,12 +1,12 @@
1
- module AppleManifest
1
+ module AppleManifestRails
2
2
  module Install
3
3
  class IPA
4
4
 
5
5
  def template
6
- Rails.root.join('mobile_build', 'manifest.plist').to_s
6
+ AppleManifestRails.template('manifest.plist')
7
7
  end
8
-
9
- def tmp
8
+
9
+ def manifest_path
10
10
  Rails.root.join('tmp', 'manifest.plist').to_s
11
11
  end
12
12
 
@@ -25,16 +25,12 @@ module AppleManifest
25
25
  end
26
26
 
27
27
  def write_manifest
28
- File.open(tmp, "w") do |f|
28
+ File.open(manifest_path, "w") do |f|
29
29
  File.open(template, "r") do |tmpl|
30
30
  f.write tmpl.read.gsub("[IPAURL]", self.url)
31
31
  end
32
32
  end
33
33
  end
34
-
35
- def manifest_path
36
- Rails.root.join("tmp","manifest.plist").to_s
37
- end
38
34
  end
39
35
  end
40
36
  end
@@ -0,0 +1,30 @@
1
+ module AppleManifestRails
2
+ class TemplateDir
3
+ attr_accessor :dir
4
+ class InvalidTemplateDirError < StandardError ; end
5
+ class TemplateMissingError < StandardError ; end
6
+ EXPECTED_TEMPLATES = %w{Profile.mobileconfig manifest.plist}
7
+
8
+ def initialize dir
9
+ errors = []
10
+ self.dir = File.expand_path(dir.to_s)
11
+ if File.directory?(self.dir)
12
+ EXPECTED_TEMPLATES.each do |t|
13
+ path = self.join(t)
14
+ unless File.exists?(path)
15
+ errors << "Template missing! #{path}"
16
+ end
17
+ end
18
+ else
19
+ raise InvalidTemplateDirError, "Expected a template directory! #{self.dir}"
20
+ end
21
+ if errors.size > 0
22
+ raise TemplateMissingError, errors.join("\n")
23
+ end
24
+ end
25
+
26
+ def join *args
27
+ File.join(self.dir, args)
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module AppleManifestRails
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_manifest_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keyvan Fatehi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-06 00:00:00.000000000 Z
11
+ date: 2013-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -73,11 +73,12 @@ files:
73
73
  - app/views/apple_manifest_rails/manifest/install.html.haml
74
74
  - app/views/layouts/apple_manifest_rails/application.html.erb
75
75
  - config/routes.rb
76
- - lib/apple_manifest/enroll/mobile_config.rb
77
- - lib/apple_manifest/enroll/response_parser.rb
78
- - lib/apple_manifest/install/checker.rb
79
- - lib/apple_manifest/install/ipa.rb
80
76
  - lib/apple_manifest_rails/engine.rb
77
+ - lib/apple_manifest_rails/enroll/mobile_config.rb
78
+ - lib/apple_manifest_rails/enroll/response_parser.rb
79
+ - lib/apple_manifest_rails/install/checker.rb
80
+ - lib/apple_manifest_rails/install/ipa.rb
81
+ - lib/apple_manifest_rails/template_dir.rb
81
82
  - lib/apple_manifest_rails/version.rb
82
83
  - lib/apple_manifest_rails.rb
83
84
  - lib/tasks/apple_manifest_rails_tasks.rake
@@ -97,12 +98,12 @@ require_paths:
97
98
  - lib
98
99
  required_ruby_version: !ruby/object:Gem::Requirement
99
100
  requirements:
100
- - - '>='
101
+ - - ! '>='
101
102
  - !ruby/object:Gem::Version
102
103
  version: 1.9.2
103
104
  required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  requirements:
105
- - - '>='
106
+ - - ! '>='
106
107
  - !ruby/object:Gem::Version
107
108
  version: '0'
108
109
  requirements: []
@@ -112,3 +113,4 @@ signing_key:
112
113
  specification_version: 4
113
114
  summary: Rails engine for iOS app distribution
114
115
  test_files: []
116
+ has_rdoc: