motion-fabric 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/motion-fabric.rb +157 -0
  3. metadata +58 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3aa34823f8079f1c54b3855762154e63800b2d08
4
+ data.tar.gz: 1febab75109159bf77749b3ec3995205e9e76d0e
5
+ SHA512:
6
+ metadata.gz: 2044f8ff53c7f12210e3fde5359a5855b1ba522bc1a2a7c27a1ba23abe600acdfec14de1e3d0dc73c2c90adda59ef49ea4d85eb02edb9e769c184239f784fc96
7
+ data.tar.gz: 7746c254b19a916cff2c4953017f6cdc8f60f2c6fe6200f0b9d44a370ec0d4c07640d2758eda92987a27b8fbfd2d5ee3c4cde5b18f40426d7e08a6bd6232d5e4
@@ -0,0 +1,157 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (c) 2016, HipByte SPRL and contributors
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # 1. Redistributions of source code must retain the above copyright notice, this
10
+ # list of conditions and the following disclaimer.
11
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+
26
+ unless defined?(Motion::Project::Config)
27
+ raise "This file must be required within a RubyMotion project Rakefile."
28
+ end
29
+
30
+ class FabricKitConfig
31
+ attr_accessor :name, :info
32
+
33
+ def initialize(name)
34
+ @name = name
35
+ @info = {}
36
+ end
37
+
38
+ def to_hash
39
+ {
40
+ 'KitInfo' => info,
41
+ 'KitName' => name
42
+ }
43
+ end
44
+ end
45
+
46
+ class FabricConfig
47
+ attr_accessor :api_key, :build_secret, :kits, :beta_block
48
+
49
+ def api_key=(api_key)
50
+ @config.info_plist['Fabric']['APIKey'] = api_key
51
+ @api_key = api_key
52
+ end
53
+
54
+ def initialize(config)
55
+ @config = config
56
+ config.info_plist['Fabric'] ||= {}
57
+ config.info_plist['Fabric']['Kits'] ||= []
58
+ end
59
+
60
+ def kit(name, &block)
61
+ kit_config = FabricKitConfig.new(name)
62
+ block.call(kit_config.info) if block
63
+ config.info_plist['Fabric']['Kits'] << kit_config.to_hash
64
+ end
65
+
66
+ def beta(&block)
67
+ @beta_block = block if block
68
+ end
69
+ end
70
+
71
+ module Motion::Project
72
+ class Config
73
+ variable :fabric
74
+
75
+ def fabric(&block)
76
+ @fabric ||= FabricConfig.new(self)
77
+ block.call(@fabric) if block
78
+ @fabric
79
+ end
80
+ end
81
+ end
82
+
83
+ Motion::Project::App.setup do |app|
84
+ app.pods do
85
+ pod 'Fabric', '~> 1.6'
86
+ pod 'Crashlytics', '~> 3.7'
87
+ end
88
+ end
89
+
90
+ def fabric_setup(&block)
91
+ pods_root = Motion::Project::CocoaPods::PODS_ROOT
92
+ api_key = App.config.fabric.api_key
93
+ build_secret = App.config.fabric.build_secret
94
+
95
+ App.fail "Fabric's api_key cannot be empty" unless api_key
96
+ App.fail "Fabric's build_secret cannot be empty" unless build_secret
97
+
98
+ block.call(pods_root, api_key, build_secret)
99
+ end
100
+
101
+ def fabric_run(platform)
102
+ dsym_path = App.config.app_bundle_dsym(platform)
103
+ project_dir = File.expand_path(App.config.project_dir)
104
+ env = {
105
+ BUILT_PRODUCTS_DIR: File.expand_path(File.join(App.config.versionized_build_dir(platform), App.config.bundle_filename)),
106
+ INFOPLIST_PATH: 'Info.plist',
107
+ DWARF_DSYM_FILE_NAME: File.basename(dsym_path),
108
+ DWARF_DSYM_FOLDER_PATH: File.expand_path(File.dirname(dsym_path)),
109
+ PROJECT_DIR: project_dir,
110
+ SRCROOT: project_dir,
111
+ PLATFORM_NAME: platform.downcase,
112
+ PROJECT_FILE_PATH: "",
113
+ CONFIGURATION: App.config_mode == 'development' ? 'debug' : 'release',
114
+ }
115
+ env_string = env.map { |k,v| "#{k}='#{v}'" }.join(' ')
116
+ fabric_setup do |pods_root, api_key, build_secret|
117
+ App.info "Fabric", "Uploading .dSYM file"
118
+ system("env #{env_string} sh #{pods_root}/Fabric/run #{api_key} #{build_secret}")
119
+ end
120
+ end
121
+
122
+ namespace :fabric do
123
+ task :setup do
124
+ fabric_run(App.config_without_setup.deploy_platform)
125
+ Rake::Task["fabric:dsym:simulator"].invoke
126
+ end
127
+
128
+ task :upload do
129
+ App.config.fabric.beta_block.call if App.config.fabric.beta_block
130
+
131
+ file = File.join(Dir.tmpdir, 'motion-fabric.rb')
132
+ open(file, 'w') { |io| io.write 'CRASHLYTICS_BETA = true' }
133
+ App.config.files << file
134
+ Rake::Task["archive"].invoke
135
+
136
+ # Force a link of the executable on the next build by touching the project
137
+ # file since we dont want motion-fabric.rb to be included for a non-beta build.
138
+ FileUtils.touch App.config.project_file
139
+
140
+ fabric_setup do |pods_root, api_key, build_secret|
141
+ App.info "Fabric", "Uploading IPA"
142
+ notes_path = File.join(Dir.tmpdir, 'fabric-notes.txt')
143
+ open(notes_path, 'w') { |io| io.write ENV['notes'] }
144
+ system(%Q{#{pods_root}/Crashlytics/submit #{api_key} #{build_secret} -ipaPath "#{App.config.archive}" -notesPath "#{notes_path}"})
145
+ end
146
+ end
147
+
148
+ namespace :dsym do
149
+ task :device do
150
+ fabric_run(App.config_without_setup.deploy_platform)
151
+ end
152
+
153
+ task :simulator do
154
+ fabric_run(App.config_without_setup.local_platform)
155
+ end
156
+ end
157
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: motion-fabric
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - HipByte
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: motion-cocoapods
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ description: Fabric in your RubyMotion applications.
28
+ email: info@hipbyte.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/motion-fabric.rb
34
+ homepage: http://www.rubymotion.com
35
+ licenses:
36
+ - Proprietary
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.4.5
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: motion-fabric allows you to easily integrate Fabric in your RubyMotion applications.
58
+ test_files: []