hound_breeder 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9987a3922f7f78e34869489cab03b1f47c96a7f2
4
- data.tar.gz: 8af1d6965d346402544c7339c191cb06ca2344fd
3
+ metadata.gz: 5ec17a1c135949993ca828c0fe5c84b9e1bf471e
4
+ data.tar.gz: fe46477044b23c97ef9cdb8707ef7fe3a180cff8
5
5
  SHA512:
6
- metadata.gz: 7518f6ed42cd69cfed8837e5e7f26ca02a924a23a5b1dac116f1b4c5353c6c5174a8991ff8301c7d1aa54c475c40c8cbb9a9132b53589509a8980d5cab79398e
7
- data.tar.gz: 65fd4f72922e5dd3537ca6bf3b97c808f0b06017c631433a9d25bd1d3bddea1263f5b7e28cb315e9b6995a08ee9dba042e00198810edf2c6d1697501cb5d9194
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('Your repo failed to activate.'))
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
- createSubscription = (stripeToken) ->
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
- # if scope.repo.price_in_cents > 0
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
  ]
@@ -1,3 +1,3 @@
1
1
  module HoundBreeder
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
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
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: 2014-10-29 00:00:00.000000000 Z
11
+ date: 2015-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails