munificent 1.0.0 → 2.0.2

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
  SHA256:
3
- metadata.gz: 1890f00087cf9fdcb1113548b998514df7fd04eef97eaa6171d9abee1c85c52b
4
- data.tar.gz: f032f530d03db2e9aa45a15ec396738aa06c8d1acce837e7eed638f08df7d1b6
3
+ metadata.gz: 342de290198e0a3620175b8be52d56cda5e0ec637c024cba658bd84c012d0e0c
4
+ data.tar.gz: f74501c8561c19484fa93b9aad33912fd7e95c339db05eebe3b1caff35b49049
5
5
  SHA512:
6
- metadata.gz: 67edb35c996448870855658929b66595be30f99715646e8c56dc4aebf964279e7eea9c80fc1fa6b436f2820853fb433e3217ce02a2c15470f699d6e202bdb613
7
- data.tar.gz: f962ed5ef92d44445228d829bbbb7c689c75e83b8992c43dbec0862d2a5f0144422ef7afecf5476567f6f40ba68aef63516309f8fdfdaf676c5b026f91c27103
6
+ metadata.gz: 2eb467e3f62cd5e8629ea7bc1587188faba0b409b2ad3f69bfe9a82eb2c60bbac454689356e88c86b14e0d11e2aba4e750bfaf8cb35971905afc850740a69a24
7
+ data.tar.gz: 9ea04f0a2cf48fb93bc4d7c20d3ed17f4d7e35176a22af5f6b127ba93c6425b92b42bc771033d75e05a5b70cf1a90af4923c9091ec61b8aa349f5908844f164f
@@ -1,11 +1,7 @@
1
- require "aasm"
2
-
3
1
  module Munificent
4
2
  class ApplicationRecord < ActiveRecord::Base
5
3
  self.abstract_class = true
6
4
 
7
- include AASM
8
-
9
5
  scope :where_money, -> (monies) {
10
6
  conditions = monies.each_with_object({}) { |(field_prefix, money), hash|
11
7
  hash["#{field_prefix}_decimals"] = money.cents
@@ -15,6 +15,8 @@ module Munificent
15
15
  end
16
16
  end
17
17
 
18
+ require "aasm"
19
+ include AASM
18
20
  aasm column: :state do
19
21
  state :draft, initial: true
20
22
  state :live
@@ -20,6 +20,8 @@ module Munificent
20
20
 
21
21
  validates :amount, presence: true, "munificent/donation_amount": true
22
22
 
23
+ require "aasm"
24
+ include AASM
23
25
  aasm column: :state do
24
26
  state :pending, initial: true
25
27
  state :cancelled
@@ -11,6 +11,8 @@ module Munificent
11
11
  PRO_SE = "pro_se".freeze,
12
12
  ].freeze
13
13
 
14
+ require "aasm"
15
+ include AASM
14
16
  aasm column: :state do
15
17
  state :inactive, initial: true
16
18
  state :active
@@ -1,3 +1,3 @@
1
1
  module Munificent
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "2.0.2".freeze
3
3
  end
@@ -0,0 +1,60 @@
1
+ require_relative "lib/munificent/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.required_ruby_version = ">= 3.1"
5
+
6
+ spec.name = "munificent"
7
+ spec.version = Munificent::VERSION
8
+ spec.authors = ["Elliot Crosby-McCullough"]
9
+ spec.email = ["elliot@smart-casual.com"]
10
+ spec.homepage = "https://github.com/SmartCasual/munificent"
11
+ spec.summary = "The core of Munificent, a game-bundle fundraising platform."
12
+ spec.license = "CC-BY-NC-SA-4.0"
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = spec.homepage
16
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/#{spec.version}/CHANGELOG.md"
17
+ spec.metadata["rubygems_mfa_required"] = "true"
18
+
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) {
20
+ Dir[
21
+ "{app,config,db,lib}/**/*",
22
+ "LICENCE",
23
+ "Rakefile",
24
+ "README.md",
25
+ "munificent.gemspec",
26
+ "test/factories/**/*_factory.rb",
27
+ "test/support/aasm_factories.rb",
28
+ ]
29
+ }
30
+
31
+ spec.add_dependency "aasm", "~> 5.2"
32
+ spec.add_dependency "after_commit_everywhere", "~> 1.1"
33
+ spec.add_dependency "authlogic", "~> 6.4"
34
+ spec.add_dependency "aws-sdk-kms", "~> 1.53" # AWS KMS support for `kms_encrypted`
35
+ spec.add_dependency "aws-sdk-rails", "~> 3.6"
36
+ spec.add_dependency "blind_index", "~> 2.3" # Encrypted query support for `lockbox`
37
+ spec.add_dependency "devise", "~> 4.8"
38
+ spec.add_dependency "factory_bot", "~> 6.2"
39
+ spec.add_dependency "factory_bot_namespaced_factories", "~> 0.1"
40
+ spec.add_dependency "factory_bot_rails", "~> 6.2"
41
+ spec.add_dependency "faraday", "~> 2.2"
42
+ spec.add_dependency "faraday-retry", "~> 1.0"
43
+ spec.add_dependency "hmac", "~> 2.1"
44
+ spec.add_dependency "kms_encrypted", "~> 1.4" # KMS support for `lockbox`
45
+ spec.add_dependency "lockbox", "~> 0.6" # Game key encryption
46
+ spec.add_dependency "monetize", "~> 1.12"
47
+ spec.add_dependency "money-rails", "~> 1.15"
48
+ spec.add_dependency "net-smtp", "~> 0.3"
49
+ spec.add_dependency "omniauth", "~> 2.0"
50
+ spec.add_dependency "omniauth-rails_csrf_protection", "~> 1.0"
51
+ spec.add_dependency "omniauth-token", "~> 1.0"
52
+ spec.add_dependency "omniauth-twitch_smartcasual", "~> 1.1"
53
+ spec.add_dependency "paypal-rest", "~> 1.1"
54
+ spec.add_dependency "rails", "~> 7.0"
55
+ spec.add_dependency "redis", "~> 4.6"
56
+ spec.add_dependency "rollbar", "~> 3.3"
57
+ spec.add_dependency "scrypt", "~> 3.0"
58
+ spec.add_dependency "sidekiq", "~> 6.4"
59
+ spec.add_dependency "stripe", "~> 5.43"
60
+ end
@@ -0,0 +1,33 @@
1
+ require_relative "../support/aasm_factories"
2
+
3
+ Munificent::Factories.define :bundle do
4
+ sequence(:name) { |n| "Bundle #{n}" }
5
+
6
+ fundraiser { Munificent::Fundraiser.active.first || association(:fundraiser, :active) }
7
+
8
+ transient do
9
+ price { Money.new(25_00, "GBP") }
10
+ end
11
+
12
+ bundle_tiers do
13
+ build_list(:bundle_tier, 1, bundle: @instance, price:)
14
+ end
15
+
16
+ trait :empty do
17
+ bundle_tiers do
18
+ build_list(:bundle_tier, 1, :empty, bundle: @instance, price:)
19
+ end
20
+ end
21
+
22
+ trait :tiered do
23
+ bundle_tiers do
24
+ [
25
+ build(:bundle_tier, bundle: @instance, price:),
26
+ build(:bundle_tier, bundle: @instance, price: Money.new(15_00, "GBP")),
27
+ build(:bundle_tier, bundle: @instance, price: Money.new(10_00, "GBP")),
28
+ ]
29
+ end
30
+ end
31
+
32
+ AASMFactories.init(self, @definition)
33
+ end
@@ -0,0 +1,21 @@
1
+ Munificent::Factories.define :bundle_tier do
2
+ bundle
3
+
4
+ price { Money.new(5_00, "GBP") }
5
+
6
+ transient do
7
+ game { build(:game, :with_keys) }
8
+ end
9
+
10
+ bundle_tier_games do
11
+ FactoryBot.build_list(:bundle_tier_game, 1, bundle_tier: @instance, game:)
12
+ end
13
+
14
+ trait :empty do
15
+ bundle_tier_games { [] }
16
+ end
17
+
18
+ trait :without_keys do
19
+ game { build(:game) }
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ Munificent::Factories.define :bundle_tier_game do
2
+ bundle_tier
3
+ association(:game, :with_keys)
4
+ end
@@ -0,0 +1,3 @@
1
+ Munificent::Factories.define :charity do
2
+ sequence(:name) { |n| "Charity #{n}" }
3
+ end
@@ -0,0 +1,3 @@
1
+ Munificent::Factories.define :curated_streamer do
2
+ sequence(:twitch_username) { |n| "streamer_#{n}" }
3
+ end
@@ -0,0 +1,26 @@
1
+ require_relative "../support/aasm_factories"
2
+
3
+ Munificent::Factories.define :donation do
4
+ donator
5
+ amount { Money.new(25_000) }
6
+ message { "Some standard message" }
7
+ sequence(:stripe_payment_intent_id) { |n| "stripe_payment_intent_id_#{n}" }
8
+
9
+ fundraiser { Munificent::Fundraiser.active.first || association(:fundraiser, :active) }
10
+
11
+ transient do
12
+ charity_split { {} }
13
+ end
14
+
15
+ AASMFactories.init(self, @definition)
16
+
17
+ after(:build) do |donation, evaluator|
18
+ evaluator.charity_split.each do |charity, split_amount|
19
+ donation.charity_splits.build(
20
+ donation:,
21
+ charity:,
22
+ amount: split_amount,
23
+ )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,4 @@
1
+ Munificent::Factories.define :donator_bundle do
2
+ bundle
3
+ donator
4
+ end
@@ -0,0 +1,22 @@
1
+ Munificent::Factories.define :donator_bundle_tier do
2
+ donator_bundle
3
+ bundle_tier
4
+
5
+ trait :fulfilled do
6
+ keys do
7
+ bundle_tier.games.map do |game|
8
+ build(:key, game:, donator_bundle_tier: @instance)
9
+ end
10
+ end
11
+ end
12
+
13
+ trait :unfulfilled
14
+
15
+ trait :locked do
16
+ unlocked { false }
17
+ end
18
+
19
+ trait :unlocked do
20
+ unlocked { true }
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ Munificent::Factories.define :donator do
2
+ sequence(:name) { |n| "Donator #{n}" }
3
+
4
+ trait :with_email_address do
5
+ sequence(:email_address) { |n| "test-#{n}@example.com" }
6
+ end
7
+
8
+ trait :confirmed do
9
+ confirmed { true }
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ Munificent::Factories.define :fundraiser do
2
+ sequence(:name) { |n| "Fundraiser #{n}" }
3
+
4
+ AASMFactories.init(self, @definition)
5
+
6
+ trait :with_live_bundle do
7
+ bundles do
8
+ build_list(:bundle, 1, :live)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ Munificent::Factories.define :game do
2
+ sequence(:name) { |n| "Game #{n}" }
3
+
4
+ trait :with_keys do
5
+ keys { FactoryBot.build_list(:key, 1, game: @instance) }
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ Munificent::Factories.define :key do
2
+ code { SecureRandom.uuid }
3
+ game
4
+ donator_bundle_tier { nil }
5
+
6
+ trait :unassigned
7
+
8
+ trait :assigned do
9
+ donator_bundle_tier
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ Munificent::Factories.define :payment
@@ -0,0 +1,20 @@
1
+ module AASMFactories
2
+ SCOPE = "Munificent".freeze
3
+
4
+ def self.init(definition_proxy, definition, class_name: nil)
5
+ class_name ||= definition.name
6
+
7
+ trimmed_name = class_name
8
+ .to_s
9
+ .gsub(/^#{SCOPE.downcase}_/, "")
10
+ .camelize
11
+
12
+ klass = "#{SCOPE}::#{trimmed_name}".constantize
13
+
14
+ klass.aasm.states.each do |state|
15
+ definition_proxy.trait(state.name) do
16
+ add_attribute(klass.aasm.attribute_name) { state.name }
17
+ end
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: munificent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Crosby-McCullough
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aasm
@@ -466,13 +466,28 @@ files:
466
466
  - lib/tasks/default.rake
467
467
  - lib/tasks/key_assignment.rake
468
468
  - lib/tasks/munificent_tasks.rake
469
+ - munificent.gemspec
470
+ - test/factories/bundle_factory.rb
471
+ - test/factories/bundle_tier_factory.rb
472
+ - test/factories/bundle_tier_game_factory.rb
473
+ - test/factories/charity_factory.rb
474
+ - test/factories/curated_streamer_factory.rb
475
+ - test/factories/donation_factory.rb
476
+ - test/factories/donator_bundle_factory.rb
477
+ - test/factories/donator_bundle_tier_factory.rb
478
+ - test/factories/donator_factory.rb
479
+ - test/factories/fundraiser_factory.rb
480
+ - test/factories/game_factory.rb
481
+ - test/factories/key_factory.rb
482
+ - test/factories/payment_factory.rb
483
+ - test/support/aasm_factories.rb
469
484
  homepage: https://github.com/SmartCasual/munificent
470
485
  licenses:
471
486
  - CC-BY-NC-SA-4.0
472
487
  metadata:
473
488
  homepage_uri: https://github.com/SmartCasual/munificent
474
489
  source_code_uri: https://github.com/SmartCasual/munificent
475
- changelog_uri: https://github.com/SmartCasual/munificent/blob/1.0.0/CHANGELOG.md
490
+ changelog_uri: https://github.com/SmartCasual/munificent/blob/2.0.2/CHANGELOG.md
476
491
  rubygems_mfa_required: 'true'
477
492
  post_install_message:
478
493
  rdoc_options: []