sbds-rails 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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +63 -0
  3. data/Rakefile +47 -0
  4. data/app/assets/config/sbds_manifest.js +0 -0
  5. data/app/models/sbds/account_create.rb +5 -0
  6. data/app/models/sbds/account_create_with_delegation.rb +5 -0
  7. data/app/models/sbds/account_update.rb +5 -0
  8. data/app/models/sbds/account_witness_proxy.rb +5 -0
  9. data/app/models/sbds/account_witness_vote.rb +5 -0
  10. data/app/models/sbds/acts_as_transaction.rb +41 -0
  11. data/app/models/sbds/cancel_transfer_from_savings.rb +5 -0
  12. data/app/models/sbds/change_recovery_account.rb +5 -0
  13. data/app/models/sbds/claim_reward_balance.rb +5 -0
  14. data/app/models/sbds/comment.rb +5 -0
  15. data/app/models/sbds/comment_options.rb +6 -0
  16. data/app/models/sbds/convert.rb +5 -0
  17. data/app/models/sbds/core_block.rb +5 -0
  18. data/app/models/sbds/custom.rb +5 -0
  19. data/app/models/sbds/custom_json.rb +5 -0
  20. data/app/models/sbds/decline_voting_rights.rb +5 -0
  21. data/app/models/sbds/delegate_vesting_share.rb +5 -0
  22. data/app/models/sbds/delete_comment.rb +5 -0
  23. data/app/models/sbds/escrow_approve.rb +5 -0
  24. data/app/models/sbds/escrow_dispute.rb +5 -0
  25. data/app/models/sbds/escrow_release.rb +5 -0
  26. data/app/models/sbds/escrow_transfer.rb +5 -0
  27. data/app/models/sbds/feed_publish.rb +5 -0
  28. data/app/models/sbds/limit_order_cancel.rb +5 -0
  29. data/app/models/sbds/limit_order_create.rb +5 -0
  30. data/app/models/sbds/pow.rb +5 -0
  31. data/app/models/sbds/pow2.rb +5 -0
  32. data/app/models/sbds/recover_account.rb +5 -0
  33. data/app/models/sbds/request_account_recovery.rb +5 -0
  34. data/app/models/sbds/transfer.rb +5 -0
  35. data/app/models/sbds/transfer_from_savings.rb +5 -0
  36. data/app/models/sbds/transfer_to_savings.rb +5 -0
  37. data/app/models/sbds/transfer_to_vesting.rb +5 -0
  38. data/app/models/sbds/vote.rb +5 -0
  39. data/app/models/sbds/withdraw_vesting.rb +5 -0
  40. data/app/models/sbds/withdraw_vesting_route.rb +5 -0
  41. data/app/models/sbds/witness_update.rb +5 -0
  42. data/config/routes.rb +2 -0
  43. data/lib/sbds/engine.rb +4 -0
  44. data/lib/sbds/version.rb +3 -0
  45. data/lib/sbds.rb +4 -0
  46. data/lib/tasks/sbds_tasks.rake +19 -0
  47. metadata +157 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 23dc7fa810edb6ba037e54bf4a7ecddf838e23c5
4
+ data.tar.gz: 41f8d63b235b3e99c75d6de68d05fd591556666b
5
+ SHA512:
6
+ metadata.gz: 6af87d0dc81087f817c60085051a2cb3ed6e2d77ecfc694d49027110e8f5dcb5a5b83230e867d52a7df84a757a56b506bdf942cf99d8fa26a728a449cb25af56
7
+ data.tar.gz: bba59ae091bc69edcec35154eb2202ae8bf3d56906a6f3b40ddd20d88e8e70c9204ac6a541494a77bbebb72e88b812c3099ac7f3c9243f35eda878cd8f55e523
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Steem Blockchain Data Service Rails Engine
2
+
3
+ Ruby on Rails Engine for accessing Steem Blockchain Data Service.
4
+
5
+ The [sbds](https://github.com/steemit/sbds) project is the official database layer for accessing a local, read-only version of the Steem blockchain. It is developed and maintained by Steemit, Inc. and can be confugured to use SQLite, Postgres, and MySQL.
6
+
7
+ This `gem` allows you to access an `sdbs` instance with `ActiveRecord`.
8
+
9
+ ## Installation
10
+
11
+ ### For Existing Rails Projects
12
+
13
+ Assuming you already have an existing rails project,
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'sbds-rails'
19
+ ```
20
+
21
+ And then execute:
22
+ ```bash
23
+ $ bundle install
24
+ ```
25
+
26
+ Edit `database.yml` and use your own `sbds` database or try out @furion's:
27
+
28
+ ```yaml
29
+ default: &default
30
+ adapter: mysql2
31
+ encoding: utf8
32
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
33
+ username: steemit
34
+ password: steemit
35
+ host: sbds-mysql.steemdata.com
36
+ database: sbds
37
+ ```
38
+
39
+ ### For New Projects
40
+
41
+ Have a look at this article on setting up a new rails project, then use the
42
+ steps above to enable this plug-in.
43
+
44
+ [How to Write a Ruby on Rails App for STEEM](https://steemit.com/radiator/@inertia/how-to-write-a-ruby-on-rails-app-for-steem)
45
+
46
+ ## Tests
47
+
48
+ * Basic tests can be invoked as follows:
49
+ * `rake`
50
+ * To run tests with parallelization and local code coverage:
51
+ * `HELL_ENABLED=true rake`
52
+
53
+ ![](http://i.imgur.com/0STlATl.png)
54
+
55
+ ## Get in touch!
56
+
57
+ If you're using sbds-rails, I'd love to hear from you. Drop me a line and tell
58
+ me what you think! I'm @inertia on STEEM.
59
+
60
+ ## License
61
+
62
+ I don't believe in intellectual "property". If you do, consider sbds-rails as
63
+ licensed under a Creative Commons [![CC0](http://i.creativecommons.org/p/zero/1.0/80x15.png)](http://creativecommons.org/publicdomain/zero/1.0/) License.
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Sbds'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+
19
+ load 'rails/tasks/engine.rake'
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
33
+
34
+ task :build do
35
+ exec 'gem build sbds-rails.gemspec'
36
+ end
37
+
38
+ task :push do
39
+ exec "gem push sbds-rails-#{Sbd::VERSION}.gem"
40
+ end
41
+
42
+ # We're not going to yank on a regular basis, but this is how it's done if you
43
+ # really want a task for that for some reason.
44
+
45
+ # task :yank do
46
+ # exec "gem yank sbds-rails -v #{Sbds::VERSION}"
47
+ # end
File without changes
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class AccountCreate < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class AccountCreateWithDelegation < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class AccountUpdate < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class AccountWitnessProxy < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class AccountWitnessVote < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ module Sbds
2
+ module ActsAsTransaction
3
+ def self.included(base)
4
+ def base.table_name_prefix; 'sbds_tx_'; end
5
+
6
+ def base.default_scope
7
+ order(timestamp: :asc)
8
+ end
9
+
10
+ base.scope :block, lambda { |block_num|
11
+ where(block_num: block_num)
12
+ }
13
+
14
+ base.scope :starting, lambda { |with, field = :timestamp, not_inverted = true|
15
+ r = where(field => with..Time.now.utc)
16
+
17
+ not_inverted ? r : where.not(r)
18
+ }
19
+
20
+ base.scope :ending, lambda { |with, field = :timestamp, not_inverted = true|
21
+ r = where(field => Time.at(0)..with)
22
+
23
+ not_inverted ? r : where.not(r)
24
+ }
25
+
26
+ base.scope :betwixt, lambda { |starting, ending, field = :timestamp, not_inverted = true|
27
+ r = where(field => starting..ending)
28
+
29
+ not_inverted ? r : where.not(r)
30
+ }
31
+
32
+ base.scope :today, lambda { |field = :timestamp|
33
+ starting(1.day.ago.utc, field)
34
+ }
35
+
36
+ base.scope :yesterday, lambda { |field = :timestamp|
37
+ betwixt(2.days.ago.utc, 1.day.ago.utc, field)
38
+ }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class CancelTransferFromSavings < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class ChangeRecoveryAccount < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class ClaimRewardBalance < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class Comment < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Sbds
2
+ class CommentOptions < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ def self.table_name; 'sbds_tx_comments_options'; end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class Convert < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class CoreBlock < ActiveRecord::Base
3
+ def self.table_name_prefix; 'sbds_'; end
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class Custom < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class CustomJson < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class DeclineVotingRights < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class DelegateVestingShare < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class DeleteComment < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class EscrowApprove < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class EscrowDispute < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class EscrowRelease < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class EscrowTransfer < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class FeedPublish < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class LimitOrderCancel < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class LimitOrderCreate < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class Pow < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class Pow2 < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class RecoverAccount < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class RequestAccountRecovery < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class Transfer < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class TransferFromSavings < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class TransferToSavings < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class TransferToVesting < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class Vote < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class WithdrawVesting < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class WithdrawVestingRoute < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Sbds
2
+ class WitnessUpdate < ActiveRecord::Base
3
+ include ActsAsTransaction
4
+ end
5
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,4 @@
1
+ module Sbds
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Sbds
2
+ VERSION = '0.1.0'
3
+ end
data/lib/sbds.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "sbds/engine"
2
+
3
+ module Sbds
4
+ end
@@ -0,0 +1,19 @@
1
+ # desc "Explaining what the task does"
2
+ # task :sbds do
3
+ # # Task goes here
4
+ # end
5
+
6
+ Rake.application.instance_variable_get('@tasks').delete('db:test:purge')
7
+ Rake.application.instance_variable_get('@tasks').delete('db:test:load_schema')
8
+
9
+ namespace 'db' do
10
+ namespace 'test' do
11
+ task 'purge' do
12
+ # noop
13
+ end
14
+
15
+ task 'load_schema' do
16
+ # noop
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sbds-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anthony Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.1.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '5.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.1.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: pry
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.10.3
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.10.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: simplecov
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.11.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.11.2
61
+ - !ruby/object:Gem::Dependency
62
+ name: mysql2
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.4'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 0.4.6
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '0.4'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 0.4.6
81
+ description: Ruby on Rails Engine for accessing Steem Blockchain Data Service.
82
+ email:
83
+ - github@martin-studio.com
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - README.md
89
+ - Rakefile
90
+ - app/assets/config/sbds_manifest.js
91
+ - app/models/sbds/account_create.rb
92
+ - app/models/sbds/account_create_with_delegation.rb
93
+ - app/models/sbds/account_update.rb
94
+ - app/models/sbds/account_witness_proxy.rb
95
+ - app/models/sbds/account_witness_vote.rb
96
+ - app/models/sbds/acts_as_transaction.rb
97
+ - app/models/sbds/cancel_transfer_from_savings.rb
98
+ - app/models/sbds/change_recovery_account.rb
99
+ - app/models/sbds/claim_reward_balance.rb
100
+ - app/models/sbds/comment.rb
101
+ - app/models/sbds/comment_options.rb
102
+ - app/models/sbds/convert.rb
103
+ - app/models/sbds/core_block.rb
104
+ - app/models/sbds/custom.rb
105
+ - app/models/sbds/custom_json.rb
106
+ - app/models/sbds/decline_voting_rights.rb
107
+ - app/models/sbds/delegate_vesting_share.rb
108
+ - app/models/sbds/delete_comment.rb
109
+ - app/models/sbds/escrow_approve.rb
110
+ - app/models/sbds/escrow_dispute.rb
111
+ - app/models/sbds/escrow_release.rb
112
+ - app/models/sbds/escrow_transfer.rb
113
+ - app/models/sbds/feed_publish.rb
114
+ - app/models/sbds/limit_order_cancel.rb
115
+ - app/models/sbds/limit_order_create.rb
116
+ - app/models/sbds/pow.rb
117
+ - app/models/sbds/pow2.rb
118
+ - app/models/sbds/recover_account.rb
119
+ - app/models/sbds/request_account_recovery.rb
120
+ - app/models/sbds/transfer.rb
121
+ - app/models/sbds/transfer_from_savings.rb
122
+ - app/models/sbds/transfer_to_savings.rb
123
+ - app/models/sbds/transfer_to_vesting.rb
124
+ - app/models/sbds/vote.rb
125
+ - app/models/sbds/withdraw_vesting.rb
126
+ - app/models/sbds/withdraw_vesting_route.rb
127
+ - app/models/sbds/witness_update.rb
128
+ - config/routes.rb
129
+ - lib/sbds.rb
130
+ - lib/sbds/engine.rb
131
+ - lib/sbds/version.rb
132
+ - lib/tasks/sbds_tasks.rake
133
+ homepage: http://github.com/inertia186/sbds-rails
134
+ licenses:
135
+ - CC0-1.0
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.8
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Steem Blockchain Data Service Rails Engine
157
+ test_files: []