Skip to content

Commit

Permalink
Add DPPM config spec
Browse files Browse the repository at this point in the history
  • Loading branch information
j8r committed Dec 27, 2019
1 parent 5ddfe12 commit 813a0d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions spec/cli_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ describe DPPM::CLI do
it "installs DPPM" do
spec_with_tempdir do |prefix|
install_dppm prefix
dppm_prefix = DPPM::Prefix.new prefix
dppm_prefix.dppm.config_file?.should_not be_nil
dppm_prefix.dppm_config
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/prefix_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "./prefix_helper"
require "../src/prefix"

describe DPPM::Prefix do
it "downloads packages source with cli using config file mirror" do
it "downloads packages source using config file mirror" do
spec_with_prefix do |prefix|
prefix.update
children = Dir.new(prefix.path.to_s).children
Expand Down
14 changes: 8 additions & 6 deletions src/prefix/config.cr
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
struct DPPM::Prefix::Config
getter sources : Hash(String, String) { data["sources"].as_h.transform_values &.as_s }
getter host : String { data["host"].as_s }
getter port : Int32 { data["port"].as_i }
getter data : CON::Any
getter sources : Hash(String, String)
getter host : String
getter port : Int32

def initialize(content : String)
@data = CON.parse content
def initialize(data : String | IO)
data = CON.parse data
@port = data["port"].as_i
@host = data["host"].as_s
@sources = data["sources"].as_h.transform_values &.as_s
end
end

0 comments on commit 813a0d8

Please sign in to comment.