msgpack-inspect 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5a3c533c3c23728a626a5f6a92b0ded176cf1cb
4
- data.tar.gz: 2a5d4ed28d7d5d02886d3a80ae88571ea966b450
3
+ metadata.gz: 6e91d7d7767afb363718c4d91b9eb5b3777d1ba6
4
+ data.tar.gz: 5ddb504a62ad2ef03baa4fa5f0155ad301c9a769
5
5
  SHA512:
6
- metadata.gz: f0748e0b795f82c17b95e44a065e59cea0a7cb23347d1503af7b551320f5c221e5440f468ef023075b460b643aaf9b5871acb63b9dacb1c82d033924d05433da
7
- data.tar.gz: d827254fb029595163b033a211bdda005be4fc3eea5b41beb016f8d46f1c690d0284964057113c1d1416e7efb0ee072249a22e2a204dece8a1e62332f75cdf4c
6
+ metadata.gz: ba04b57ddfac50103b15bacf1ed8dd3d82bad41a0cd0b1d6d61136ef0622f01c482fa73e42bfa967e990ece5d3b68e4fc77da7d617a1201f51ce6ab744abddfe
7
+ data.tar.gz: 7bdb948ec679f023f568b4b10d9a6f4718e3f402365612e742f4662628be64c4198e05e4188046ff3508857b19f094f9997ee408a831b75b56b32996676ffcd0
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /mruby/
11
+ /releases/
data/.travis.yml CHANGED
@@ -1,11 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.3
4
+ - 2.3.1
5
5
 
6
- os:
7
- - linux
8
- - osx
6
+ script:
7
+ - bundle exec rake test
9
8
 
10
9
  sudo: false
11
10
 
data/Dockerfile ADDED
@@ -0,0 +1 @@
1
+ FROM hone/mruby-cli
data/README.md CHANGED
@@ -45,9 +45,45 @@ This command shows the all data contained in specified format (YAML in default).
45
45
  :value: true
46
46
  ```
47
47
 
48
+ ## Example
49
+
50
+ This is a example to inspect a data from STDIN.
51
+ The data corresponds to `{"compact":true,"schema":0}` in JSON.
52
+
53
+ ```
54
+ $ printf "\x82\xa7compact\xc3\xa6schema\x00" | msgpack-inspect -
55
+ ---
56
+ - :format: :fixmap
57
+ :header: '82'
58
+ :length: 2
59
+ :children:
60
+ - :key:
61
+ :format: :fixstr
62
+ :header: a7
63
+ :length: 7
64
+ :data: 636f6d70616374
65
+ :value: compact
66
+ :value:
67
+ :format: :true
68
+ :header: c3
69
+ :data: c3
70
+ :value: true
71
+ - :key:
72
+ :format: :fixstr
73
+ :header: a6
74
+ :length: 6
75
+ :data: 736368656d61
76
+ :value: schema
77
+ :value:
78
+ :format: :fixint
79
+ :header: '00'
80
+ :data: '00'
81
+ :value: 0
82
+ ```
83
+
48
84
  TODO: show more example
49
85
 
50
86
  ## Contributing
51
87
 
52
- Bug reports and pull requests are welcome on GitHub at [https://github.com/tafomoris/msgpack-inspect].
88
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/tagomoris/msgpack-inspect].
53
89
 
data/Rakefile CHANGED
@@ -1,18 +1,130 @@
1
- require "bundler/gem_tasks"
2
-
3
1
  require 'fileutils'
4
- require 'rake/testtask'
5
- require 'rake/clean'
6
2
 
7
- Rake::TestTask.new(:test) do |t|
8
- # To run test for only one file (or file path pattern)
9
- # $ bundle exec rake test TEST=test/test_specified_path.rb
10
- # $ bundle exec rake test TEST=test/test_*.rb
11
- t.libs << "test"
12
- t.test_files = Dir["test/**/test_*.rb"].sort
13
- t.verbose = true
14
- t.warning = true
15
- t.ruby_opts = ["-Eascii-8bit:ascii-8bit"]
3
+ MRUBY_VERSION="1.2.0"
4
+
5
+ file :mruby do
6
+ #sh "git clone --depth=1 https://github.com/mruby/mruby"
7
+ sh "curl -L --fail --retry 3 --retry-delay 1 https://github.com/mruby/mruby/archive/#{MRUBY_VERSION}.tar.gz -s -o - | tar zxf -"
8
+ FileUtils.mv("mruby-#{MRUBY_VERSION}", "mruby")
9
+ end
10
+
11
+ APP_NAME=ENV["APP_NAME"] || "msgpack-inspect"
12
+ APP_ROOT=ENV["APP_ROOT"] || Dir.pwd
13
+ # avoid redefining constants in mruby Rakefile
14
+ mruby_root=File.expand_path(ENV["MRUBY_ROOT"] || "#{APP_ROOT}/mruby")
15
+ mruby_config=File.expand_path(ENV["MRUBY_CONFIG"] || "build_config.rb")
16
+ ENV['MRUBY_ROOT'] = mruby_root
17
+ ENV['MRUBY_CONFIG'] = mruby_config
18
+ Rake::Task[:mruby].invoke unless Dir.exist?(mruby_root)
19
+ load "#{mruby_root}/Rakefile"
20
+ Rake::Task['test'].clear # to clear test task of mruby/Rakefile
21
+
22
+ desc "compile binary"
23
+ task :compile => [:all] do
24
+ Dir.chdir(mruby_root) do
25
+ MRuby.each_target do |target|
26
+ `#{target.cc.command} --version`
27
+ abort("Command #{target.cc.command} for #{target.name} is missing.") unless $?.success?
28
+ end
29
+ %W(#{mruby_root}/build/x86_64-pc-linux-gnu/bin/#{APP_NAME} #{mruby_root}/build/i686-pc-linux-gnu/#{APP_NAME}).each do |bin|
30
+ sh "strip --strip-unneeded #{bin}" if File.exist?(bin)
31
+ end
32
+ end
33
+ end
34
+
35
+ desc "cleanup"
36
+ task :clean do
37
+ Dir.chdir(mruby_root) do
38
+ sh "rake deep_clean"
39
+ end
40
+ end
41
+
42
+ desc "generate a release tarball"
43
+ task :release => :compile do
44
+ require 'tmpdir'
45
+
46
+ Dir.chdir(mruby_root) do
47
+ # since we're in the mruby/
48
+ release_dir = "releases/v#{APP_VERSION}"
49
+ release_path = Dir.pwd + "/../#{release_dir}"
50
+ app_name = "#{APP_NAME}-#{APP_VERSION}"
51
+ FileUtils.mkdir_p(release_path)
52
+
53
+ Dir.mktmpdir do |tmp_dir|
54
+ Dir.chdir(tmp_dir) do
55
+ MRuby.each_target do |target|
56
+ next if name == "host"
57
+
58
+ arch = name
59
+ bin = "#{build_dir}/bin/#{exefile(APP_NAME)}"
60
+ FileUtils.mkdir_p(name)
61
+ FileUtils.cp(bin, name)
62
+
63
+ Dir.chdir(arch) do
64
+ arch_release = "#{app_name}-#{arch}"
65
+ puts "current dir #{Dir.pwd}"
66
+ puts "Writing #{release_path}/#{arch_release}.tgz"
67
+ `tar czf #{release_path}/#{arch_release}.tgz *`
68
+ end
69
+ end
70
+
71
+ puts "Writing #{release_dir}/#{app_name}.tgz"
72
+ `tar czf #{release_path}/#{app_name}.tgz *`
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ namespace :local do
79
+ desc "show version"
80
+ task :version do
81
+ puts "#{APP_NAME} #{APP_VERSION}"
82
+ end
83
+ end
84
+
85
+ def is_in_a_docker_container?
86
+ `test -f /proc/self/cgroup && grep -q docker /proc/self/cgroup`
87
+ $?.success?
88
+ end
89
+
90
+ Rake.application.tasks.each do |task|
91
+ next if ENV["MRUBY_CLI_LOCAL"]
92
+ unless task.name.start_with?("local:") || task.name == 'test'
93
+ # Inspired by rake-hooks
94
+ # https://github.com/guillermo/rake-hooks
95
+ old_task = Rake.application.instance_variable_get('@tasks').delete(task.name)
96
+ desc old_task.full_comment
97
+ task old_task.name => old_task.prerequisites do
98
+ abort("Not running in docker, you should type \"docker-compose run <task>\".") unless is_in_a_docker_container?
99
+ old_task.invoke
100
+ end
101
+ end
102
+ end
103
+
104
+ if is_in_a_docker_container?
105
+ load File.join(File.expand_path(File.dirname(__FILE__)), "mrbgem.rake")
106
+
107
+ current_gem = MRuby::Gem.current
108
+ app_version = MRuby::Gem.current.version
109
+ APP_VERSION = (app_version.nil? || app_version.empty?) ? "unknown" : app_version
110
+
111
+ task default: :compile
112
+ else
113
+ Rake::Task['release'].clear # to clear release tasks to create mruby binary
114
+ require "bundler/gem_tasks"
115
+ require 'rake/testtask'
116
+ # require 'rake/clean'
117
+
118
+ Rake::TestTask.new(:test) do |t|
119
+ # To run test for only one file (or file path pattern)
120
+ # $ bundle exec rake test TEST=test/test_specified_path.rb
121
+ # $ bundle exec rake test TEST=test/test_*.rb
122
+ t.libs << "test"
123
+ t.test_files = Dir["test/**/test_*.rb"].sort
124
+ t.verbose = true
125
+ t.warning = true
126
+ t.ruby_opts = ["-Eascii-8bit:ascii-8bit"]
127
+ end
128
+ task default: [:test, :release]
16
129
  end
17
130
 
18
- task :default => :test
data/build_config.rb ADDED
@@ -0,0 +1,94 @@
1
+ def gem_config(conf)
2
+ #conf.gembox 'default'
3
+
4
+ # be sure to include this gem (the cli app)
5
+ conf.gem File.expand_path(File.dirname(__FILE__))
6
+ end
7
+
8
+ MRuby::Build.new do |conf|
9
+ toolchain :clang
10
+
11
+ conf.enable_bintest
12
+ conf.enable_debug
13
+ conf.enable_test
14
+
15
+ gem_config(conf)
16
+ end
17
+
18
+ MRuby::Build.new('x86_64-pc-linux-gnu') do |conf|
19
+ toolchain :gcc
20
+
21
+ gem_config(conf)
22
+ end
23
+
24
+ MRuby::CrossBuild.new('i686-pc-linux-gnu') do |conf|
25
+ toolchain :gcc
26
+
27
+ [conf.cc, conf.cxx, conf.linker].each do |cc|
28
+ cc.flags << "-m32"
29
+ end
30
+
31
+ gem_config(conf)
32
+ end
33
+
34
+ MRuby::CrossBuild.new('x86_64-apple-darwin14') do |conf|
35
+ toolchain :clang
36
+
37
+ [conf.cc, conf.linker].each do |cc|
38
+ cc.command = 'x86_64-apple-darwin14-clang'
39
+ end
40
+ conf.cxx.command = 'x86_64-apple-darwin14-clang++'
41
+ conf.archiver.command = 'x86_64-apple-darwin14-ar'
42
+
43
+ conf.build_target = 'x86_64-pc-linux-gnu'
44
+ conf.host_target = 'x86_64-apple-darwin14'
45
+
46
+ gem_config(conf)
47
+ end
48
+
49
+ MRuby::CrossBuild.new('i386-apple-darwin14') do |conf|
50
+ toolchain :clang
51
+
52
+ [conf.cc, conf.linker].each do |cc|
53
+ cc.command = 'i386-apple-darwin14-clang'
54
+ end
55
+ conf.cxx.command = 'i386-apple-darwin14-clang++'
56
+ conf.archiver.command = 'i386-apple-darwin14-ar'
57
+
58
+ conf.build_target = 'i386-pc-linux-gnu'
59
+ conf.host_target = 'i386-apple-darwin14'
60
+
61
+ gem_config(conf)
62
+ end
63
+
64
+ MRuby::CrossBuild.new('x86_64-w64-mingw32') do |conf|
65
+ toolchain :gcc
66
+
67
+ [conf.cc, conf.linker].each do |cc|
68
+ cc.command = 'x86_64-w64-mingw32-gcc'
69
+ end
70
+ conf.cxx.command = 'x86_64-w64-mingw32-g++'
71
+ conf.archiver.command = 'x86_64-w64-mingw32-gcc-ar'
72
+ conf.exts.executable = ".exe"
73
+
74
+ conf.build_target = 'x86_64-pc-linux-gnu'
75
+ conf.host_target = 'x86_64-w64-mingw32'
76
+
77
+ gem_config(conf)
78
+ end
79
+
80
+ MRuby::CrossBuild.new('i686-w64-mingw32') do |conf|
81
+ toolchain :gcc
82
+
83
+ [conf.cc, conf.linker].each do |cc|
84
+ cc.command = 'i686-w64-mingw32-gcc'
85
+ end
86
+ conf.cxx.command = 'i686-w64-mingw32-g++'
87
+ conf.archiver.command = 'i686-w64-mingw32-gcc-ar'
88
+ conf.exts.executable = ".exe"
89
+
90
+ conf.build_target = 'i686-pc-linux-gnu'
91
+ conf.host_target = 'i686-w64-mingw32'
92
+
93
+ gem_config(conf)
94
+ end
@@ -0,0 +1,23 @@
1
+ compile: &defaults
2
+ build: .
3
+ volumes:
4
+ - .:/home/mruby/code:rw
5
+ command: rake compile
6
+ test:
7
+ <<: *defaults
8
+ command: rake test
9
+ bintest:
10
+ <<: *defaults
11
+ command: rake test:bintest
12
+ mtest:
13
+ <<: *defaults
14
+ command: rake test:mtest
15
+ clean:
16
+ <<: *defaults
17
+ command: rake clean
18
+ shell:
19
+ <<: *defaults
20
+ command: bash
21
+ release:
22
+ <<: *defaults
23
+ command: rake release
data/exe/msgpack-inspect CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ begin; require 'msgpack'; rescue LoadError; end
3
4
  here = File.dirname(__FILE__)
4
5
  $LOAD_PATH << File.expand_path(File.join(here, '..', 'lib'))
5
6
  require 'msgpack/inspect/command'
@@ -1,13 +1,14 @@
1
1
  require "msgpack/inspect/version"
2
+ require "msgpack/inspect/node"
3
+ require "msgpack/inspect/streamer"
2
4
  require "msgpack/inspect/inspector"
3
5
 
4
6
  module MessagePack
5
7
  module Inspect
6
8
  FORMATS = MessagePack::Inspect::Inspector::FORMATS
7
9
 
8
- # MessagePack::Inspect.inspect(io).dump(format)
9
- def self.inspect(io)
10
- MessagePack::Inspect::Inspector.new(io)
10
+ def self.inspect(io, format)
11
+ MessagePack::Inspect::Inspector.new(io, format).inspect
11
12
  end
12
13
  end
13
14
  end
@@ -1,5 +1,6 @@
1
1
  require 'optparse'
2
2
  require 'msgpack/inspect'
3
+ require 'msgpack/inspect/version'
3
4
 
4
5
  module MessagePack
5
6
  module Inspect
@@ -18,6 +19,10 @@ module MessagePack
18
19
  opts.on("-r", "--require LIB", "ruby file path to require (to load ext type definitions)") do |path|
19
20
  require path
20
21
  end
22
+ opts.on("-v", "--version", "Show version of this software") do
23
+ puts "msgpack-inspect #{MessagePack::Inspect::VERSION}"
24
+ exit
25
+ end
21
26
  opts.on_tail("-h", "--help", "Show this message") do
22
27
  puts opts
23
28
  exit
@@ -36,7 +41,8 @@ module MessagePack
36
41
  exit 1
37
42
  end
38
43
 
39
- puts MessagePack::Inspect.inspect(io).dump(format)
44
+ # puts MessagePack::Inspect.inspect(io).dump(format)
45
+ puts MessagePack::Inspect.inspect(io, format)
40
46
  end
41
47
  end
42
48
  end
@@ -0,0 +1,48 @@
1
+ [
2
+ { "format": "fixarray",
3
+ "header": "ff",
4
+ "length": 3,
5
+ "children": [
6
+ { "format": "string",
7
+ "header": "e0",
8
+ "length": 10,
9
+ "data": "0102030405060708090a",
10
+ "value": "aaaaaaaaaa"
11
+ },
12
+ { "format": "int",
13
+ "header": "10",
14
+ "data": "10",
15
+ "value": 10
16
+ },
17
+ { "format": "nil",
18
+ "header": "a0",
19
+ "data": "a0",
20
+ "value": null
21
+ }
22
+ ]
23
+ },
24
+ { "format": "fixmap",
25
+ "header": "ff",
26
+ "length": 2,
27
+ "children": [
28
+ { "key":
29
+ { "format": "nil",
30
+ "data": "a0"
31
+ },
32
+ "value":
33
+ { "format": "nil",
34
+ "data": "a0"
35
+ }
36
+ },
37
+ { "key":
38
+ { "format": "nil",
39
+ "data": "a0"
40
+ },
41
+ "value":
42
+ { "format": "nil",
43
+ "data": "a0"
44
+ }
45
+ }
46
+ ]
47
+ }
48
+ ]