bigbang_engine 0.1.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 +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bigbang_engine.gemspec +35 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/bigbang_engine/support/concerns/fund_concern/associations.rb +44 -0
- data/lib/bigbang_engine/support/concerns/fund_concern/callbacks.rb +42 -0
- data/lib/bigbang_engine/support/concerns/fund_concern/delegators.rb +17 -0
- data/lib/bigbang_engine/support/concerns/fund_concern/scopes.rb +30 -0
- data/lib/bigbang_engine/support.rb +2 -0
- data/lib/bigbang_engine/version.rb +3 -0
- data/lib/bigbang_engine.rb +5 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b295476dd3b7ace3e39403bb8a9430dabd19919c
|
4
|
+
data.tar.gz: 2b63eb3d11e7d130e9f398c93fceaa8eff958d84
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d8bcba5a0428fe4a21185eb6c2816d9fd5fecf7f099fa3b6838f1d14037c4243243fdc6af15fad58f61719f67944b7c904dad0360812b1be1fc0dced05ebf064
|
7
|
+
data.tar.gz: 0ff8a3c439da1a094c508afcccc8d9df5cc380528154f55ce33126393ad2cd8648d3f14ef6b102069c3de4a25ec56821f81cceb36ec293f36688e3b9153e732d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# BigbangEngine
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bigbang_engine`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bigbang_engine'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install bigbang_engine
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Vitor Vidotto/bigbang_engine.
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bigbang_engine/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bigbang_engine"
|
8
|
+
spec.version = BigbangEngine::VERSION
|
9
|
+
spec.authors = ["Vitor Vidotto"]
|
10
|
+
spec.email = ["vvidotto@bip.b.br"]
|
11
|
+
|
12
|
+
spec.summary = %q{Support library for the Bigbang project}
|
13
|
+
spec.description = %q{Extraction of part of the intelligence behind BigBang}
|
14
|
+
spec.homepage = "https://bitbucket.org/guideinvestimentos/"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
# else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bigbang_engine"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Concerns
|
2
|
+
module Fund
|
3
|
+
module Associations
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
belongs_to :administrator
|
7
|
+
belongs_to :manager
|
8
|
+
belongs_to :asset_strategy
|
9
|
+
belongs_to :asset_sub_strategy
|
10
|
+
belongs_to :client
|
11
|
+
belongs_to :rebate_group
|
12
|
+
|
13
|
+
has_many :attachments
|
14
|
+
|
15
|
+
has_one :promotional_material,
|
16
|
+
-> { where(attachable_foreign_key: :promotional_material) },
|
17
|
+
as: :attachable, class_name: 'Attachment', dependent: :destroy
|
18
|
+
|
19
|
+
has_one :regulation, -> { where(attachable_foreign_key: :regulation) },
|
20
|
+
as: :attachable, class_name: 'Attachment', dependent: :destroy
|
21
|
+
|
22
|
+
has_one :sheet_complementary_form, -> { where(attachable_foreign_key: :sheet_complementary_form) },
|
23
|
+
as: :attachable, class_name: 'Attachment', dependent: :destroy
|
24
|
+
|
25
|
+
has_one :sheet_essential, -> { where(attachable_foreign_key: :sheet_essential) },
|
26
|
+
as: :attachable, class_name: 'Attachment', dependent: :destroy
|
27
|
+
|
28
|
+
has_many :documents, class_name: "Documentation", as: Fund
|
29
|
+
has_many :bank_accounts, as: :accountable, dependent: :destroy
|
30
|
+
has_many :shares, dependent: :destroy
|
31
|
+
has_one :info, dependent: :destroy, class_name: "FundInfo"
|
32
|
+
has_one :transactions_info, class_name: "FundTransactionsInfo"
|
33
|
+
has_one :monthly_fund_sheet
|
34
|
+
accepts_nested_attributes_for :promotional_material, allow_destroy: true
|
35
|
+
accepts_nested_attributes_for :regulation, allow_destroy: true
|
36
|
+
accepts_nested_attributes_for :sheet_essential, allow_destroy: true
|
37
|
+
accepts_nested_attributes_for :sheet_complementary_form, allow_destroy: true
|
38
|
+
accepts_nested_attributes_for :bank_accounts, allow_destroy: true
|
39
|
+
accepts_nested_attributes_for :info, allow_destroy: true
|
40
|
+
accepts_nested_attributes_for :transactions_info, allow_destroy: true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Concerns
|
2
|
+
module Fund
|
3
|
+
module Callbacks
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
before_save :update_client_attributes
|
7
|
+
before_validation :reject_attachments
|
8
|
+
end
|
9
|
+
|
10
|
+
def update_client_attributes
|
11
|
+
if client
|
12
|
+
client.update_attribute(:name, name) if name_changed?
|
13
|
+
client.update_attribute(:document, cnpj) if cnpj_changed?
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def reject_attachments
|
18
|
+
self.promotional_material = nil if promotional_material &&
|
19
|
+
promotional_material.file_file_name.blank?
|
20
|
+
self.regulation = nil if regulation && regulation.file_file_name.blank?
|
21
|
+
self.sheet_complementary_form = nil if sheet_complementary_form &&
|
22
|
+
sheet_complementary_form.file_file_name.blank?
|
23
|
+
self.sheet_essential = nil if sheet_essential &&
|
24
|
+
sheet_essential.file_file_name.blank?
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
def after_save_asset
|
29
|
+
set_status
|
30
|
+
end
|
31
|
+
|
32
|
+
def after_destroy_asset
|
33
|
+
set_status
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_status
|
37
|
+
manager.status = manager.balances.actives.empty? ? :inactive : :active
|
38
|
+
manager.save!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Concerns
|
2
|
+
module Fund
|
3
|
+
module Delegators
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
delegate :double_count, to: :manager, allow_nil: true
|
7
|
+
delegate :bmark, to: :asset_strategy
|
8
|
+
delegate :name, to: :administrator, prefix: true, allow_nil: true
|
9
|
+
delegate :name, to: :manager, prefix: true, allow_nil: true
|
10
|
+
delegate :email, to: :manager, prefix: true, allow_nil: true
|
11
|
+
delegate :adm_fee_calculation_type,
|
12
|
+
to: :rebate_group, allow_nil: true
|
13
|
+
delegate :share_treshold, to: :asset_sub_strategy, allow_nil: true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Concerns
|
2
|
+
module Fund
|
3
|
+
module Scopes
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
scope :double_count, ->(flag) {
|
7
|
+
joins(:manager).where("managers.double_count = #{flag}")
|
8
|
+
}
|
9
|
+
|
10
|
+
scope :to_website,
|
11
|
+
-> { with_info.where("show_on_website = 1").by_name }
|
12
|
+
scope :share_gaps,
|
13
|
+
-> { with_info.where("fund_infos.terminated = 0").by_name }
|
14
|
+
scope :with_transactions, -> { joins(:transactions).uniq }
|
15
|
+
scope :with_sheets, -> {
|
16
|
+
with_info.where.not(fund_infos: {sheet_id: nil}).
|
17
|
+
by_name.pluck(:name, :id)
|
18
|
+
}
|
19
|
+
|
20
|
+
scope :exclusive_funds, -> {
|
21
|
+
with_info.includes(:asset, :client).where(
|
22
|
+
"fund_infos.exclusive = 1 AND client_id IS NOT NULL").map(&:asset)
|
23
|
+
}
|
24
|
+
|
25
|
+
private
|
26
|
+
scope :with_info, -> { joins(:info) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bigbang_engine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vitor Vidotto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-17 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.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
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.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Extraction of part of the intelligence behind BigBang
|
56
|
+
email:
|
57
|
+
- vvidotto@bip.b.br
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bigbang_engine.gemspec
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/bigbang_engine.rb
|
72
|
+
- lib/bigbang_engine/support.rb
|
73
|
+
- lib/bigbang_engine/support/concerns/fund_concern/associations.rb
|
74
|
+
- lib/bigbang_engine/support/concerns/fund_concern/callbacks.rb
|
75
|
+
- lib/bigbang_engine/support/concerns/fund_concern/delegators.rb
|
76
|
+
- lib/bigbang_engine/support/concerns/fund_concern/scopes.rb
|
77
|
+
- lib/bigbang_engine/version.rb
|
78
|
+
homepage: https://bitbucket.org/guideinvestimentos/
|
79
|
+
licenses: []
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.4.8
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Support library for the Bigbang project
|
101
|
+
test_files: []
|