coins_paid_rails 1.1.8 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab34308c6f8735c1ab2b0c30a24faa2c11719b5017e8aca9697fa70cc85b0c32
4
- data.tar.gz: 64151ea8d034672fd678555036a82e3f191cbb11beedc015a5653b7982c7e449
3
+ metadata.gz: b5f4f94846ba1e3ffa0c4e6d019833198eb380884a25cd83a328cf783c9556ef
4
+ data.tar.gz: 49529291f106e21617c3bff7f9f41c50571fc2d48647c8a876053fd9f16fc2ce
5
5
  SHA512:
6
- metadata.gz: c3555750af1c3766d2bd96af8085258a2617f45e8c2a23f66f5b1cdc172da54366e2e3ba84e64bdb02985176fff5d55a482a0d784d5cac676c9caecb98a976fe
7
- data.tar.gz: 167e712d1860a1b2ad29cea848bf25bd601531a55648ed40e89d13ed5503ed9c94203ddaabb4987ef72edfe0a22c4e2b6cef7cfa1990cc597d5dd357a67a2b3b
6
+ metadata.gz: 2e88d8f07132fedf82433dc08bafcc3849252b746d4269b9e5b01f6f3d54c20ecaac2c10f4f1a6fe4c5efdfa43ab47ed9202775ba83842d7620d1c6d49a9b1a9
7
+ data.tar.gz: ef914fe2d13cda6e5b6775f5364dcc99c4ec88c09d07ed766554fdc263050a163db7278939a661be797cf5f223d66d86e7f0679ab7e2e5a5eb855995c090ab88
data/.circleci/config.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  version: 2.0
2
+
2
3
  defaults: &defaults
3
4
  docker:
4
- - image: circleci/ruby:2.5-stretch-node
5
- working_directory: ~/coins_paid
5
+ - image: cimg/ruby:2.7-node
6
+ working_directory: ~/project
6
7
 
7
8
  jobs:
8
9
  checkout_code:
@@ -10,10 +11,10 @@ jobs:
10
11
  steps:
11
12
  - checkout
12
13
  - run: mkdir log
13
- - save_cache:
14
- key: v4-repo-{{ .Environment.CIRCLE_SHA1 }}
14
+ - persist_to_workspace:
15
+ root: ~/project
15
16
  paths:
16
- - ~/coins_paid
17
+ - ./
17
18
 
18
19
  download_cc_reporter:
19
20
  <<: *defaults
@@ -25,45 +26,45 @@ jobs:
25
26
  curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc/cc-test-reporter
26
27
  chmod +x ./cc/cc-test-reporter
27
28
  - persist_to_workspace:
28
- root: ~/coins_paid
29
+ root: ~/project
29
30
  paths:
30
31
  - cc/cc-test-reporter
31
32
 
32
33
  run_bundler:
33
34
  <<: *defaults
34
35
  steps:
36
+ - attach_workspace:
37
+ at: ~/project
35
38
  - restore_cache:
36
- key: v4-repo-{{ .Environment.CIRCLE_SHA1 }}
37
- - restore_cache:
38
- key: v4-bundle-{{ checksum "Gemfile.lock" }}
39
+ key: v1-bundle-{{ checksum "Gemfile.lock" }}
39
40
  - run: echo "export rvm_ignore_gemsets_flag=1" >> ~/.rvmrc
40
41
  - run: sudo apt-get update && sudo apt-get install -y libsodium-dev
41
- - run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
42
+ - run: bundle config set --local path 'vendor/bundle'
43
+ - run: bundle check || bundle install --path=vendor/bundle --jobs=4 --retry=3
42
44
  - save_cache:
43
- key: v4-bundle-{{ checksum "Gemfile.lock" }}
45
+ key: v1-bundle-{{ checksum "Gemfile.lock" }}
44
46
  paths:
45
- - ~/coins_paid/vendor/bundle
47
+ - ~/project/vendor/bundle
46
48
 
47
49
  run_rspec_tests:
48
50
  <<: *defaults
49
51
  docker:
50
- - image: circleci/ruby:2.5-stretch-node
52
+ - image: cimg/ruby:2.7-node
51
53
  environment:
52
54
  RACK_ENV: "test"
53
55
  CIRCLE_ARTIFACTS: "./tmp"
54
56
  steps:
55
- - restore_cache:
56
- key: v4-repo-{{ .Environment.CIRCLE_SHA1 }}
57
- - restore_cache:
58
- key: v4-bundle-{{ checksum "Gemfile.lock" }}
59
57
  - attach_workspace:
60
- at: ~/coins_paid
58
+ at: ~/project
59
+ - restore_cache:
60
+ key: v1-bundle-{{ checksum "Gemfile.lock" }}
61
61
  - run: sudo apt-get update && sudo apt-get install -y libsodium-dev
62
- - run: bundle check --path vendor/bundle
62
+ - run: bundle config set --local path 'vendor/bundle'
63
+ - run: bundle check
63
64
  - run: bundle exec rspec spec
64
65
  - run: ./cc/cc-test-reporter format-coverage -t simplecov -o cc/codeclimate.rspec.json tmp/coverage/.resultset.json
65
66
  - persist_to_workspace:
66
- root: ~/coins_paid
67
+ root: ~/project
67
68
  paths:
68
69
  - cc/codeclimate.rspec.json
69
70
 
@@ -71,24 +72,12 @@ jobs:
71
72
  <<: *defaults
72
73
  steps:
73
74
  - attach_workspace:
74
- at: ~/coins_paid
75
+ at: ~/project
75
76
  - run:
76
77
  name: Upload coverage results to Code Climate
77
78
  command: |
78
79
  ./cc/cc-test-reporter upload-coverage -i cc/codeclimate.rspec.json
79
80
 
80
- deploy:
81
- <<: *defaults
82
- steps:
83
- - restore_cache:
84
- key: v4-repo-{{ .Environment.CIRCLE_SHA1 }}
85
- - restore_cache:
86
- key: v4-bundle-{{ checksum "Gemfile.lock" }}
87
- - run: mkdir -p ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts
88
- - run: sudo apt-get update && sudo apt-get install -y libsodium-dev
89
- - run: bundle check --path vendor/bundle
90
- - run: bundle exec rake deploy:branch_or_label
91
-
92
81
  workflows:
93
82
  version: 2
94
83
  build_test_deploy:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.1
1
+ 2.7.5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coins_paid_rails (1.1.7)
4
+ coins_paid_rails (1.1.8)
5
5
  activerecord (~> 6.1.4)
6
6
  coins_paid_api (~> 1.0)
7
7
  dry-initializer (~> 3.0)
@@ -10,25 +10,25 @@ PATH
10
10
  GEM
11
11
  remote: http://www.rubygems.org/
12
12
  specs:
13
- actionpack (6.1.4.1)
14
- actionview (= 6.1.4.1)
15
- activesupport (= 6.1.4.1)
13
+ actionpack (6.1.5)
14
+ actionview (= 6.1.5)
15
+ activesupport (= 6.1.5)
16
16
  rack (~> 2.0, >= 2.0.9)
17
17
  rack-test (>= 0.6.3)
18
18
  rails-dom-testing (~> 2.0)
19
19
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
- actionview (6.1.4.1)
21
- activesupport (= 6.1.4.1)
20
+ actionview (6.1.5)
21
+ activesupport (= 6.1.5)
22
22
  builder (~> 3.1)
23
23
  erubi (~> 1.4)
24
24
  rails-dom-testing (~> 2.0)
25
25
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
- activemodel (6.1.4.1)
27
- activesupport (= 6.1.4.1)
28
- activerecord (6.1.4.1)
29
- activemodel (= 6.1.4.1)
30
- activesupport (= 6.1.4.1)
31
- activesupport (6.1.4.1)
26
+ activemodel (6.1.5)
27
+ activesupport (= 6.1.5)
28
+ activerecord (6.1.5)
29
+ activemodel (= 6.1.5)
30
+ activesupport (= 6.1.5)
31
+ activesupport (6.1.5)
32
32
  concurrent-ruby (~> 1.0, >= 1.0.2)
33
33
  i18n (>= 1.6, < 2)
34
34
  minitest (>= 5.1)
@@ -40,20 +40,20 @@ GEM
40
40
  dry-struct (~> 1.0)
41
41
  faraday (~> 0.12)
42
42
  faraday_middleware (~> 0.11)
43
- concurrent-ruby (1.1.9)
43
+ concurrent-ruby (1.1.10)
44
44
  crass (1.0.6)
45
45
  diff-lcs (1.4.4)
46
46
  docile (1.1.5)
47
- dry-configurable (0.12.1)
47
+ dry-configurable (0.14.0)
48
48
  concurrent-ruby (~> 1.0)
49
- dry-core (~> 0.5, >= 0.5.0)
50
- dry-container (0.7.2)
49
+ dry-core (~> 0.6)
50
+ dry-container (0.9.0)
51
51
  concurrent-ruby (~> 1.0)
52
- dry-configurable (~> 0.1, >= 0.1.3)
53
- dry-core (0.6.0)
52
+ dry-configurable (~> 0.13, >= 0.13.0)
53
+ dry-core (0.7.1)
54
54
  concurrent-ruby (~> 1.0)
55
- dry-inflector (0.2.0)
56
- dry-initializer (3.0.4)
55
+ dry-inflector (0.2.1)
56
+ dry-initializer (3.1.1)
57
57
  dry-logic (1.2.0)
58
58
  concurrent-ruby (~> 1.0)
59
59
  dry-core (~> 0.5, >= 0.5)
@@ -68,25 +68,25 @@ GEM
68
68
  dry-inflector (~> 0.1, >= 0.1.2)
69
69
  dry-logic (~> 1.0, >= 1.0.2)
70
70
  erubi (1.10.0)
71
- faraday (0.17.4)
71
+ faraday (0.17.5)
72
72
  multipart-post (>= 1.2, < 3)
73
73
  faraday_middleware (0.14.0)
74
74
  faraday (>= 0.7.4, < 1.0)
75
- i18n (1.8.10)
75
+ i18n (1.10.0)
76
76
  concurrent-ruby (~> 1.0)
77
77
  ice_nine (0.11.2)
78
78
  json (2.3.0)
79
- loofah (2.12.0)
79
+ loofah (2.15.0)
80
80
  crass (~> 1.0.2)
81
81
  nokogiri (>= 1.5.9)
82
82
  method_source (1.0.0)
83
- mini_portile2 (2.6.1)
84
- minitest (5.14.4)
83
+ mini_portile2 (2.8.0)
84
+ minitest (5.15.0)
85
85
  multipart-post (2.1.1)
86
- nokogiri (1.12.5)
87
- mini_portile2 (~> 2.6.1)
86
+ nokogiri (1.13.3)
87
+ mini_portile2 (~> 2.8.0)
88
88
  racc (~> 1.4)
89
- racc (1.5.2)
89
+ racc (1.6.0)
90
90
  rack (2.2.3)
91
91
  rack-test (1.1.0)
92
92
  rack (>= 1.0, < 3)
@@ -95,11 +95,11 @@ GEM
95
95
  nokogiri (>= 1.6)
96
96
  rails-html-sanitizer (1.4.2)
97
97
  loofah (~> 2.3)
98
- railties (6.1.4.1)
99
- actionpack (= 6.1.4.1)
100
- activesupport (= 6.1.4.1)
98
+ railties (6.1.5)
99
+ actionpack (= 6.1.5)
100
+ activesupport (= 6.1.5)
101
101
  method_source
102
- rake (>= 0.13)
102
+ rake (>= 12.2)
103
103
  thor (~> 1.0)
104
104
  rake (13.0.6)
105
105
  rqrcode (2.1.0)
@@ -132,10 +132,10 @@ GEM
132
132
  simplecov-html (~> 0.10.0)
133
133
  simplecov-html (0.10.2)
134
134
  sqlite3 (1.4.2)
135
- thor (1.1.0)
135
+ thor (1.2.1)
136
136
  tzinfo (2.0.4)
137
137
  concurrent-ruby (~> 1.0)
138
- zeitwerk (2.4.2)
138
+ zeitwerk (2.5.4)
139
139
 
140
140
  PLATFORMS
141
141
  ruby
@@ -149,4 +149,4 @@ DEPENDENCIES
149
149
  sqlite3
150
150
 
151
151
  BUNDLED WITH
152
- 1.17.1
152
+ 2.2.32
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'coins_paid_rails'
3
3
  s.authors = ['Artem Biserov(artembiserov)', 'Oleg Ivanov(morhekil)']
4
- s.version = '1.1.8'
4
+ s.version = '1.2.0'
5
5
  s.files = `git ls-files`.split("\n")
6
6
  s.summary = 'CoinsPaid Rails Integration'
7
7
  s.license = 'MIT'
data/lib/coins_paid.rb CHANGED
@@ -3,34 +3,14 @@ require 'dry-struct'
3
3
  require 'dry-initializer'
4
4
  require_relative 'coins_paid/address'
5
5
  require_relative 'coins_paid/coins_paid_address'
6
- require_relative 'coins_paid/qr_code'
7
6
 
8
7
  module CoinsPaid
9
8
  module_function
10
9
 
11
10
  UnknownCurrency = Class.new RuntimeError
12
11
 
13
- DEFAULT_CONVERT_TO = ENV['COINS_PAID_CURRENCY']
14
-
15
- ADDRESS_PREFIXES = {
16
- 'BTC' => 'bitcoin',
17
- 'BCH' => 'bitcoincash',
18
- 'DOGE' => 'doge',
19
- 'ETH' => 'ethereum',
20
- 'EURTE' => 'ethereum',
21
- 'LTC' => 'litecoin',
22
- 'USDT' => 'bitcoin',
23
- 'USDTE' => 'ethereum',
24
- 'TRX' => 'tron',
25
- 'USDTT' => 'tron'
26
- }.freeze
27
-
28
- def address(foreign_id, currency:)
29
- Address.new(foreign_id: foreign_id, currency: currency, convert_to: DEFAULT_CONVERT_TO).call
30
- end
31
-
32
- def qr_code(player_id, currency:, label:, message:)
33
- QrCode.new(player_id, currency: currency, label: label, message: message)
12
+ def address(foreign_id, currency:, convert_to:)
13
+ Address.new(foreign_id: foreign_id, currency: currency, convert_to: convert_to).call
34
14
  end
35
15
 
36
16
  def currency(name)
data/spec/address_spec.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  describe CoinsPaid, '.address' do
4
4
  let(:foreign_key) { 'user-id:2048' }
5
5
  let(:currency) { 'BTC' }
6
+ let(:convert_to) { 'EUR' }
6
7
  let(:full_address_attributes) do
7
8
  {
8
9
  foreign_id: foreign_key,
@@ -16,7 +17,7 @@ describe CoinsPaid, '.address' do
16
17
  tag: 'tag-123',
17
18
  }
18
19
  end
19
- subject(:take_address) { described_class.address(foreign_key, currency: currency) }
20
+ subject(:take_address) { described_class.address(foreign_key, currency: currency, convert_to: convert_to) }
20
21
 
21
22
  context 'when there is existing record' do
22
23
  let!(:address) do
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coins_paid_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artem Biserov(artembiserov)
8
8
  - Oleg Ivanov(morhekil)
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-29 00:00:00.000000000 Z
12
+ date: 2022-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coins_paid_api
@@ -81,8 +81,8 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
- description:
85
- email:
84
+ description:
85
+ email:
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
@@ -97,7 +97,6 @@ files:
97
97
  - lib/coins_paid.rb
98
98
  - lib/coins_paid/address.rb
99
99
  - lib/coins_paid/coins_paid_address.rb
100
- - lib/coins_paid/qr_code.rb
101
100
  - lib/coins_paid_rails.rb
102
101
  - lib/generators/coins_paid/migration_data.rb
103
102
  - lib/generators/coins_paid/migration_generator.rb
@@ -105,14 +104,13 @@ files:
105
104
  - spec/address_spec.rb
106
105
  - spec/currency_spec.rb
107
106
  - spec/issued_addresses_spec.rb
108
- - spec/qr_code_spec.rb
109
107
  - spec/spec_helper.rb
110
108
  - spec/support/database/create_table.rb
111
- homepage:
109
+ homepage:
112
110
  licenses:
113
111
  - MIT
114
112
  metadata: {}
115
- post_install_message:
113
+ post_install_message:
116
114
  rdoc_options: []
117
115
  require_paths:
118
116
  - lib
@@ -127,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
125
  - !ruby/object:Gem::Version
128
126
  version: '0'
129
127
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.7.6
132
- signing_key:
128
+ rubygems_version: 3.1.6
129
+ signing_key:
133
130
  specification_version: 4
134
131
  summary: CoinsPaid Rails Integration
135
132
  test_files: []
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CoinsPaid
4
- class QrCode
5
- include Dry::Initializer.define -> do
6
- param :player_id
7
- option :currency
8
- option :label
9
- option :message
10
- end
11
-
12
- def url
13
- known_url? ? "#{token_type}:#{address.address}?label=#{encode(label)}&message=#{encode(message)}" : nil
14
- end
15
-
16
- def address
17
- @address ||= CoinsPaid.address(player_id, currency: currency)
18
- end
19
-
20
- def svg
21
- RQRCode::QRCode.new(url || address.address).as_svg(
22
- offset: 0,
23
- color: '000',
24
- shape_rendering: 'crispEdges',
25
- module_size: 3,
26
- standalone: true
27
- )
28
- end
29
-
30
- private
31
-
32
- def token_type
33
- ADDRESS_PREFIXES[currency]
34
- end
35
-
36
- def encode(string)
37
- URI.encode_www_form_component(string)
38
- end
39
-
40
- def known_url?
41
- token_type.present?
42
- end
43
- end
44
- end
data/spec/qr_code_spec.rb DELETED
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe CoinsPaid, '.qr_code' do
4
- let(:foreign_id) { 123 }
5
- let(:currency) { 'BTC' }
6
- let(:address) { 'abc123' }
7
- let(:coins_paid_address) do
8
- instance_double CoinsPaid::CoinsPaidAddress,
9
- currency: currency,
10
- address: address
11
- end
12
- subject(:qr_code) do
13
- described_class.qr_code(
14
- foreign_id,
15
- currency: currency,
16
- label: 'RedStar deposit',
17
- message: 'Make a deposit to RedStar'
18
- )
19
- end
20
-
21
- before do
22
- allow(CoinsPaid).to receive(:address).with(foreign_id, currency: currency).and_return(coins_paid_address)
23
- end
24
-
25
- context 'it is known how to build payment url for the currency' do
26
- let(:currency) { 'BTC' }
27
- let(:url) { "bitcoin:#{address}?label=RedStar+deposit&message=Make+a+deposit+to+RedStar" }
28
-
29
- describe '#url' do
30
- its(:url) { is_expected.to eq url }
31
- end
32
-
33
- describe '#svg' do
34
- it 'encodes payment url' do
35
- expect(RQRCode::QRCode).to receive(:new).with(url).and_call_original
36
- qr_code.svg
37
- end
38
- end
39
- end
40
-
41
- context 'it is not known how to build payment url for the currency' do
42
- let(:currency) { 'BNB' }
43
-
44
- describe '#url' do
45
- its(:url) { is_expected.to be_nil }
46
- end
47
-
48
- describe '#svg' do
49
- it 'encodes payment address' do
50
- expect(RQRCode::QRCode).to receive(:new).with(address).and_call_original
51
- qr_code.svg
52
- end
53
- end
54
- end
55
-
56
- context '#address' do
57
- its(:address) { is_expected.to eq coins_paid_address }
58
- end
59
- end