Skip to content

Commit dfdda54

Browse files
committed
Initial commit. #RN
0 parents  commit dfdda54

10 files changed

+212
-0
lines changed

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: ruby
2+
rvm:
3+
- 2.2
4+
before_install:
5+
- ruby --version
6+
script:
7+
- make test

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
source 'https://rubygems.org'
3+
gemspec

Gemfile.lock

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
PATH
2+
remote: .
3+
specs:
4+
mpcat (0.1.0)
5+
msgpack (~> 0.7)
6+
7+
GEM
8+
remote: https://rubygems.org/
9+
specs:
10+
msgpack (0.7.1)
11+
12+
PLATFORMS
13+
ruby
14+
15+
DEPENDENCIES
16+
bundler (~> 1.10)
17+
mpcat!
18+
19+
BUNDLED WITH
20+
1.10.2

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
GEM_NAME = mpcat
3+
4+
include Makefile.common
5+
6+
.PHONY: test
7+
test:
8+
RUBYOPT=-w ./bin/mpcat tests/test1.mp

Makefile.common

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
# Ruby Common Big
3+
# 2015-12-15
4+
5+
MV = mv -nv
6+
RM = rm -rf
7+
MKDIR = mkdir -p
8+
BUNDLER = bundle
9+
BUNDLER_OPTIONS = --jobs=5 --retry=3
10+
GEMSPEC_FILE = $(GEM_NAME).gemspec
11+
12+
.PHONY: all $(ALL_TARGETS_EXT)
13+
all: setup
14+
15+
.PHONY: setup
16+
setup: .setup
17+
18+
.setup:
19+
$(BUNDLER) install $(BUNDLER_OPTIONS)
20+
touch $@
21+
22+
.PHONY: install
23+
install:
24+
gem_file=$$(gem build $(GEMSPEC_FILE) | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
25+
sudo gem install $$gem_file; \
26+
$(RM) $$gem_file
27+
28+
.PHONY: uninstall
29+
uninstall:
30+
sudo gem uninstall $(GEM_NAME)
31+
32+
.PHONY: update
33+
update:
34+
$(BUNDLER) update
35+
36+
.PHONY: clean
37+
clean:
38+
$(RM) .setup
39+
40+
.PHONY: release
41+
release: | releases
42+
set -e; \
43+
gem_file=$$(gem build $(GEMSPEC_FILE) | grep 'File:' | tail -1 | awk '{ print $$2 }'); \
44+
dst="releases/$$gem_file"; \
45+
[ ! -f $$dst ]; \
46+
$(MV) $$gem_file releases; \
47+
gem push $$dst; \
48+
echo 'done'
49+
50+
releases:
51+
$(MKDIR) $@

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# MessagePack Cat
2+
3+
Convert [MessagePack](http://msgpack.org/)-files to [YAML](http://yaml.org/).
4+
5+
This tool is actually a side product of [One Shall Pass](https://github.com/TheFox/osp).
6+
7+
## Install
8+
9+
The preferred method of installation is via RubyGems.org:
10+
https://rubygems.org/gems/mpcat
11+
12+
gem install mpcat
13+
14+
or via Gemfile:
15+
16+
gem 'mpcat', '~>0.1'
17+
18+
## Project Links
19+
20+
- [Gem](https://rubygems.org/gems/mpcat)
21+
- [Travis CI Repository](https://travis-ci.org/TheFox/mpcat)
22+
23+
## Weblinks
24+
25+
- [MessagePack](http://msgpack.org/)
26+
- [YAML](http://yaml.org/)
27+
28+
## License
29+
Copyright (C) 2015 Christian Mayer <http://fox21.at>
30+
31+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
32+
33+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

bin/mpcat

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env ruby
2+
# coding: UTF-8
3+
4+
raise 'Ruby >=2.2 required' unless RUBY_VERSION >= '2.2.0'
5+
6+
require 'optparse'
7+
require 'yaml'
8+
require 'pp'
9+
10+
require 'bundler/setup'
11+
require 'msgpack'
12+
13+
14+
options = {
15+
:path => nil,
16+
:yaml => true,
17+
}
18+
opts = OptionParser.new do |o|
19+
o.banner = 'Usage: mpcat [--no-yaml] <files...>'
20+
o.separator('')
21+
22+
# o.on('-p', '--path <path>', 'Path msgpack file.') do |path|
23+
# options[:path] = path
24+
# end
25+
26+
o.on('--no-yaml', 'Do not use YAML as output format.') do
27+
options[:yaml] = false
28+
end
29+
30+
o.on_tail('-h', '--help', 'Show this message.') do
31+
puts o
32+
puts
33+
exit 3
34+
end
35+
end
36+
#ARGV << '-h' if ARGV.count == 0
37+
args = opts.parse(ARGV)
38+
39+
if args.count > 0
40+
options[:path] = args.shift
41+
42+
if !options[:path].nil?
43+
ar = MessagePack.unpack(File.binread(options[:path]))
44+
45+
if options[:yaml]
46+
print YAML.dump(ar)
47+
else
48+
pp ar
49+
end
50+
else
51+
raise 'FATAL ERROR: path invalid.'
52+
end
53+
else
54+
opts.parse(['-h'])
55+
end
56+

mpcat.gemspec

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# coding: UTF-8
2+
3+
Gem::Specification.new do |spec|
4+
spec.name = 'mpcat'
5+
spec.version = '0.1.0'
6+
spec.date = '2015-12-18'
7+
spec.author = 'Christian Mayer'
8+
spec.email = '[email protected]'
9+
10+
spec.summary = %q{MessagePack Cat}
11+
spec.description = %q{Pretty print for MessagePack files.}
12+
spec.homepage = 'https://github.com/TheFox/mpcat'
13+
spec.license = 'GPL-3.0'
14+
15+
spec.files = `git ls-files -z`.split("\x0").reject{ |f| f.match(%r{^(test|spec|features)/}) }
16+
spec.bindir = 'bin'
17+
spec.executables = ['mpcat']
18+
spec.required_ruby_version = '>=2.2.0'
19+
20+
spec.add_development_dependency 'bundler', '~>1.10'
21+
22+
spec.add_dependency 'msgpack', '~>0.7'
23+
end

mpcat.sublime-project

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"folders":[
3+
{
4+
"path": ".",
5+
"name": "mpcat",
6+
"folder_exclude_patterns": [ ],
7+
"file_exclude_patterns": [ ]
8+
}
9+
]
10+
}

tests/test1.mp

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��h1��a�b�c�*

0 commit comments

Comments
 (0)