motion-paddle 1.0.0
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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +17 -0
- data/README.md +31 -0
- data/Rakefile +17 -0
- data/lib/motion-paddle.rb +3 -0
- data/lib/motion-paddle/paddle.rb +58 -0
- data/lib/motion-paddle/paddle_setup.rb +174 -0
- data/lib/motion-paddle/version.rb +3 -0
- data/motion-paddle.gemspec +23 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d18314dddcee9e6f6cbd2a39d46eab6021968cbf
|
4
|
+
data.tar.gz: 14600491324e0f7e30dfebdf606315a13ec6c096
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61fb59ae38bdc1308c5cc2b5de0ea25b8d9be0aebb942831d13795ee3fdcf492950e28e33022125fe632c889f4877d474c864458e38b20fba8a3c3e27d71320d
|
7
|
+
data.tar.gz: da03a3a5540a0b0ab501ab905b9e2498e45dc94ecbb26c652285e96ef1fa5af69b60939cbc1ed844635b5f464ab8ebf135b96271e6e84c97b058e9ad11ab3a88
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# motion-paddle
|
2
|
+
|
3
|
+
Paddle for vendors: <https://vendors.paddle.com>
|
4
|
+
You will have to vendor the Paddle framework yourself because I can't get the gem to bundle it properly.
|
5
|
+
More info coming soon.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'motion-paddle'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install motion-paddle
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.unshift('/Library/RubyMotion/lib')
|
2
|
+
|
3
|
+
ENV['platform'] = 'osx'
|
4
|
+
require 'motion/project/template/osx'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.require
|
9
|
+
rescue LoadError
|
10
|
+
# ignored
|
11
|
+
end
|
12
|
+
|
13
|
+
Motion::Project::App.setup do |app|
|
14
|
+
app.name = 'motion-paddle'
|
15
|
+
app.identifier = 'us.myepg.motion-paddle'
|
16
|
+
app.specs_dir = 'spec/'
|
17
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise 'This file must be required within a RubyMotion project Rakefile.'
|
3
|
+
end
|
4
|
+
|
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
|
7
|
+
|
8
|
+
def initialize(config)
|
9
|
+
@config = config
|
10
|
+
end
|
11
|
+
|
12
|
+
def set(var, val)
|
13
|
+
@config.info_plist['MotionPaddle'] ||= [{}]
|
14
|
+
@config.info_plist['MotionPaddle'].first[var.to_s] = val
|
15
|
+
send("#{var}=", val)
|
16
|
+
end
|
17
|
+
|
18
|
+
def inspect
|
19
|
+
{
|
20
|
+
product_id: product_id,
|
21
|
+
vendor_id: vendor_id,
|
22
|
+
api_key: api_key,
|
23
|
+
current_price: current_price,
|
24
|
+
dev_name: dev_name,
|
25
|
+
currency: currency,
|
26
|
+
image: image,
|
27
|
+
product_name: product_name,
|
28
|
+
trial_duration: trial_duration,
|
29
|
+
trial_text: trial_text,
|
30
|
+
product_image: product_image,
|
31
|
+
time_trial: time_trial
|
32
|
+
}.inspect
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Motion
|
37
|
+
module Project
|
38
|
+
class Config
|
39
|
+
variable :paddle
|
40
|
+
|
41
|
+
def paddle(&block)
|
42
|
+
@paddle ||= PaddleConfig.new(self)
|
43
|
+
@paddle.instance_eval(&block) unless block.nil?
|
44
|
+
@paddle
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
Motion::Project::App.setup do |app|
|
51
|
+
Dir.glob(File.join(File.dirname(__FILE__), '**/*.rb')).each do |file|
|
52
|
+
if app.respond_to?('exclude_from_detect_dependencies')
|
53
|
+
app.exclude_from_detect_dependencies << file
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
app.files.push(File.join(File.dirname(__FILE__), 'paddle_setup.rb'))
|
58
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
class MotionPaddle
|
2
|
+
class << self
|
3
|
+
def enabled?
|
4
|
+
(NSClassFromString('Paddle')!=nil)
|
5
|
+
end
|
6
|
+
|
7
|
+
def paddle_instance
|
8
|
+
Paddle.sharedInstance
|
9
|
+
end
|
10
|
+
|
11
|
+
def product_id
|
12
|
+
self.plist['product_id']
|
13
|
+
end
|
14
|
+
|
15
|
+
def vendor_id
|
16
|
+
self.plist['vendor_id']
|
17
|
+
end
|
18
|
+
|
19
|
+
def api_key
|
20
|
+
self.plist['api_key']
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_price
|
24
|
+
self.plist['current_price']
|
25
|
+
end
|
26
|
+
|
27
|
+
def dev_name
|
28
|
+
self.plist['dev_name']
|
29
|
+
end
|
30
|
+
|
31
|
+
def currency
|
32
|
+
self.plist['currency']
|
33
|
+
end
|
34
|
+
|
35
|
+
def image
|
36
|
+
self.plist['image']
|
37
|
+
end
|
38
|
+
|
39
|
+
def product_name
|
40
|
+
self.plist['product_name']
|
41
|
+
end
|
42
|
+
|
43
|
+
def trial_duration
|
44
|
+
self.plist['trial_duration']
|
45
|
+
end
|
46
|
+
|
47
|
+
def trial_text
|
48
|
+
self.plist['trial_text']
|
49
|
+
end
|
50
|
+
|
51
|
+
def product_image
|
52
|
+
self.plist['product_image']
|
53
|
+
end
|
54
|
+
|
55
|
+
def time_trial?
|
56
|
+
@time_trial = self.plist['time_trial'] && self.plist['time_trial'] != 0 && self.plist['time_trial'] != '0' if @time_trial.nil?
|
57
|
+
@time_trial
|
58
|
+
end
|
59
|
+
|
60
|
+
def time_trial=(time_trial)
|
61
|
+
paddle_instance.setIsTimeTrial(time_trial)
|
62
|
+
@time_trial = time_trial
|
63
|
+
end
|
64
|
+
|
65
|
+
def can_force_exit?
|
66
|
+
paddle_instance.canForceExit
|
67
|
+
end
|
68
|
+
|
69
|
+
def can_force_exit=(can_force_exit)
|
70
|
+
paddle_instance.setCanForceExit(can_force_exit)
|
71
|
+
end
|
72
|
+
|
73
|
+
def will_show_licensing_window?
|
74
|
+
paddle_instance.willShowLicensingWindow
|
75
|
+
end
|
76
|
+
|
77
|
+
def will_show_licensing_window=(will_show_licensing_window)
|
78
|
+
paddle_instance.setWillShowLicensingWindow(will_show_licensing_window)
|
79
|
+
end
|
80
|
+
|
81
|
+
def setup(window = nil, &block)
|
82
|
+
return unless enabled?
|
83
|
+
return unless self.plist
|
84
|
+
paddle = paddle_instance
|
85
|
+
paddle.setProductId(product_id)
|
86
|
+
paddle.setVendorId(vendor_id)
|
87
|
+
paddle.setApiKey(api_key)
|
88
|
+
paddle.startLicensing({ KPADCurrentPrice => current_price,
|
89
|
+
KPADDevName => dev_name,
|
90
|
+
KPADCurrency => currency,
|
91
|
+
KPADImage => image,
|
92
|
+
KPADProductName => product_name,
|
93
|
+
KPADTrialDuration => trial_duration,
|
94
|
+
KPADTrialText => trial_text,
|
95
|
+
KPADProductImage => product_image }, timeTrial: time_trial?, withWindow: window)
|
96
|
+
NSNotificationCenter.defaultCenter.addObserver(self, selector: 'activated:', name: KPADActivated, object: nil)
|
97
|
+
NSNotificationCenter.defaultCenter.addObserver(self, selector: 'continue:', name: KPADContinue, object: nil)
|
98
|
+
paddle.setDelegate(self)
|
99
|
+
# block.call unless block.nil?
|
100
|
+
listen(:activated, :continue, &block)
|
101
|
+
end
|
102
|
+
|
103
|
+
def listen(*names, &block)
|
104
|
+
return if block.nil?
|
105
|
+
@listeners ||= {}
|
106
|
+
names.each { |name|
|
107
|
+
@listeners[name.to_sym] ||= []
|
108
|
+
@listeners[name.to_sym] << block
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
def trial_days_left
|
113
|
+
paddle_instance.daysRemainingOnTrial
|
114
|
+
end
|
115
|
+
|
116
|
+
def activated?
|
117
|
+
paddle_instance.productActivated
|
118
|
+
end
|
119
|
+
|
120
|
+
def show_licencing
|
121
|
+
paddle_instance.showLicencing
|
122
|
+
end
|
123
|
+
|
124
|
+
alias :show_licensing :show_licencing
|
125
|
+
|
126
|
+
def activated_licence_code
|
127
|
+
paddle_instance.activatedLicenceCode
|
128
|
+
end
|
129
|
+
|
130
|
+
alias :activated_license_code :activated_licence_code
|
131
|
+
|
132
|
+
def activated_email
|
133
|
+
paddle_instance.activatedEmail
|
134
|
+
end
|
135
|
+
|
136
|
+
def deactivate_licence
|
137
|
+
paddle_instance.deactivateLicence
|
138
|
+
end
|
139
|
+
|
140
|
+
alias :deactivate_license :deactivate_licence
|
141
|
+
|
142
|
+
#internal
|
143
|
+
def plist
|
144
|
+
(@plist = NSBundle.mainBundle.objectForInfoDictionaryKey('MotionPaddle')) && (@plist = @plist.first) unless @plist
|
145
|
+
@plist
|
146
|
+
end
|
147
|
+
|
148
|
+
#internal
|
149
|
+
def call_listeners(name, *args)
|
150
|
+
@listeners ||= {}
|
151
|
+
@listeners[name.to_sym].each { |block| block.call(name.to_sym, *args) } if @listeners.has_key?(name.to_sym)
|
152
|
+
end
|
153
|
+
|
154
|
+
#internal
|
155
|
+
def activated(note)
|
156
|
+
call_listeners :activated, note
|
157
|
+
end
|
158
|
+
|
159
|
+
#internal
|
160
|
+
def continue(note)
|
161
|
+
call_listeners :continue, note
|
162
|
+
end
|
163
|
+
|
164
|
+
#internal
|
165
|
+
def licenceDeactivated(deactivated, message: deactivateMessage)
|
166
|
+
call_listeners :deactivated, deactivated, deactivateMessage
|
167
|
+
end
|
168
|
+
|
169
|
+
#internal
|
170
|
+
def paddleDidFailWithError(error)
|
171
|
+
call_listeners :error, error
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'motion-paddle/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'motion-paddle'
|
8
|
+
spec.version = MotionPaddle::VERSION
|
9
|
+
spec.authors = ['Eric Henderson']
|
10
|
+
spec.email = ['henderea@gmail.com']
|
11
|
+
spec.description = %q{A RubyMotion gem for using the Paddle selling framework.}
|
12
|
+
spec.summary = %q{A RubyMotion gem for using the Paddle framework}
|
13
|
+
spec.homepage = 'https://github.com/henderea/motion-paddle'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.3'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion-paddle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eric Henderson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
description: A RubyMotion gem for using the Paddle selling framework.
|
42
|
+
email:
|
43
|
+
- henderea@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/motion-paddle.rb
|
54
|
+
- lib/motion-paddle/paddle.rb
|
55
|
+
- lib/motion-paddle/paddle_setup.rb
|
56
|
+
- lib/motion-paddle/version.rb
|
57
|
+
- motion-paddle.gemspec
|
58
|
+
homepage: https://github.com/henderea/motion-paddle
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: A RubyMotion gem for using the Paddle framework
|
82
|
+
test_files: []
|
83
|
+
has_rdoc:
|