ruam 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +40 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE +13 -0
- data/README.md +74 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/circle.yml +18 -0
- data/exe/ruam +24 -0
- data/lib/ruam.rb +38 -0
- data/lib/ruam/options.rb +49 -0
- data/lib/ruam/version.rb +17 -0
- data/ruam.gemspec +28 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ee5bc981d769bbe0c6d4848921bd3205124a3a32
|
4
|
+
data.tar.gz: f8f3187089ecdf636d671e6dc1546761adf8d743
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2847de904ad7f367d1ec4de0cd00f1b5040f641c9fa6fcae55619dd7a3ed0bf5f31649bc70c748a029fee11872aec2146b431977902350e69294942d84f0a28
|
7
|
+
data.tar.gz: 94e5243e2236601114ca857f6c3d604c3092d1269897b28527bcc88d22750f7f89af3272b88bec7abe873d990b9972427c72f0d79a395c9dd5a95b2b4eb66773
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Metrics/LineLength:
|
2
|
+
Max: 100
|
3
|
+
|
4
|
+
Style/EndOfLine:
|
5
|
+
EnforcedStyle: lf
|
6
|
+
|
7
|
+
Style/BracesAroundHashParameters:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Style/FrozenStringLiteralComment:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/MutableConstant:
|
14
|
+
AutoCorrect: false
|
15
|
+
|
16
|
+
Style/SafeNavigation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/ParameterLists:
|
20
|
+
Exclude:
|
21
|
+
- spec/**/*
|
22
|
+
|
23
|
+
Metrics/MethodLength:
|
24
|
+
Max: 15
|
25
|
+
|
26
|
+
Metrics/BlockLength:
|
27
|
+
Exclude:
|
28
|
+
- spec/**/*
|
29
|
+
|
30
|
+
Metrics/AbcSize:
|
31
|
+
Max: 20
|
32
|
+
|
33
|
+
Metrics/PerceivedComplexity:
|
34
|
+
Max: 8
|
35
|
+
|
36
|
+
Metrics/CyclomaticComplexity:
|
37
|
+
Max: 7
|
38
|
+
|
39
|
+
Performance/RedundantMerge:
|
40
|
+
Enabled: false
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (C) 2017 autopp
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Ruam
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/ruam.svg)](https://badge.fury.io/rb/ruam)
|
3
|
+
[![Build Status](https://circleci.com/gh/autopp/ruam.svg?style=shield&circle-token=21fbc0adbc3428399a27b0f1334dd52ff22d8fd8)](https://circleci.com/gh/autopp/ruam)
|
4
|
+
|
5
|
+
Ruam is a simple command line tool to inspect a byte code of Ruby script.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruam'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ruam
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```
|
26
|
+
$ cat hello.rb
|
27
|
+
puts 'hello world'
|
28
|
+
|
29
|
+
$ ruam hello.rb
|
30
|
+
== disasm: #<ISeq:<main>@hello.rb>======================================
|
31
|
+
0000 trace 1 ( 1)
|
32
|
+
0002 putself
|
33
|
+
0003 putstring "hello world"
|
34
|
+
0005 opt_send_without_block <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
|
35
|
+
0008 leave
|
36
|
+
```
|
37
|
+
|
38
|
+
If file name is not given, `ruam` read from stdin:
|
39
|
+
|
40
|
+
```
|
41
|
+
$ echo "puts 'hello world'" | ruam
|
42
|
+
== disasm: #<ISeq:<compiled>@<compiled>>================================
|
43
|
+
0000 trace 1 ( 1)
|
44
|
+
0002 putself
|
45
|
+
0003 putstring "hello world"
|
46
|
+
0005 opt_send_without_block <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
|
47
|
+
0008 leave
|
48
|
+
```
|
49
|
+
|
50
|
+
You can enable/disable compile option which are [defined in the VM](https://docs.ruby-lang.org/en/2.4.0/RubyVM/InstructionSequence.html#method-c-compile_option-3D):
|
51
|
+
|
52
|
+
```
|
53
|
+
$ ruam hello.rb --no-trace-instruction
|
54
|
+
== disasm: #<ISeq:<main>@hello.rb>======================================
|
55
|
+
0000 putself ( 1)
|
56
|
+
0001 putstring "hello world"
|
57
|
+
0003 opt_send_without_block <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
|
58
|
+
0006 leave
|
59
|
+
```
|
60
|
+
|
61
|
+
For more info, execute `ruam -h`.
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruam.
|
66
|
+
|
67
|
+
|
68
|
+
## Lisence
|
69
|
+
|
70
|
+
[Apache License 2.0](LICENSE)
|
71
|
+
|
72
|
+
## Author
|
73
|
+
|
74
|
+
[@AuToPP](https://twitter.com/AuToPP)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'ruam'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
dependencies:
|
2
|
+
pre:
|
3
|
+
- gem install bundler
|
4
|
+
|
5
|
+
test:
|
6
|
+
post:
|
7
|
+
- bundle exec ruam lib/ruam.rb
|
8
|
+
- bundle exec rubocop -D
|
9
|
+
|
10
|
+
deployment:
|
11
|
+
rubygems:
|
12
|
+
tag: /v[0-9]+(\.[0-9]+)*/
|
13
|
+
owner: autopp
|
14
|
+
commands:
|
15
|
+
- git config --local user.name "autopp"
|
16
|
+
- git config --local user.email "autopp@gmail.com"
|
17
|
+
- 'echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials && chmod 0600 ~/.gem/credentials'
|
18
|
+
- bundle exec rake release
|
data/exe/ruam
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (C) 2017 autopp
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'ruam'
|
18
|
+
|
19
|
+
begin
|
20
|
+
Ruam.run(ARGV)
|
21
|
+
rescue Ruam::Options::ParseError, IOError, Errno::ENOENT => e
|
22
|
+
$stderr.puts e.message
|
23
|
+
exit 1
|
24
|
+
end
|
data/lib/ruam.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Copyright (C) 2017 autopp
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'ruam/version'
|
16
|
+
|
17
|
+
# Top level namespace for ruam
|
18
|
+
#
|
19
|
+
module Ruam
|
20
|
+
def self.optimization_flags
|
21
|
+
RubyVM::InstructionSequence.compile_option.keys - %i[debug_level]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.run(argv)
|
25
|
+
options = Options.parse(argv)
|
26
|
+
file = options[:file]
|
27
|
+
compile_options = RubyVM::InstructionSequence.compile_option.merge(options[:compile_options])
|
28
|
+
|
29
|
+
insns = if file
|
30
|
+
RubyVM::InstructionSequence.compile_file(file, compile_options)
|
31
|
+
else
|
32
|
+
RubyVM::InstructionSequence.compile($stdin.read, nil, nil, 1, compile_options)
|
33
|
+
end
|
34
|
+
puts insns.disasm
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'ruam/options'
|
data/lib/ruam/options.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (C) 2017 autopp
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'optparse'
|
16
|
+
|
17
|
+
module Ruam
|
18
|
+
# Command line option parser
|
19
|
+
#
|
20
|
+
class Options
|
21
|
+
def self.parse(argv)
|
22
|
+
options = { compile_options: {} }
|
23
|
+
parser = create_parser(options[:compile_options])
|
24
|
+
begin
|
25
|
+
argv = parser.parse(argv)
|
26
|
+
raise ParseError, 'more than one file is specified' if argv.size > 1
|
27
|
+
rescue OptionParser::InvalidOption => e
|
28
|
+
raise ParseError, e.message
|
29
|
+
end
|
30
|
+
options[:file] = argv.first
|
31
|
+
options
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.create_parser(options)
|
35
|
+
parser = OptionParser.new
|
36
|
+
Ruam.optimization_flags.each do |flag|
|
37
|
+
parser.on("--[no-]#{flag.to_s.tr('_', '-')}") do |v|
|
38
|
+
options[flag] = v
|
39
|
+
end
|
40
|
+
end
|
41
|
+
parser.on('--debug-level=LEVEL') do |v|
|
42
|
+
options[:debug_level] = v.to_i
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class ParseError < StandardError
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/ruam/version.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (C) 2017 autopp
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Ruam
|
16
|
+
VERSION = '1.0.0'.freeze
|
17
|
+
end
|
data/ruam.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'ruam/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'ruam'
|
9
|
+
spec.version = Ruam::VERSION
|
10
|
+
spec.authors = ['autopp']
|
11
|
+
spec.email = ['autopp.inc@gmail.com']
|
12
|
+
|
13
|
+
spec.summary = 'Command line tool to show byte code of Ruby script'
|
14
|
+
spec.description = spec.summary
|
15
|
+
spec.homepage = 'https://github.com/autopp/ruam'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 0.48'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruam
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- autopp
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.48'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.48'
|
69
|
+
description: Command line tool to show byte code of Ruby script
|
70
|
+
email:
|
71
|
+
- autopp.inc@gmail.com
|
72
|
+
executables:
|
73
|
+
- ruam
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".rubocop.yml"
|
80
|
+
- CHANGELOG.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- circle.yml
|
88
|
+
- exe/ruam
|
89
|
+
- lib/ruam.rb
|
90
|
+
- lib/ruam/options.rb
|
91
|
+
- lib/ruam/version.rb
|
92
|
+
- ruam.gemspec
|
93
|
+
homepage: https://github.com/autopp/ruam
|
94
|
+
licenses: []
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.6.11
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Command line tool to show byte code of Ruby script
|
116
|
+
test_files: []
|