motion-paddle 1.1.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f966fce013a984b0b52631cb2f160658c34a1dbb
4
- data.tar.gz: 6a5d6d7415a47bfb5b700632e102230c67dd0b79
3
+ metadata.gz: 7d64c5106e9c291b97d672fe970da18a8fcfbec2
4
+ data.tar.gz: d38f55e551cbb2c849e51847c128f07ab0c7ca46
5
5
  SHA512:
6
- metadata.gz: f384ec9bcceba89d13dbae13cf4e9118b895928906eedc9cae54c7b72f3ad61433e3117dd530366bcd62a411ed51af3c5367258d2428931022c9424decf68464
7
- data.tar.gz: e5d6ecb55a33ab9e18279179f7edbc3e0030af3c843e79e2fe7c82d32d12c160dd19080ce8716358ac76012373c15f16c531da900e5d4ee98f7fca6b113bf03b
6
+ metadata.gz: 5743c663e41558ceb8548243a423b841ea9a386a3b1b121cb2f630b9e406f05b1714b1c1bd8c83d5b9239ca0856dc4899a0107e0f6ce0560e3c4c48c80b94a0c
7
+ data.tar.gz: ef8171f480fd40e877cf382e64656d10fc94567a69b6c23abf48c345dcd2f2c9d115e0cac809ebdfc9bc3df4c9e6bcb1d0a63e58661cfe68bc4d79b47fe71e36
data/README.md CHANGED
@@ -77,6 +77,41 @@ def applicationDidFinishLaunching(notification)
77
77
  end
78
78
  ```
79
79
 
80
+ ### Choosing which store to build for
81
+
82
+ Use the `store` environment variable to choose which version of the Paddle framework
83
+ you wish to use: the one for the Paddle store or for the Mac App Store.
84
+
85
+ ```
86
+ rake store=paddle
87
+ rake store=mas
88
+ ```
89
+
90
+ If you are building an app that will run on both the Paddle store and the Mac App Store,
91
+ you will want to update your `Rakefile` to something like this:
92
+
93
+ ```ruby
94
+ Motion::Project::App.setup do |app|
95
+ #...
96
+ app.paddle do
97
+ if mas_store?
98
+ set :product_id, 'mas_product_id'
99
+ else
100
+ set :product_id, 'product_id'
101
+ end
102
+ set :vendor_id, 'vendor_id'
103
+ set :api_key, 'api_key'
104
+ set :store, ENV.fetch('store', 'paddle')
105
+
106
+ ...
107
+
108
+ end
109
+ end
110
+ ```
111
+
112
+ There is also a `paddle_store?` method available in the block passed to `app.paddle`
113
+
114
+
80
115
  ###Other `MotionPaddle` methods not in the above example
81
116
 
82
117
  * `MotionPaddle.enabled?` - true if Paddle framework is included
@@ -97,6 +132,8 @@ end
97
132
  * `MotionPaddle.will_continue_at_trial_end=` - set the above property
98
133
  * `MotionPaddle.trial_days_left` - get the number of days left in the trial
99
134
  * `MotionPaddle.deactivate_license` - deactivate the license
135
+ * `MotionPaddle.paddle_store?` - returns true if using the Paddle store
136
+ * `MotionPaddle.mas_store?` - returns true if using the Mac App Store
100
137
 
101
138
  **NOTE:** some methods offer a version that uses the spelling "licen**c**e". This is the name used for the methods in the Paddle framework, so I included this spelling as an option. The `will_show_licensing_window` methods are the only ones with it spelled with an "s" in the Paddle framework, and they do not have the "c" version in `MotionPaddle`.
102
139
 
@@ -3,12 +3,21 @@ unless defined?(Motion::Project::Config)
3
3
  end
4
4
 
5
5
  class PaddleConfig
6
- attr_accessor :product_id, :vendor_id, :api_key, :current_price, :dev_name, :currency, :image, :product_name, :trial_duration, :trial_text, :product_image, :time_trial
6
+ attr_accessor :product_id, :vendor_id, :api_key, :current_price, :dev_name, :currency, :image,
7
+ :product_name, :trial_duration, :trial_text, :product_image, :time_trial, :store
7
8
 
8
9
  def initialize(config)
9
10
  @config = config
10
11
  end
11
12
 
13
+ def mas_store?
14
+ ENV.fetch('store', 'paddle').downcase == 'mas'
15
+ end
16
+
17
+ def paddle_store?
18
+ ENV.fetch('store', 'paddle').downcase == 'paddle'
19
+ end
20
+
12
21
  def set(var, val)
13
22
  @config.info_plist["MotionPaddle_#{@config.short_version}"] ||= [{}]
14
23
  @config.info_plist["MotionPaddle_#{@config.short_version}"].first[var.to_s] = val
@@ -28,7 +37,8 @@ class PaddleConfig
28
37
  trial_duration: trial_duration,
29
38
  trial_text: trial_text,
30
39
  product_image: product_image,
31
- time_trial: time_trial
40
+ time_trial: time_trial,
41
+ store: store
32
42
  }.inspect
33
43
  end
34
44
  end
@@ -55,6 +65,12 @@ Motion::Project::App.setup do |app|
55
65
  end
56
66
 
57
67
  app.files.push(File.join(File.dirname(__FILE__), 'paddle_setup.rb'))
58
-
59
- app.pods.pod 'Paddle', git: 'https://github.com/PaddleHQ/Mac-Framework.git'
68
+
69
+ # include the correct framework for the store we're targeting
70
+ if ENV.fetch('store', 'paddle').downcase == 'paddle'
71
+ app.pods.pod 'Paddle', git: 'https://github.com/PaddleHQ/Mac-Framework.git'
72
+ elsif ENV.fetch('store', 'paddle').downcase == 'mas'
73
+ app.pods.pod 'Paddle-MAS', git: 'https://github.com/PaddleHQ/Paddle-MAS.git'
74
+ end
75
+
60
76
  end
@@ -1,7 +1,11 @@
1
1
  class MotionPaddle
2
2
  class << self
3
3
  def enabled?
4
- (NSClassFromString('Paddle')!=nil)
4
+ (NSClassFromString('Paddle') != nil)
5
+ end
6
+
7
+ def enabled_paddle_store?
8
+ enabled? && paddle_store?
5
9
  end
6
10
 
7
11
  def paddle_instance
@@ -12,6 +16,10 @@ class MotionPaddle
12
16
  enabled? && PaddleStoreKit.sharedInstance
13
17
  end
14
18
 
19
+ def store
20
+ self.plist['store'] || 'paddle'
21
+ end
22
+
15
23
  def product_id
16
24
  self.plist['product_id']
17
25
  end
@@ -62,64 +70,64 @@ class MotionPaddle
62
70
  end
63
71
 
64
72
  def time_trial=(time_trial)
65
- paddle_instance.setIsTimeTrial(time_trial) if enabled?
73
+ paddle_instance.setIsTimeTrial(time_trial) if enabled_paddle_store?
66
74
  @time_trial = time_trial
67
75
  end
68
76
 
69
77
  def can_force_exit?
70
- enabled? && paddle_instance.canForceExit
78
+ enabled_paddle_store? && paddle_instance.canForceExit
71
79
  end
72
80
 
73
81
  def can_force_exit=(can_force_exit)
74
- enabled? && paddle_instance.setCanForceExit(can_force_exit)
82
+ enabled_paddle_store? && paddle_instance.setCanForceExit(can_force_exit)
75
83
  end
76
84
 
77
85
  def will_show_licensing_window?
78
- enabled? && paddle_instance.willShowLicensingWindow
86
+ enabled_paddle_store? && paddle_instance.willShowLicensingWindow
79
87
  end
80
88
 
81
89
  def will_show_licensing_window=(will_show_licensing_window)
82
- enabled? && paddle_instance.setWillShowLicensingWindow(will_show_licensing_window)
90
+ enabled_paddle_store? && paddle_instance.setWillShowLicensingWindow(will_show_licensing_window)
83
91
  end
84
92
 
85
93
  def has_tracking_started?
86
- enabled? && paddle_instance.hasTrackingStarted
94
+ enabled_paddle_store? && paddle_instance.hasTrackingStarted
87
95
  end
88
96
 
89
97
  def has_tracking_started=(has_tracking_started)
90
- enabled? && paddle_instance.setHasTrackingStarted(has_tracking_started)
98
+ enabled_paddle_store? && paddle_instance.setHasTrackingStarted(has_tracking_started)
91
99
  end
92
100
 
93
101
  def will_simplify_views?
94
- enabled? && paddle_instance.willSimplifyViews
102
+ enabled_paddle_store? && paddle_instance.willSimplifyViews
95
103
  end
96
104
 
97
105
  def will_simplify_views=(will_simplify_views)
98
- enabled? && paddle_instance.setWillSimplifyViews(will_simplify_views)
106
+ enabled_paddle_store? && paddle_instance.setWillSimplifyViews(will_simplify_views)
99
107
  end
100
108
 
101
109
  def will_show_activation_alert?
102
- enabled? && paddle_instance.willShowActivationAlert
110
+ enabled_paddle_store? && paddle_instance.willShowActivationAlert
103
111
  end
104
112
 
105
113
  def will_show_activation_alert=(will_show_activation_alert)
106
- enabled? && paddle_instance.setWillShowActivationAlert(will_show_activation_alert)
114
+ enabled_paddle_store? && paddle_instance.setWillShowActivationAlert(will_show_activation_alert)
107
115
  end
108
116
 
109
117
  def will_continue_at_trial_end?
110
- enabled? && paddle_instance.willContinueAtTrialEnd
118
+ enabled_paddle_store? && paddle_instance.willContinueAtTrialEnd
111
119
  end
112
120
 
113
121
  def will_continue_at_trial_end=(will_continue_at_trial_end)
114
- enabled? && paddle_instance.setWillContinueAtTrialEnd(will_continue_at_trial_end)
122
+ enabled_paddle_store? && paddle_instance.setWillContinueAtTrialEnd(will_continue_at_trial_end)
115
123
  end
116
124
 
117
125
  def psk_valid_receipts
118
- enabled? && psk_instance.validReceipts
126
+ enabled_paddle_store? && psk_instance.validReceipts
119
127
  end
120
128
 
121
129
  def psk_receipt_for_product_id(product_id)
122
- enabled? && psk_instance.receiptForProductId(product_id)
130
+ enabled_paddle_store? && psk_instance.receiptForProductId(product_id)
123
131
  end
124
132
 
125
133
  def setup(window = nil, &block)
@@ -129,22 +137,24 @@ class MotionPaddle
129
137
  paddle.setProductId(product_id)
130
138
  paddle.setVendorId(vendor_id)
131
139
  paddle.setApiKey(api_key)
132
- product_info = {KPADCurrentPrice => current_price,
133
- KPADDevName => dev_name,
134
- KPADCurrency => currency,
135
- KPADImage => image,
136
- KPADTrialText => trial_text,
137
- KPADProductName => product_name,
138
- KPADProductImage => product_image }
139
- if time_trial?
140
- product_info.merge!({KPADTrialDuration => trial_duration})
140
+ if paddle_store?
141
+ product_info = {KPADCurrentPrice => current_price,
142
+ KPADDevName => dev_name,
143
+ KPADCurrency => currency,
144
+ KPADImage => image,
145
+ KPADTrialText => trial_text,
146
+ KPADProductName => product_name,
147
+ KPADProductImage => product_image }
148
+ if time_trial?
149
+ product_info.merge!({KPADTrialDuration => trial_duration})
150
+ end
151
+ paddle.startLicensing(product_info, timeTrial: time_trial?, withWindow: window)
152
+ NSNotificationCenter.defaultCenter.addObserver(self, selector: 'activated:', name: KPADActivated, object: nil)
153
+ NSNotificationCenter.defaultCenter.addObserver(self, selector: 'continue:', name: KPADContinue, object: nil)
154
+ paddle.setDelegate(self)
155
+ # block.call unless block.nil?
156
+ listen(:activated, :continue, &block)
141
157
  end
142
- paddle.startLicensing(product_info, timeTrial: time_trial?, withWindow: window)
143
- NSNotificationCenter.defaultCenter.addObserver(self, selector: 'activated:', name: KPADActivated, object: nil)
144
- NSNotificationCenter.defaultCenter.addObserver(self, selector: 'continue:', name: KPADContinue, object: nil)
145
- paddle.setDelegate(self)
146
- # block.call unless block.nil?
147
- listen(:activated, :continue, &block)
148
158
  end
149
159
 
150
160
  def listen(*names, &block)
@@ -157,7 +167,7 @@ class MotionPaddle
157
167
  end
158
168
 
159
169
  def psk_show(product_ids = nil, &block)
160
- return unless enabled?
170
+ return unless enabled_paddle_store?
161
171
  psk = psk_instance
162
172
  psk.setDelegate(self)
163
173
  if product_ids && !product_ids.empty?
@@ -169,7 +179,7 @@ class MotionPaddle
169
179
  end
170
180
 
171
181
  def psk_show_product(product_id, &block)
172
- return unless enabled?
182
+ return unless enabled_paddle_store?
173
183
  psk = psk_instance
174
184
  psk.setDelegate(self)
175
185
  psk.showProduct(product_id)
@@ -177,7 +187,7 @@ class MotionPaddle
177
187
  end
178
188
 
179
189
  def psk_purchase_product(product_id, &block)
180
- return unless enabled?
190
+ return unless enabled_paddle_store?
181
191
  psk = psk_instance
182
192
  psk.setDelegate(self)
183
193
  psk.purchaseProduct(product_id)
@@ -185,35 +195,43 @@ class MotionPaddle
185
195
  end
186
196
 
187
197
  def trial_days_left
188
- enabled? && paddle_instance.daysRemainingOnTrial
198
+ enabled_paddle_store? && paddle_instance.daysRemainingOnTrial
189
199
  end
190
200
 
191
201
  def activated?
192
- enabled? && paddle_instance.productActivated
202
+ enabled_paddle_store? && paddle_instance.productActivated
193
203
  end
194
204
 
195
205
  def show_licencing
196
- enabled? && paddle_instance.showLicencing
206
+ enabled_paddle_store? && paddle_instance.showLicencing
197
207
  end
198
208
 
199
209
  alias :show_licensing :show_licencing
200
210
 
201
211
  def activated_licence_code
202
- enabled? && paddle_instance.activatedLicenceCode
212
+ enabled_paddle_store? && paddle_instance.activatedLicenceCode
203
213
  end
204
214
 
205
215
  alias :activated_license_code :activated_licence_code
206
216
 
207
217
  def activated_email
208
- enabled? && paddle_instance.activatedEmail
218
+ enabled_paddle_store? && paddle_instance.activatedEmail
209
219
  end
210
220
 
211
221
  def deactivate_licence
212
- enabled? && paddle_instance.deactivateLicence
222
+ enabled_paddle_store? && paddle_instance.deactivateLicence
213
223
  end
214
224
 
215
225
  alias :deactivate_license :deactivate_licence
216
226
 
227
+ def paddle_store?
228
+ self.plist['store'] == 'paddle'
229
+ end
230
+
231
+ def mas_store?
232
+ self.plist['store'] == 'mas'
233
+ end
234
+
217
235
  #internal
218
236
  def plist
219
237
  (@plist = NSBundle.mainBundle.objectForInfoDictionaryKey("MotionPaddle_#{NSBundle.mainBundle.infoDictionary['CFBundleShortVersionString']}")) && (@plist = @plist.first) unless @plist
@@ -1,3 +1,3 @@
1
1
  module MotionPaddle
2
- VERSION = '1.1.7'
2
+ VERSION = '1.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-paddle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Henderson