Skip to content

Commit

Permalink
Merge pull request #13 from alpaca-tc/remove-msgpack
Browse files Browse the repository at this point in the history
Remove support msgpack
  • Loading branch information
alpaca-tc authored Apr 15, 2024
2 parents 20f0584 + 02759e6 commit 314505d
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 90 deletions.
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ PATH
specs:
diver_down (0.0.1.alpha1)
activesupport (>= 7.0.0)
msgpack (>= 1.7.0)
rack-contrib (>= 2.3.0)

GEM
Expand Down Expand Up @@ -32,7 +31,6 @@ GEM
json (2.7.2)
language_server-protocol (3.17.0.3)
minitest (5.22.3)
msgpack (1.7.2)
mutex_m (0.2.0)
nio4r (2.7.1)
parallel (1.24.0)
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ end
```

The analysis results should be output to a specific directory.
Files saved in `.msgpack`, `.json`, or `.yaml` can be read by `DiverDown::Web`.
Files saved in `.json` or `.yaml` can be read by `DiverDown::Web`.

```ruby
dir = 'tmp/diver_down'
Expand All @@ -67,7 +67,6 @@ definition = tracer.trace do
# do something
end

File.binwrite(File.join(dir, "#{definition.title}.msgpack"), definition.to_msgpack)
File.write(File.join(dir, "#{definition.title}.json"), definition.to_h.to_json)
File.write(File.join(dir, "#{definition.title}.yaml"), definition.to_h.to_yaml)
```
Expand Down
1 change: 0 additions & 1 deletion diver_down.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_dependency 'activesupport', '>= 7.0.0'
spec.add_dependency 'msgpack', '>= 1.7.0'
spec.add_dependency 'rack-contrib', '>= 2.3.0'
end
1 change: 0 additions & 1 deletion lib/diver_down.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'msgpack'
require_relative 'diver_down/version'

module DiverDown
Expand Down
5 changes: 0 additions & 5 deletions lib/diver_down/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ def to_h
}
end

# @return [String]
def to_msgpack
MessagePack.pack(to_h)
end

# @param other [Object, DiverDown::Definition::Source]
# @return [Boolean]
def ==(other)
Expand Down
6 changes: 0 additions & 6 deletions lib/diver_down/web/definition_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ def load_file(path)
hash = case File.extname(path)
when '.yaml', '.yml'
from_yaml(path)
when '.msgpack'
from_msgpack(path)
when '.json'
from_json(path)
else
Expand All @@ -28,10 +26,6 @@ def from_json(path)
def from_yaml(path)
YAML.load_file(path)
end

def from_msgpack(path)
MessagePack.unpack(File.binread(path))
end
end
end
end
60 changes: 0 additions & 60 deletions spec/diver_down/definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,66 +159,6 @@
end
end

describe '#to_msgpack' do
it 'converts definition to message-pack' do
definition = described_class.new(
title: 'title',
sources: [
DiverDown::Definition::Source.new(
source_name: 'a.rb',
dependencies: [
DiverDown::Definition::Dependency.new(
source_name: 'b.rb',
method_ids: [
DiverDown::Definition::MethodId.new(
name: 'A',
context: 'class',
paths: ['a.rb']
),
]
),
DiverDown::Definition::Dependency.new(
source_name: 'c.rb'
),
]
),
]
)

expect(definition.to_msgpack).to eq(MessagePack.pack(definition.to_h))
end

it 'can be loaded' do
definition = described_class.new(
title: 'title',
sources: [
DiverDown::Definition::Source.new(
source_name: 'a.rb',
dependencies: [
DiverDown::Definition::Dependency.new(
source_name: 'b.rb',
method_ids: [
DiverDown::Definition::MethodId.new(
name: 'A',
context: 'class',
paths: ['a.rb']
),
]
),
DiverDown::Definition::Dependency.new(
source_name: 'c.rb'
),
]
),
]
)

msgpack = definition.to_msgpack
hash = DiverDown::Helper.deep_symbolize_keys(MessagePack.unpack(msgpack))
expect(described_class.from_hash(hash)).to eq(definition)
end
end

describe '#hash' do
it 'returns a hash' do
definition = described_class.new(
Expand Down
12 changes: 0 additions & 12 deletions spec/diver_down/web/definition_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,6 @@

expect(loader.load_file(path)).to eq(definition)
end

it 'loads msgpack' do
dir = Dir.mktmpdir
path = File.join(dir, 'a.msgpack')

definition = DiverDown::Definition.new(title: 'a')
File.write(path, definition.to_h.to_msgpack)

loader = DiverDown::Web::DefinitionLoader.new

expect(loader.load_file(path)).to eq(definition)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/diver_down/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def assert_source(source, expected_ids)
),
]
)
File.binwrite(File.join(definition_dir, '1.msgpack'), definition.to_h.to_msgpack)
File.write(File.join(definition_dir, '1.yaml'), definition.to_h.to_yaml)

get '/api/initialization_status.json'

Expand Down

0 comments on commit 314505d

Please sign in to comment.