hound_breeder 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/hound_breeder/repo.js.coffee.erb +32 -11
- data/lib/hound_breeder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ec17a1c135949993ca828c0fe5c84b9e1bf471e
|
4
|
+
data.tar.gz: fe46477044b23c97ef9cdb8707ef7fe3a180cff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a985f95d6e14bf5ae8ae486857ddd9f3a37423d0ecf4887c6c4197244c832e575a7723c507b30c2bd74593a8046daa77a507ac99d6ca02f245e1f1d49dc0f6d1
|
7
|
+
data.tar.gz: 1fcb274d5eadc050a6fa3f7964901078f75dc60622dbb56faed64129c747e1c77b6eb1d8cef8696057786539fe0b1593fec2426ea06def044857123fa571a067
|
@@ -1,4 +1,4 @@
|
|
1
|
-
App.directive 'repo', ['Subscription', 'StripeCheckout', (Subscription, StripeCheckout) ->
|
1
|
+
App.directive 'repo', ['Subscription', 'StripeCheckout', 'User', (Subscription, StripeCheckout, User) ->
|
2
2
|
scope: true
|
3
3
|
templateUrl: '/templates/repo'
|
4
4
|
link: (scope, element, attributes) ->
|
@@ -6,9 +6,15 @@ App.directive 'repo', ['Subscription', 'StripeCheckout', (Subscription, StripeCh
|
|
6
6
|
scope.processing = true
|
7
7
|
|
8
8
|
scope.repo.$activate()
|
9
|
-
.catch(-> alert(
|
9
|
+
.catch((response) -> alert(errorMessage(response.data)))
|
10
10
|
.finally(-> scope.processing = false)
|
11
11
|
|
12
|
+
errorMessage = (responseData) ->
|
13
|
+
if responseData.errors.length > 0
|
14
|
+
responseData.errors.join("\n")
|
15
|
+
else
|
16
|
+
"Your repo failed to activate"
|
17
|
+
|
12
18
|
deactivateRepo = ->
|
13
19
|
scope.processing = true
|
14
20
|
|
@@ -16,15 +22,37 @@ App.directive 'repo', ['Subscription', 'StripeCheckout', (Subscription, StripeCh
|
|
16
22
|
.catch(-> alert('Your repo failed to deactivate.'))
|
17
23
|
.finally(-> scope.processing = false)
|
18
24
|
|
19
|
-
|
25
|
+
showCreditCardForm = ->
|
26
|
+
StripeCheckout.open(
|
27
|
+
name: scope.repo.full_plan_name,
|
28
|
+
amount: scope.repo.price_in_cents,
|
29
|
+
createSubscriptionWithNewCard
|
30
|
+
)
|
31
|
+
|
32
|
+
createSubscription = (user) ->
|
33
|
+
# if scope.repo.price_in_cents > 0
|
34
|
+
# if user.card_exists
|
35
|
+
# createSubscriptionWithExistingCard()
|
36
|
+
# else
|
37
|
+
# showCreditCardForm()
|
38
|
+
# else
|
39
|
+
activateRepo()
|
40
|
+
|
41
|
+
createSubscriptionWithExistingCard = ->
|
20
42
|
scope.processing = true
|
43
|
+
subscription = new Subscription(repo_id: scope.repo.id)
|
44
|
+
saveSubscription(subscription)
|
21
45
|
|
46
|
+
createSubscriptionWithNewCard = (stripeToken) ->
|
47
|
+
scope.processing = true
|
22
48
|
subscription = new Subscription(
|
23
49
|
repo_id: scope.repo.id
|
24
50
|
card_token: stripeToken.id
|
25
51
|
email_address: stripeToken.email
|
26
52
|
)
|
53
|
+
saveSubscription(subscription)
|
27
54
|
|
55
|
+
saveSubscription = (subscription) ->
|
28
56
|
subscription.$save().then((response) ->
|
29
57
|
scope.repo.active = true
|
30
58
|
scope.repo.stripe_subscription_id = response.stripe_subscription_id
|
@@ -55,12 +83,5 @@ App.directive 'repo', ['Subscription', 'StripeCheckout', (Subscription, StripeCh
|
|
55
83
|
else
|
56
84
|
deactivateRepo()
|
57
85
|
else
|
58
|
-
|
59
|
-
# StripeCheckout.open(
|
60
|
-
# name: scope.repo.full_plan_name,
|
61
|
-
# amount: scope.repo.price_in_cents,
|
62
|
-
# createSubscription
|
63
|
-
# )
|
64
|
-
# else
|
65
|
-
activateRepo()
|
86
|
+
User.get().$promise.then(createSubscription)
|
66
87
|
]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hound_breeder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Saito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|