rm_vendor 0.3.2 → 0.3.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 +8 -8
- data/lib/Vendor.rb +6 -10
- data/lib/project/buy.rb +2 -2
- data/lib/project/info.rb +18 -3
- data/lib/project/product.rb +5 -0
- data/lib/project/products.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDliOWI1YWQ0YzEzMGE3OTY5OTA0YzczZDA1Y2ZjY2YwNjI5NjUzMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzUyMTllMDFiYzFhYTk0ZTExYjAxNDAyNjFlYzc0MjViYzZmNWU2MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmU0MWJkMWQ2YmY1MmIzMWQ5YTA5OGM2ZTZhYjA0MTU0YmRlMzY4MGQwNjEz
|
10
|
+
Mjc3MWY2MDFkZGYxM2Q0MGQ2OTk3ZTM2ZmJiZWRjMTcyM2ZjN2E3NmM4ZmNm
|
11
|
+
YjRmNDQxZDE4ODZkMDljYjM3YmJkMjNiOWYxYWYwZThmNmQxMjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODgzYWNkOTNmZmQ2MjNhODdhNjA4MjVjZjI0ODlkMTkxNjFlZGJiYTExZmE1
|
14
|
+
ZGNlZTdjNWI4OTg4ZmFiNDQwODc3YWU4Nzk1NWYzMTJmZDRmNzc2MmRlOGQy
|
15
|
+
NTdhNDFhOWEzMjMwNTIxZmJjZjE4YTE3ZGQ4ODU4NGU1ODEwMTc=
|
data/lib/Vendor.rb
CHANGED
@@ -9,19 +9,15 @@ require 'sugarcube-nsuserdefaults'
|
|
9
9
|
require 'sugarcube-files'
|
10
10
|
require 'motion-cocoapods'
|
11
11
|
|
12
|
-
unless defined?(Motion::Project::Config)
|
13
|
-
raise "This file must be required within a RubyMotion project Rakefile."
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'motion/project/template/ios'
|
17
|
-
|
18
12
|
lib_dir_path = File.dirname(File.expand_path(__FILE__))
|
19
13
|
Motion::Project::App.setup do |app|
|
20
14
|
app.files.unshift(Dir.glob(File.join(lib_dir_path, "project/**/*.rb")))
|
21
15
|
|
22
16
|
app.frameworks += ['StoreKit']
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
|
18
|
+
if !App.osx?
|
19
|
+
app.pods ||= Motion::Project::CocoaPods.new(app)
|
20
|
+
app.pods.pod 'CocoaSecurity'
|
21
|
+
app.pods.pod 'CargoBay', '2.0.0'
|
22
|
+
end
|
27
23
|
end
|
data/lib/project/buy.rb
CHANGED
@@ -16,7 +16,7 @@ module Vendor
|
|
16
16
|
def purchase(params, &block)
|
17
17
|
@params = params
|
18
18
|
@block = block
|
19
|
-
SKPaymentQueue.defaultQueue.addPayment(SKPayment.
|
19
|
+
SKPaymentQueue.defaultQueue.addPayment(SKPayment.paymentWithProduct(@params.sk_product))
|
20
20
|
end
|
21
21
|
|
22
22
|
def restore(params, &block)
|
@@ -33,7 +33,7 @@ module Vendor
|
|
33
33
|
return if @params.nil?
|
34
34
|
password = @params.secret=="no_secret" ? nil : @params.secret
|
35
35
|
|
36
|
-
if success
|
36
|
+
if success && !App.osx? # If successfull and ios
|
37
37
|
# Verify transaction receipt
|
38
38
|
Vendor::Receipt.new(transaction.transactionReceipt, @params) do |block|
|
39
39
|
valid_receipt = block[:success] && block[:object][:status]==0
|
data/lib/project/info.rb
CHANGED
@@ -24,8 +24,22 @@ module Vendor
|
|
24
24
|
|
25
25
|
# INFO METHODS
|
26
26
|
def price
|
27
|
-
|
28
|
-
|
27
|
+
local_price = NSUserDefaults["#{@params.id}.price"] || @params.price
|
28
|
+
number_formatter = NSNumberFormatter.alloc.init
|
29
|
+
number_formatter.setFormatterBehavior(NSNumberFormatterBehavior10_4)
|
30
|
+
number_formatter.setNumberStyle(NSNumberFormatterCurrencyStyle)
|
31
|
+
number_formatter.setLocale(price_locale)
|
32
|
+
|
33
|
+
currency_string = number_formatter.internationalCurrencySymbol
|
34
|
+
format = number_formatter.positiveFormat
|
35
|
+
format.gsub("¤", currency_string)
|
36
|
+
number_formatter.setPositiveFormat(format)
|
37
|
+
|
38
|
+
return number_formatter.stringFromNumber(local_price)
|
39
|
+
end
|
40
|
+
|
41
|
+
def price_locale
|
42
|
+
@params[:price_locale]==nil ? NSLocale.alloc.initWithLocaleIdentifier("en_US") : @params[:price_locale]
|
29
43
|
end
|
30
44
|
|
31
45
|
def title
|
@@ -78,6 +92,7 @@ module Vendor
|
|
78
92
|
if exists
|
79
93
|
product = response.products.first
|
80
94
|
NSUserDefaults["#{@params.id}.price"] = product.price
|
95
|
+
@params[:price_locale] = product.priceLocale
|
81
96
|
NSUserDefaults["#{@params.id}.localizedTitle"] = product.localizedTitle
|
82
97
|
NSUserDefaults["#{@params.id}.localizedDescription"] = product.localizedDescription
|
83
98
|
end
|
@@ -89,4 +104,4 @@ module Vendor
|
|
89
104
|
@block.call({success: false, response: nil, error: error}.to_object)
|
90
105
|
end
|
91
106
|
end
|
92
|
-
end
|
107
|
+
end
|
data/lib/project/product.rb
CHANGED
@@ -16,6 +16,7 @@ module Vendor
|
|
16
16
|
# Update product and set exists variable
|
17
17
|
@info = Vendor::Info.new(@params) do |block|
|
18
18
|
@exists = block.success
|
19
|
+
@params[:sk_product] = block.response.products.first if block.success
|
19
20
|
@block.call(block) unless @block.nil?
|
20
21
|
end
|
21
22
|
end
|
@@ -38,6 +39,10 @@ module Vendor
|
|
38
39
|
@info.price
|
39
40
|
end
|
40
41
|
|
42
|
+
def price_locale
|
43
|
+
@info.price_locale
|
44
|
+
end
|
45
|
+
|
41
46
|
def title
|
42
47
|
@info.title
|
43
48
|
end
|
data/lib/project/products.rb
CHANGED
@@ -7,7 +7,6 @@ module Vendor
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(products=[], &block)
|
10
|
-
NSLog "Products initialize"
|
11
10
|
# Set up products array
|
12
11
|
@products = []
|
13
12
|
|
@@ -28,8 +27,10 @@ module Vendor
|
|
28
27
|
:secret => "no_secret",
|
29
28
|
:subscription => false,
|
30
29
|
:price => "0.99",
|
30
|
+
:price_locale => nil,
|
31
31
|
:title => "No Title",
|
32
|
-
:desc => "No Description."
|
32
|
+
:desc => "No Description.",
|
33
|
+
:sk_product => nil
|
33
34
|
}
|
34
35
|
options = default_options.merge(product)
|
35
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rm_vendor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Holger Sindbaek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|