rippler 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,8 +1,11 @@
1
+ .DS_Store
2
+
1
3
  *.gem
2
4
  *.rbc
3
5
  .bundle
4
- .config
5
6
  .yardoc
7
+ .config
8
+ config
6
9
  Gemfile.lock
7
10
  InstalledFiles
8
11
  _yardoc
@@ -15,3 +18,4 @@ spec/reports
15
18
  test/tmp
16
19
  test/version_tmp
17
20
  tmp
21
+ log
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm --create use jruby-1.7.2@rippler
1
+ rvm --create use ruby-1.9.3-p362@rippler
data/README.md CHANGED
@@ -4,21 +4,19 @@ Command line client for Ripple payment platform. It uses Ripple websocket API to
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ You need to have Ruby 1.9 (http://www.ruby-lang.org/en/downloads/) installed. Once Ruby is in place, just install Rippler gem:
8
8
 
9
- gem 'rippler'
9
+ $ gem install rippler
10
10
 
11
- And then execute:
11
+ ## Usage
12
12
 
13
- $ bundle
13
+ Rippler supports Ripple API commands (https://ripple.com/wiki/RPC_API). All parameters after command should be given in JSON format, such as:
14
14
 
15
- Or install it yourself as:
15
+ $ rippler account_info ident:rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi
16
16
 
17
- $ gem install rippler
18
-
19
- ## Usage
17
+ $ rippler account_tx account:rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi ledger:319841
20
18
 
21
- TODO: Write usage instructions here
19
+ $ rippler account_tx account:rpH3zuMch2GrrYX724xGWwbMGwiQ5RbSAU ledger_min:300000 ledger_max:319000
22
20
 
23
21
  ## Contributing
24
22
 
data/bin/rippler ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler'
4
+ Bundler.setup
5
+
6
+ lib = File.expand_path('../lib', __FILE__)
7
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
8
+
9
+ require 'rippler'
10
+ require "pp"
11
+
12
+ pp Rippler.process ARGV
data/lib/rippler.rb CHANGED
@@ -1,5 +1,74 @@
1
+ require 'eventmachine'
2
+ require 'faye/websocket'
3
+ require "json"
1
4
  require "rippler/version"
5
+ require 'rippler/transaction'
6
+ require 'rippler/contacts'
2
7
 
3
8
  module Rippler
4
- # Your code goes here...
9
+ RIPPLE_URI = 'wss://s1.ripple.com:51233'
10
+ MY_ACCT = Rippler::Contacts["arvicco"]
11
+
12
+ # Turn command line arguments into command json
13
+ def self.process args
14
+ command_line = args.empty? ? ['account_info'] : args.dup
15
+
16
+ command = command_line.shift
17
+ params = Hash[*command_line.map {|p| p.split(':')}.flatten]
18
+ # p command, params
19
+
20
+ if Rippler.respond_to? command # pre-defined Rippler method
21
+ Rippler.send command, params
22
+ else # Arbitrary API command
23
+ Rippler.request params.merge(command: command)
24
+ end
25
+ end
26
+
27
+ # Make a single JSON request to Ripple over Websockets, return Ripple reply
28
+ def self.request params
29
+ reply = ''
30
+
31
+ EM.run {
32
+ ws = Faye::WebSocket::Client.new(RIPPLE_URI)
33
+
34
+ ws.onopen = lambda do |event|
35
+ # p [:open]
36
+ ws.send params.to_json
37
+ end
38
+
39
+ ws.onmessage = lambda do |event|
40
+ # p [:message]
41
+ reply = JSON.parse(event.data)
42
+ ws.close
43
+ end
44
+
45
+ ws.onerror = lambda do |event|
46
+ # p [:error, event]
47
+ end
48
+
49
+ ws.onclose = lambda do |event|
50
+ # p [:close, event.code, event.reason]
51
+ ws = nil
52
+ EM.stop
53
+ end
54
+ }
55
+ reply
56
+ end
57
+
58
+ # These are user-defined methods that post-process Ripple replies
59
+ def self.my_info params
60
+ request( {command: "account_info", ident: MY_ACCT}.merge(params) )
61
+ end
62
+
63
+ def self.my_tx params
64
+ reply = request( {command: "account_tx",
65
+ account: MY_ACCT,
66
+ ledger_min: 303000,
67
+ ledger_max: 329794,
68
+ resume: 0,
69
+ sort_asc: 1
70
+ }.merge(params) ) #(optional)
71
+ txs = reply["result"]["transactions"]
72
+ txs.map {|t| Transaction.new(t).to_s}
73
+ end
5
74
  end
@@ -0,0 +1,113 @@
1
+ module Rippler
2
+ Contacts = Hash[ *%W[
3
+ OpenCoin rJR7gjNe3DpJ7kpB4CHBxjDKfwVMpTKPpj
4
+ address_one rrrrrrrrrrrrrrrrrrrrBZbvji
5
+
6
+ weex_btc rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi
7
+ bitstamp rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B
8
+ bitstamp_hotwallet rrpNnNLKrartuEqfJGpqyDwPj1AFPg9vn1
9
+ weex_btc rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi
10
+ weex_aud rBcYpuDT1aXNo4jnqczWJTytKGdBGufsre
11
+ weex_cad r47RkFi1Ew3LvCNKT6ufw3ZCyj5AJiLHi9
12
+ weex_usd r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X
13
+
14
+ molecular rpH3zuMch2GrrYX724xGWwbMGwiQ5RbSAU
15
+ Ente rNEtVs4kNeESF5HbWCDZMYcWwKZ5iKwUEr
16
+ herzmeister rUdPvX9YN1NwyniwiJeSW6y3YKZL84gsB6
17
+ ribuck ra3a5cfr83b5FTh1YDURqWQh8HTbHEwdyD
18
+ Spekulatius rNHf9nnX4JgHferxjRxmapDev7mWQZ6XXd
19
+ Bitobsessed rKfd86S25PUdVquk41xedH5jNX4bZ8DiA7
20
+ Akka r9RpJFpD6vkKhgHhrRjkgofSbNsE1oYFZ1
21
+ bbit rB7qiwEDrcMShUN3Jd8LwXr4RJ7RWBaQu8
22
+ ryanAC rJA6mGHsw5yCynLFRe3rjGqaCMk2YpmuMy
23
+ phelix rM3puGNYNQTWuqsQpkzxSpmWFqGGuY29Vb
24
+ kokojie rNexqWdz7q16e6PPBDsD2XxxzFS64SAEYS
25
+ PeterLambert rGsLivkDjTZHFQ8oV2h81uTcbTpgjEaEY7
26
+ jorgen rQay7bQ3XoZcT6E3c8uDopZdnWaMBxWea2
27
+ Belkaar rJVshcxcxSAXkgzg1PiUQWr5TodTNAETva
28
+ grondilu rpuebQXsR7kAst5yidD6fmGmJHD4niXzbo
29
+ TimoY rG8VFQPaJB2gNjx29Et1wKUJettQP1eLmk
30
+ Melbustus rKAw7uHrdUUEqtfFhBBHe6unyh57PLpCc4
31
+ Aahzman r9TWUUN8duW1rDqJ2yz2wjksc8A9BpxPUh
32
+ AlexNeto rp3Papsq3aXf3gswfgfaqgegjLAEVaw8V1
33
+ thoughtcourier rn7iD6DpnCwH8kjJDCsENibMXkgmJkRCRz
34
+ znort987 rnozMbmRYfqvn15iBFNeeRJs95gagR2B46
35
+ RaTTuS rw65MQQDpWQYGxFEtcQk3r6dpeZ2gx5zff
36
+ romerun rU3cgYfpu9jedq8GnW43ArEntsWTD6Sg4n
37
+ PRab rEdaspCuZQWrxrGiGMQW3iPXjmEnfUxkqN
38
+ duckbillp rsa8BE2DfzLC52XQMUv3gECoZXQL7FNGig
39
+ Mageant rPDT5apJsfy8Jbz3M8jXzXskMsKAANhM9p
40
+ Severian rDqSvk6fRhKq5tSW7GpWFFHG5pG2XE3mtR
41
+ lebing rJFGHvCtpPrftTmeNAs8bYy5xUeTaxCD5t
42
+ gweedo rKFX2Gvk4jLtgEGMC2qDmMi18Zw4bewrjK
43
+ OgNasty r3hRKGL1JKWXJDujchZXrs6Pa16xsM6JjS
44
+ Mogly r9uVRhJEKsJVaxsU3c3rimzLWKYRmDUcX2
45
+ Warry rLgbpjNtVQ6ENjn5nGgnyi26gn9EBjuKhj
46
+ supert rh7eAu9SrFsE2fVfc1PJTs1WYDHGAUde6V
47
+ Evan rfpS692WVbsSXyv6R48K8A2LHCqdvYaS2w
48
+ BBQKorv rrhAmxxwxEchP2iJdGh7nrwwAK4u3BzaLC
49
+ TTBit rGwUWgN5BEg3QGNY3RX2HfYowjUTZdid3E
50
+ Mjbmonetarymetals rNTXjBWitdKUxr6o1zyi4FsjQ8UeP3JCKd
51
+ khal rpUjkUUcbteWbXrPt4aXAMwzotSPzQJHQt
52
+
53
+ arvicco rnZoUopPFXRSVGdeDkgbqdft8SbXfJxKYh
54
+ paysafecardbitcoin rN4kvobWCZVSzgLmo27B4kMjakAL31pMSr
55
+ Lethn r4DpNXFTohg1hgBKxrYv8YBtahKNAALjeH
56
+ nikkus rUhcZuPQBrykExj1VSfLnaeLdu2hJmVe9e
57
+ filharvey rJRFxWe3KxmhMfW7am5hFE9pkciAJHefeD
58
+ ablewasiereisawelba rPtTbUkhLZ9e2a7H3TCHcHmSa35jTnQHoa
59
+ luffy r3mjrPe1S4vHe2g6CTCeb6ezcPfpDywQAs
60
+ thepwnorbpwnd rLQ1WWeCVuM523iMRC9PCLpyFU8YkWqDdR
61
+ lightlord raAw68E3T6Eh4h5Qfb1ZxsWzyHkY8BZJRN
62
+ Wolf0 rwcpov2ZZmPpo6sjeg4n2oZx94uAYBQ21o
63
+ thepickingpair rht576qwyKXZ26JEGHYpC3N3atjNS8oM5j
64
+ Luceo rGZL3cCV6Er5Tiag9tStGhseF4NDBxbxQr
65
+ 21after2 rwuoJnBP4kyfR6Bry8ruLNyxubuk37w6gi
66
+ t.o.m. r4b5wQJL9qfqGZA6WQksE9spuYi4fmgDde
67
+ octopus r33dwR8VbfDvHptF2AYzp9JHjR7iVetqM
68
+ MichaelBliss rB2VLRRZejCMpDCyvGNn4nEHRLycwY7H8z
69
+ nckfor rD2yesqWXxgEztU6khSjts7tx8CF6VN3k3
70
+ FirewallXIII rEvYxDNoz8aFSRRWH6JoKBhBAqx6xDMN3G
71
+ 00null rhr3wb58NyicoBBXGfPQtctXxk1X8ZhwcM
72
+ Isamaru rGsfVSM9etepbYoa52AScPRd2eSdv86ZDf
73
+ ragmondo rHm9QPX7v2xz9JMozrYnJynfgEhnQ6Aaeo
74
+ trippp rL4px896Gf2r5PDru38jsJt3qTN9NmpgEd
75
+ TheRenix rMPJ77FoY86cLLzhQ3ETnvNdAvy6A4UMqR
76
+ simonk83 r3U8PomU1pw4T48cmXVahUNuUerNVcbwto
77
+ rme rJeuPjq9XBZkuxk51hmXSsFmANy7JbBCRC
78
+ Ecks rJaBUL6npe6yvoJU7e5nuRgAaMoa3njnQ8
79
+ NABiT rLorFPMtVzutmcZBDGpAeQLfVyCL19p1qK
80
+ JesterOfTortuga rDGLPeQTbd7ntNRNdwAtgAjnUPf7YwDHGz
81
+ ryanbrownstar rvTZGvDaKza8Zuhm4E7vnLtTuMU2MgwX3
82
+ mmkiwi rJpG5GJrpKBabbqGphfijjdZe2bkyPewL7
83
+ camolist rBzu6o32DoHtHUvRYUKwcHMsgz1BTSTyek
84
+ cambda rfxAqtZA9Knb8mb1Gij4Y6rFfTfp6FWSTZ
85
+ cambda-1 rBBSghHNdpbBuT5kiGruX5TjofWLF2fi74
86
+ TheInventor r7a3uqQREUU6tEYnsCTFWh31DeVHWNp2G
87
+ rizzla rLnhMYFwqUkc2D8ojJmhQkNuytaBsyzVG3
88
+ Moshi r9fupyMm63XMvbAozvzjLyHdJHCtLEKveE
89
+ bachus rKQLwGTe6NX16iSEuS88bi3FEqZnbwF7EB
90
+ helloworld rwDo98FnbCp3qUN5CkwDcK4rFfbyW3Kzqq
91
+ Cyberdyne ragN8YEhHjXbgeGrNGLw9wuxQeq1d8qHk
92
+ cardinalG rQr973QcHXx1NCfXpQdLPpnGmMrkDjwRXB
93
+ dalek r3HpcvyJUhpGzJGa7KBZcvo35EiDqLtU1V
94
+ Slackware1995 rLHacQyTzfRjHMp7yFzXu18cbt6KteSXBP
95
+ WalterRothbard rwaaH5CCdWe8V7kBbXQonpFyKbRDePF9Vc
96
+ spndr7 rUusFTWNUDYqKnAg4tiZLTAyRdUMaVFVUG
97
+ kakobrekla rHrkFodY9f3DxQnSsHiu6R1j4JvTYfFnRS
98
+ ny2cafuse rBh3KyjpANw5GXbt9AmCiFB2MbYGxWSCWa
99
+ chris200x9 r9MmCAquMciDwGRqKUXvayK2LAayPSvYuz
100
+ Prospero rB8N1ohjVKtMiZVivSY3H6Y3ABcAMJce36
101
+ Atruk rp3uz9jcb8LkMpMvwsfFTaCpkEgAGxNnKj
102
+ Isokivi rUjVzMqFpFYLQ8PoKb46psWuKhkxgZFTnx
103
+ Anormalname rp9DmXB6uxkooTeGpdtjaj8eT8V3ENaads
104
+ Luno rDcW2mqMKGHZ4iFKkTSyHyBT4AtLNBwge
105
+ weex@bitcointalk rEjC6w3m7ENkmD9SAyFyfKgRgeNz7HbkbW
106
+ gbl08ma rsgg1U8UpYodp1GM3NDaYfMrZge97Gpvc9
107
+ tosku rBs43YZMn5QsYY9jZYcG4C3egEebUfGWh3
108
+ BitcoinG r3CxMDQFX1Atq1vQN5sqVsjm3rawGSwd32
109
+
110
+ ]]
111
+
112
+ Addresses = Contacts.invert
113
+ end
@@ -0,0 +1,38 @@
1
+
2
+ module Rippler
3
+ class Transaction
4
+ def initialize data # data hash
5
+ @data = data
6
+ end
7
+
8
+ def name account
9
+ Rippler::Addresses[account] || account
10
+ end
11
+
12
+ def amount money
13
+ if money.is_a? Hash
14
+ "#{money['value']}/#{money['currency']}/#{name(money['issuer'])}"
15
+ else
16
+ "#{money.to_i/1000000.0}/XRP"
17
+ end
18
+
19
+ end
20
+
21
+ def to_s
22
+ tx = @data["tx"]
23
+ case tx["TransactionType"]
24
+ when "Payment"
25
+ "PAY #{amount(tx['Amount'])} #{name(tx['Account'])} > #{name(tx['Destination'])}"
26
+ # when "OfferCancel"
27
+ # "CAN #{name(tx['Account'])} ##{tx['Sequence']}"
28
+ # when "OfferCreate"
29
+ # "OFR #{name(tx['Account'])} ##{tx['Sequence']} offers " +
30
+ # "#{amount(tx['TakerGets'])} for #{amount(tx['TakerPays'])}"
31
+ # when "TrustSet"
32
+ # "TRS #{amount(tx['LimitAmount'])} #{name(tx['Account'])}"
33
+ else
34
+ tx
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module Rippler
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/rippler.gemspec CHANGED
@@ -16,4 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'faye-websocket', '~> 0.4'
21
+ # gem.add_dependency 'websocket-eventmachine-client', '~> 1.0'
19
22
  end
metadata CHANGED
@@ -1,20 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rippler
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - arvicco
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-05 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faye-websocket
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.4'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.4'
14
30
  description: Command line client for Ripple payment platform
15
31
  email:
16
32
  - arvicco@gmail.com
17
- executables: []
33
+ executables:
34
+ - rippler
18
35
  extensions: []
19
36
  extra_rdoc_files: []
20
37
  files:
@@ -24,34 +41,34 @@ files:
24
41
  - LICENSE.txt
25
42
  - README.md
26
43
  - Rakefile
44
+ - bin/rippler
27
45
  - lib/rippler.rb
46
+ - lib/rippler/contacts.rb
47
+ - lib/rippler/transaction.rb
28
48
  - lib/rippler/version.rb
29
49
  - rippler.gemspec
30
50
  homepage: ''
31
51
  licenses: []
32
- post_install_message:
52
+ post_install_message:
33
53
  rdoc_options: []
34
54
  require_paths:
35
55
  - lib
36
56
  required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
37
58
  requirements:
38
59
  - - ! '>='
39
60
  - !ruby/object:Gem::Version
40
- version: !binary |-
41
- MA==
42
- none: false
61
+ version: '0'
43
62
  required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
44
64
  requirements:
45
65
  - - ! '>='
46
66
  - !ruby/object:Gem::Version
47
- version: !binary |-
48
- MA==
49
- none: false
67
+ version: '0'
50
68
  requirements: []
51
- rubyforge_project:
69
+ rubyforge_project:
52
70
  rubygems_version: 1.8.24
53
- signing_key:
71
+ signing_key:
54
72
  specification_version: 3
55
73
  summary: Command line client for Ripple payment platform, uses websocket API
56
74
  test_files: []
57
- has_rdoc: