serpent 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +28 -0
- data/LICENSE +21 -0
- data/README.md +37 -0
- data/Rakefile +16 -0
- data/ext/serpent/extconf.rb +10 -0
- data/ext/serpent/serpent.cpp +14 -0
- data/lib/serpent.rb +2 -0
- data/lib/serpent/version.rb +3 -0
- data/serpent.gemspec +24 -0
- data/test/serpent_test.rb +27 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ad07711497242c6c90013febde570d8a87958329
|
4
|
+
data.tar.gz: 91f99850b31ccc9ab4a20744793d6836b1574c85
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b745daa653e6eabe1f5657053a55ffbcb1845c14c8d4dec678647d8a9aca49248e1ef58befa1bedcede9e8a48659983cb4764799d46b2f73a3306093b2c025f5
|
7
|
+
data.tar.gz: c60cc1e0e94fc1a793effffec1f4934cacb6399684d8f8a68d48492477eae8a40c95750c332ec17eb0edf5a8b594cdf3b2aa465bca3445b5a88c750f70f6d578
|
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
serpent (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://ruby.taobao.org/
|
8
|
+
specs:
|
9
|
+
minitest (5.8.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rake-compiler (0.9.5)
|
12
|
+
rake
|
13
|
+
rice (2.1.0)
|
14
|
+
yard (0.8.7.6)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
minitest (= 5.8.3)
|
21
|
+
rake (~> 10.5)
|
22
|
+
rake-compiler (~> 0.9)
|
23
|
+
rice (~> 2.1)
|
24
|
+
serpent!
|
25
|
+
yard (= 0.8.7.6)
|
26
|
+
|
27
|
+
BUNDLED WITH
|
28
|
+
1.11.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jan Xie
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# ruby-serpent
|
2
|
+
|
3
|
+
## Install
|
4
|
+
|
5
|
+
```
|
6
|
+
gem i serpent
|
7
|
+
```
|
8
|
+
|
9
|
+
## Dev Build
|
10
|
+
|
11
|
+
```
|
12
|
+
git submodule sync
|
13
|
+
git submodule update
|
14
|
+
|
15
|
+
# compile and install libserpent
|
16
|
+
cd serpent
|
17
|
+
make
|
18
|
+
sudo make install
|
19
|
+
cd ..
|
20
|
+
|
21
|
+
# compile extension
|
22
|
+
rake compile
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Check test for examples.
|
28
|
+
|
29
|
+
## LICENSE
|
30
|
+
|
31
|
+
[MIT License](LICENSE)
|
32
|
+
|
33
|
+
## References
|
34
|
+
|
35
|
+
* [Ethereum](http://ethereum.org)
|
36
|
+
* [Serpent](https://github.com/ethereum/wiki/wiki/Serpent)
|
37
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rake/extensiontask'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
Rake::ExtensionTask.new "serpent" do |ext|
|
7
|
+
ext.lib_dir = 'lib/serpent'
|
8
|
+
end
|
9
|
+
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.libs += %w(lib test)
|
12
|
+
t.test_files = FileList['test/**/*_test.rb']
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
task default: [:test]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'mkmf-rice'
|
2
|
+
|
3
|
+
#include_dir = File.expand_path('../../../include', __FILE__)
|
4
|
+
#lib_dir = File.expand_path('../../../lib', __FILE__)
|
5
|
+
|
6
|
+
#dir_config('serpent', [include_dir], [lib_dir])
|
7
|
+
|
8
|
+
abort "missing libserpent.so" unless have_library "serpent"
|
9
|
+
|
10
|
+
create_makefile('serpent/serpent')
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#include "rice/Module.hpp"
|
2
|
+
using namespace Rice;
|
3
|
+
|
4
|
+
#include "libserpent/funcs.h"
|
5
|
+
|
6
|
+
std::string serpent_compile(Object self, std::string code) {
|
7
|
+
return compile(code);
|
8
|
+
}
|
9
|
+
|
10
|
+
extern "C"
|
11
|
+
void Init_serpent() {
|
12
|
+
Module rb_mSerpent = define_module("Serpent")
|
13
|
+
.define_module_function("compile", &serpent_compile);
|
14
|
+
}
|
data/lib/serpent.rb
ADDED
data/serpent.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require 'serpent/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "serpent"
|
7
|
+
s.version = Serpent::VERSION
|
8
|
+
s.authors = ["Jan Xie"]
|
9
|
+
s.email = ["jan.h.xie@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/janx/ruby-serpent"
|
11
|
+
s.summary = "Ruby binding to Ethereum Serpent compiler."
|
12
|
+
s.description = "Serpent is a Python style smart contract language."
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.extensions = ['ext/serpent/extconf.rb']
|
18
|
+
|
19
|
+
s.add_development_dependency('rake', '~> 10.5')
|
20
|
+
s.add_development_dependency('rake-compiler', '~> 0.9')
|
21
|
+
s.add_development_dependency('rice', '~> 2.1')
|
22
|
+
s.add_development_dependency('minitest', '5.8.3')
|
23
|
+
s.add_development_dependency('yard', '0.8.7.6')
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'serpent'
|
5
|
+
|
6
|
+
class SerpentTest < Minitest::Test
|
7
|
+
|
8
|
+
def test_compile
|
9
|
+
code = <<-SERPENT
|
10
|
+
def main(a,b):
|
11
|
+
return(a ^ b)
|
12
|
+
SERPENT
|
13
|
+
|
14
|
+
assert_equal decode_hex('604a80600b6000396055567c0100000000000000000000000000000000000000000000000000000000600035046397d857aa8114156048576004356040526024356060526060516040510a60805260206080f35b505b6000f3'), Serpent.compile(code)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def encode_hex(s)
|
20
|
+
s.unpack('H*').first
|
21
|
+
end
|
22
|
+
|
23
|
+
def decode_hex(s)
|
24
|
+
[s].pack('H*')
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: serpent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Xie
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rice
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 5.8.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 5.8.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.8.7.6
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.7.6
|
83
|
+
description: Serpent is a Python style smart contract language.
|
84
|
+
email:
|
85
|
+
- jan.h.xie@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions:
|
88
|
+
- ext/serpent/extconf.rb
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".gitmodules"
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- ext/serpent/extconf.rb
|
99
|
+
- ext/serpent/serpent.cpp
|
100
|
+
- lib/serpent.rb
|
101
|
+
- lib/serpent/version.rb
|
102
|
+
- serpent.gemspec
|
103
|
+
- test/serpent_test.rb
|
104
|
+
homepage: https://github.com/janx/ruby-serpent
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.5
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Ruby binding to Ethereum Serpent compiler.
|
128
|
+
test_files:
|
129
|
+
- test/serpent_test.rb
|
130
|
+
has_rdoc:
|