Ever want to just watch the blockchain from a terminal, as if you're tailing a log file? Here's how to do that in ruby. As always, we use [Radiator](https://steemit.com/steem/@inertia/radiator-steem-ruby-api-client) with `bundler`. You can get `bundler` with this command: ```bash $ gem install bundler ``` I've tested it on various versions of ruby. The oldest one I got it to work was: `ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-darwin14.4.0]` First, make a project folder: ```bash $ mkdir radiator $ cd radiator ``` Create a file named `Gemfile` containing: ```ruby source 'https://rubygems.org' gem 'radiator', github: 'inertia186/radiator' gem 'awesome_print' ``` Then run the command: ```bash $ bundle install ``` Create a file named `tail_blockchain.rb` containing: ```ruby require 'rubygems' require 'bundler/setup' Bundler.require stream = Radiator::Stream.new(url: 'http://golos.steem.ws/') last_op = nil pattern = ARGV.first stream.operations do |operation| if !!pattern next unless operation.inspect =~ /#{pattern}/i end op_key = operation.keys.first op_value = operation.values.first log = [] case op_key when :comment (v = op_value.title).empty? or log << "title: #{v}" (v = op_value.parent_author).empty? or log << "parent_author: #{v}" (v = op_value.parent_permlink).empty? or log << "parent_permlink: #{v}" log << "author: #{op_value.author}" log << "permlink: #{op_value.permlink}" when :vote log << "weight: #{op_value.weight / 100} %" log << "voter: #{op_value.voter}" log << "author: #{op_value.author}, permlink: #{op_value.permlink}" when :custom_json log << "id: #{op_value.id}" log << "json: #{op_value.json}" when :transfer log << "from: #{op_value.from}" log << "to: #{op_value.to}" log << "amount: #{op_value.amount}" (v = op_value.memo).empty? or log << "memo: #{v}" else log << op_value.to_json end ap op_key if last_op != op_key ap log.join(', ') last_op = op_key end ``` Then run it: ```bash $ ruby tail_blockchain.rb ``` You can also pass along a regex pattern to match on: ```bash $ ruby tail_blockchain.rb ned ``` Note, the `comment` operation (which also represents posts) does not output the body. If the operation, including the body, contains the optional regex, it will display that line without the body so it doesn't flood the display.  See my previous Ruby How To posts in: [#radiator](https://golos.io/created/radiator) [#ruby](https://golos.io/created/ruby)
author | inertia |
---|---|
permlink | how-to-tail-the-golos-blockchain-in-ruby |
category | radiator |
json_metadata | "{"tags": ["ruby", "golos", "howto"], "permlink": "how-to-tail-the-golos-blockchain-in-ruby"}" |
created | 2016-10-24 17:58:24 |
last_update | 2016-10-24 17:58:24 |
depth | 0 |
children | 0 |
last_payout | 2016-11-24 18:38:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.152 HBD |
curator_payout_value | 0.039 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2,610 |
author_reputation | 346,568,901,399,561 |
root_title | "How to Tail the Golos Blockchain in Ruby" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 1,610,860 |
net_rshares | 2,438,896,757,456 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
proctologic | 0 | 12,504,030,163 | 100% | ||
proctologic2 | 0 | 2,058,363,822 | 100% | ||
gavvet | 0 | 1,468,070,381,573 | 100% | ||
noganoo | 0 | 13,957,037,048 | 20% | ||
applecrisp | 0 | 1,438,584,149 | 20% | ||
gardening | 0 | 64,241,149 | 20% | ||
survival | 0 | 64,268,104 | 20% | ||
arisa | 0 | 1,916,529,205 | 20% | ||
tee-em | 0 | 1,973,919,762 | 20% | ||
proglobyte | 0 | 526,207,365 | 100% | ||
seth-krings | 0 | 4,021,196,905 | 20% | ||
crok | 0 | 3,860,261,631 | 100% | ||
technology | 0 | 13,100,899,822 | 20% | ||
fyrstikken | 0 | 317,519,205,895 | 25% | ||
isteemit | 0 | 9,617,961,117 | 20% | ||
auction | 0 | 1,861,451,935 | 20% | ||
asmolokalo | 0 | 61,256,610,430 | 11% | ||
robrigo | 0 | 302,247,278,794 | 100% | ||
dwinblood | 0 | 56,657,042,190 | 100% | ||
inertia | 0 | 113,938,741,670 | 100% | ||
hemp | 0 | 210,016,466 | 20% | ||
seb | 0 | 109,150,640 | 100% | ||
raymonjohnstone | 0 | 315,011,252 | 20% | ||
webdeals | 0 | 14,463,847,751 | 100% | ||
tingaling | 0 | 1,142,073,509 | 100% | ||
kurtbeil | 0 | 10,395,282,746 | 100% | ||
zentat | 0 | 3,492,523,275 | 100% | ||
thewhitewolf | 0 | 60,766,139 | 100% | ||
macartem | 0 | 4,634,850,263 | 100% | ||
jsantana | 0 | 911,403,667 | 10% | ||
rebel | 0 | 57,499,939 | 100% | ||
steembriefing | 0 | 385,916,990 | 100% | ||
runridefly | 0 | 3,145,323,397 | 34% | ||
jlufer | 0 | 438,145,823 | 100% | ||
donato | 0 | 54,526,921 | 100% | ||
bitcoinparadise | 0 | 3,664,010,843 | 100% | ||
inarix03 | 0 | 62,690,141 | 100% | ||
develcuy | 0 | 1,202,473,976 | 20% | ||
steemint | 0 | 378,940,707 | 100% | ||
dagasdaimuro | 0 | 151,533,992 | 100% | ||
iangasgoltigal | 0 | 151,074,186 | 100% | ||
mitovare | 0 | 154,335,347 | 100% | ||
poteriakhin | 0 | 148,797,705 | 100% | ||
samubarfaekora | 0 | 148,670,240 | 100% | ||
cerethrisaridor | 0 | 154,638,153 | 100% | ||
nikaresia | 0 | 128,707,796 | 100% | ||
dalarpewield | 0 | 152,438,133 | 100% | ||
jekotalamut | 0 | 146,019,418 | 100% | ||
dealzgal | 0 | 83,975,976 | 100% | ||
borisa | 0 | 148,024,846 | 100% | ||
lauraterevez | 0 | 144,859,278 | 100% | ||
lauratecereca | 0 | 138,636,738 | 100% | ||
leterevecca | 0 | 144,611,403 | 100% | ||
weretecioz | 0 | 150,600,506 | 100% | ||
goldfontkazrarr | 0 | 153,537,404 | 100% | ||
mikerecio | 0 | 153,635,780 | 100% | ||
taulldoomdragon | 0 | 146,905,883 | 100% | ||
mereberrity | 0 | 150,473,903 | 100% | ||
luisvererra | 0 | 139,268,820 | 100% | ||
felozelo | 0 | 148,125,868 | 100% | ||
saigelve | 0 | 126,585,986 | 100% | ||
miloduhawe | 0 | 145,379,327 | 100% | ||
vikao | 0 | 146,885,512 | 100% | ||
holinewuba | 0 | 142,177,771 | 100% | ||
trefe | 0 | 145,484,301 | 100% | ||
polinamal | 0 | 139,920,688 | 100% | ||
lilit | 0 | 1,179,611,245 | 100% | ||
sencho | 0 | 142,761,292 | 100% | ||
midefevitae | 0 | 131,323,230 | 100% | ||
voterinterstpool | 0 | 136,978,274 | 100% | ||
voteinterestpool | 0 | 1,642,111,281 | 100% | ||
slavix | 0 | 0 | 100% |