cryptopunks-graphql 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/CHANGELOG.md +3 -0
- data/Manifest.txt +9 -0
- data/README.md +20 -0
- data/Rakefile +29 -0
- data/lib/cryptopunks-graphql.rb +7 -0
- data/lib/cryptopunks/graphql.rb +22 -0
- data/lib/cryptopunks/graphql/client.rb +43 -0
- data/lib/cryptopunks/graphql/query.rb +28 -0
- data/lib/cryptopunks/graphql/version.rb +22 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 791e8ee6cf7734f5f4080c4886dfec62bcb0c8eb260be868b5a9957429a5a99b
|
4
|
+
data.tar.gz: 2502826afbd6e3c2bf5db221fb0dd604e0442e409fc55b4163336cbbee029302
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c54a379c06ca46f1db1d1faa80899e5ec430d4a3d45f802be16083fb65463db69883b3c821c535de463d2ad760dfc938d536628602d3b9a9335bea05841c8678
|
7
|
+
data.tar.gz: 0ec231917f9c9299084b68170d5b50ee374306ffb6b326a41c9b15b8422400c74392d38966a09b8f6d365882a98250f572f4d29468800768044343284ceb746d
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Cryptopunks GraphQL
|
2
|
+
|
3
|
+
|
4
|
+
cryptopunks-graphql - web client (helpers) for using Cryptopunks (HTTP JSON) GraphQL APIs
|
5
|
+
|
6
|
+
|
7
|
+
* home :: [github.com/cryptopunksnotdead/cryptopunks](https://github.com/cryptopunksnotdead/cryptopunks)
|
8
|
+
* bugs :: [github.com/cryptopunksnotdead/cryptopunks/issues](https://github.com/cryptopunksnotdead/cryptopunks/issues)
|
9
|
+
* gem :: [rubygems.org/gems/cryptopunks-graphql](https://rubygems.org/gems/cryptopunks-graphql)
|
10
|
+
* rdoc :: [rubydoc.info/gems/cryptopunks-graphql](http://rubydoc.info/gems/cryptopunks-graphql)
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
|
18
|
+
TBD
|
19
|
+
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/cryptopunks/graphql/version.rb'
|
3
|
+
|
4
|
+
Hoe.spec 'cryptopunks-graphql' do
|
5
|
+
|
6
|
+
self.version = CryptopunksClient::VERSION
|
7
|
+
|
8
|
+
self.summary = "cryptopunks-graphql - (lite) cryptopunks (http json) graphql api / client"
|
9
|
+
self.description = summary
|
10
|
+
|
11
|
+
self.urls = { home: 'https://github.com/cryptopunksnotdead/cryptopunks' }
|
12
|
+
|
13
|
+
self.author = 'Gerald Bauer'
|
14
|
+
self.email = 'wwwmake@googlegroups.com'
|
15
|
+
|
16
|
+
# switch extension to .markdown for gihub formatting
|
17
|
+
self.readme_file = 'README.md'
|
18
|
+
self.history_file = 'CHANGELOG.md'
|
19
|
+
|
20
|
+
self.extra_deps = [
|
21
|
+
]
|
22
|
+
|
23
|
+
self.licenses = ['Public Domain']
|
24
|
+
|
25
|
+
self.spec_extras = {
|
26
|
+
required_ruby_version: '>= 2.3'
|
27
|
+
}
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'uri'
|
4
|
+
require 'json'
|
5
|
+
require 'yaml'
|
6
|
+
require 'date'
|
7
|
+
require 'time'
|
8
|
+
require 'fileutils'
|
9
|
+
require 'pp'
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
## our own code
|
14
|
+
require 'cryptopunks/graphql/version' # note: let version always go first
|
15
|
+
require 'cryptopunks/graphql/client'
|
16
|
+
require 'cryptopunks/graphql/query'
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
# say hello
|
22
|
+
puts CryptopunksClient.banner
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
module Cryptopunks
|
3
|
+
class Client
|
4
|
+
|
5
|
+
|
6
|
+
def initialize( base_uri: )
|
7
|
+
@base_uri = base_uri
|
8
|
+
end
|
9
|
+
|
10
|
+
def post( **params )
|
11
|
+
|
12
|
+
uri = URI.parse( @base_uri )
|
13
|
+
res = Net::HTTP.start( uri.host, uri.port,
|
14
|
+
use_ssl: true) do |http|
|
15
|
+
req = Net::HTTP::Post.new( uri )
|
16
|
+
req['Content-Type'] = 'application/json'
|
17
|
+
|
18
|
+
# note: the body needs to be a JSON string
|
19
|
+
req.body = JSON.generate( params )
|
20
|
+
|
21
|
+
# puts
|
22
|
+
# puts "graphql post:"
|
23
|
+
# puts req.body
|
24
|
+
# puts "---"
|
25
|
+
|
26
|
+
http.request( req )
|
27
|
+
end
|
28
|
+
|
29
|
+
if res.code.to_i != 200
|
30
|
+
puts "!! ERROR: HTTP #{res.code} #{res.message}:"
|
31
|
+
pp res
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
|
35
|
+
body = res.body.to_s
|
36
|
+
## note: assumes ascii-8bit/binary encoding (by default)
|
37
|
+
## change to utf-8 (as always required by json )
|
38
|
+
body = body.force_encoding( Encoding::UTF_8 )
|
39
|
+
|
40
|
+
data = JSON.parse( body )
|
41
|
+
end
|
42
|
+
end # class Client
|
43
|
+
end # module Cryptopunks
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module Cryptopunks
|
3
|
+
module GraphQL
|
4
|
+
|
5
|
+
class Client < ::Cryptopunks::Client
|
6
|
+
def initialize
|
7
|
+
super( base_uri: 'https://api.thegraph.com/subgraphs/name/itsjerryokolo/cryptopunks' )
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
#####
|
12
|
+
# generic query via HTTP POST
|
13
|
+
def query( query, includes: [] )
|
14
|
+
if includes.size > 0
|
15
|
+
## check for end-of-line comments with @INCLUDES marker
|
16
|
+
query = query.gsub( /[#]+[ ]+@INCLUDES[^\n\r]+/,
|
17
|
+
includes.join( ' ' ) )
|
18
|
+
end
|
19
|
+
|
20
|
+
post( query: query )
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end # class Client
|
25
|
+
end # module GraphQL
|
26
|
+
end # module Cryptopunks
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module CryptopunksClient
|
3
|
+
|
4
|
+
MAJOR = 0
|
5
|
+
MINOR = 1
|
6
|
+
PATCH = 0
|
7
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
8
|
+
|
9
|
+
def self.version
|
10
|
+
VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"cryptopunks-graphql/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in #{root}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.root
|
18
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )
|
19
|
+
end
|
20
|
+
|
21
|
+
end # module CryptopunksClient
|
22
|
+
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cryptopunks-graphql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rdoc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '7'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: hoe
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.22'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.22'
|
47
|
+
description: cryptopunks-graphql - (lite) cryptopunks (http json) graphql api / client
|
48
|
+
email: wwwmake@googlegroups.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files:
|
52
|
+
- CHANGELOG.md
|
53
|
+
- Manifest.txt
|
54
|
+
- README.md
|
55
|
+
files:
|
56
|
+
- CHANGELOG.md
|
57
|
+
- Manifest.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- lib/cryptopunks-graphql.rb
|
61
|
+
- lib/cryptopunks/graphql.rb
|
62
|
+
- lib/cryptopunks/graphql/client.rb
|
63
|
+
- lib/cryptopunks/graphql/query.rb
|
64
|
+
- lib/cryptopunks/graphql/version.rb
|
65
|
+
homepage: https://github.com/cryptopunksnotdead/cryptopunks
|
66
|
+
licenses:
|
67
|
+
- Public Domain
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options:
|
71
|
+
- "--main"
|
72
|
+
- README.md
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '2.3'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.1.4
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: cryptopunks-graphql - (lite) cryptopunks (http json) graphql api / client
|
90
|
+
test_files: []
|