Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mosop committed Jan 22, 2017
1 parent cf329d8 commit 4b8957d
Show file tree
Hide file tree
Showing 55 changed files with 273 additions and 284 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
language: crystal

script:
- scripts/test
- bin/test

after_success:
- if [ "$TRAVIS_BRANCH" == "master" ]; then bin/deploy_doc; fi
65 changes: 65 additions & 0 deletions bin/deploy_doc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env ruby
require "yaml"
require "tmpdir"

VERSION = /^refs\/tags\/v(\d+(\.\d+)*)$/

Dir.mktmpdir do |dir|
cred_file = File.join(dir, ".git-credentials")
`touch #{cred_file}`
`chmod 600 #{cred_file}`
File.write cred_file, "https://mosop:#{ENV["MOSOP_GITHUB_ACCESS_TOKEN"]}@github.com\n"
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
`git init`
`git config --local credential.helper 'store --file #{cred_file}'`
`git remote add origin https://github.com/mosop/optarg.git`
gh_pages_found = false
versions = []
`git ls-remote`.chomp.split("\n").each do |line|
sha, ref = line.split(/\s+/)
if VERSION =~ ref
versions << Gem::Version.new($1)
elsif ref == "refs/heads/gh-pages"
gh_pages_found = true
end
end
version = versions.sort.last
exit unless version
`git fetch origin v#{version}:tags/v#{version}`
`git checkout -b latest v#{version}`
`crystal deps`
`crystal doc`
doc_dir = File.join(dir, "doc")
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
ver_dir = File.join(dir, "v#{version}")
if gh_pages_found
`git init`
`git config --local credential.helper 'store --file #{cred_file}'`
`git remote add origin https://github.com/mosop/optarg.git`
`git pull origin gh-pages`
`git checkout -b gh-pages origin/gh-pages`
Dir.glob("*") do |f|
`rm -rf #{f}` unless f.start_with?("v")
end
`rm -rf .git`
end
`cp -a #{doc_dir}/* #{dir}/`
`rm -rf #{ver_dir}`
`mkdir -p #{ver_dir}`
`cp -a #{doc_dir}/* #{ver_dir}/`
`git init`
`git config --local credential.helper 'store --file #{cred_file}'`
`git remote add origin https://github.com/mosop/optarg.git`
`git config --add --local user.name mosop`
`git config --add --local user.email mosop@users.noreply.github.com`
`git checkout -b gh-pages`
`git add .`
`git commit -m '#{Time.now.strftime("%Y%m%d")}'`
`git push -f origin gh-pages`
end
end
end
end
end
File renamed without changes.
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: optarg
version: 0.5.0
version: 0.5.1

authors:
- mosop
Expand All @@ -11,4 +11,4 @@ crystal: 0.20.5
dependencies:
callback:
github: mosop/callback
version: ~> 0.6.0
version: ~> 0.6.1
2 changes: 1 addition & 1 deletion spec/classes/argument_value_container_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module OptargArgumentValueContainerClassFeature

it "#[]" do
model = Model.new(%w())
model.parser.parsed_args << "arg"
model.__parser.parsed_args << "arg"
model[0].should eq "arg"
end

Expand Down
1 change: 0 additions & 1 deletion spec/features/argument_array_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ module OptargArgumentArrayFeature
result = Model.parse(%w(foo bar baz))
result.arg.should eq "foo"
result.item.should eq ["bar", "baz"]
result.parsed_args.should eq %w(foo bar baz)
end
end
15 changes: 0 additions & 15 deletions spec/features/detail/argument_value_container_spec.cr

This file was deleted.

13 changes: 0 additions & 13 deletions spec/features/detail/avoiding_overriding_methods_spec.cr

This file was deleted.

15 changes: 0 additions & 15 deletions spec/features/detail/bool_option_value_accessor_spec.cr

This file was deleted.

14 changes: 0 additions & 14 deletions spec/features/detail/named_argument_value_accessor_spec.cr

This file was deleted.

13 changes: 0 additions & 13 deletions spec/features/detail/named_argument_value_hash_spec.cr

This file was deleted.

13 changes: 0 additions & 13 deletions spec/features/detail/nameless_argument_value_hash_spec.cr

This file was deleted.

31 changes: 0 additions & 31 deletions spec/features/detail/option_value_container_spec.cr

This file was deleted.

13 changes: 0 additions & 13 deletions spec/features/detail/parsed_argument_value_array_spec.cr

This file was deleted.

12 changes: 0 additions & 12 deletions spec/features/detail/string_array_option_value_accessor_spec.cr

This file was deleted.

16 changes: 0 additions & 16 deletions spec/features/detail/string_option_value_accessor_spec.cr

This file was deleted.

13 changes: 0 additions & 13 deletions spec/features/detail/unparsed_argument_value_array_spec.cr

This file was deleted.

1 change: 0 additions & 1 deletion spec/features/named_arguments_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module OptargNamedArgumentsFeature
result = Model.parse(%w(/path/to/src /path/to/build and more))
result.src_dir.should eq "/path/to/src"
result.build_dir.should eq "/path/to/build"
result.parsed_args.should eq ["/path/to/src", "/path/to/build", "and", "more"]
result[String].should eq({"src_dir" => "/path/to/src", "build_dir" => "/path/to/build"})
result.nameless_args.should eq ["and", "more"]
end
Expand Down
50 changes: 25 additions & 25 deletions spec/fix/inherit_definition_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,31 @@ module OptargFixInheritDefinitionFeature
end

it name do
Sub.definitions.all.size.should eq 5
Sub.definitions.arguments.size.should eq 1
Sub.definitions.options.size.should eq 3
Sub.definitions.value_options.size.should eq 2
Sub.definitions.values.size.should eq 3
Sub.definitions.handlers.size.should eq 1
Sub.definitions.terminators.size.should eq 1
Sub.definitions.argument_list.size.should eq 1
Sub.__klass.definitions.all.size.should eq 5
Sub.__klass.definitions.arguments.size.should eq 1
Sub.__klass.definitions.options.size.should eq 3
Sub.__klass.definitions.value_options.size.should eq 2
Sub.__klass.definitions.values.size.should eq 3
Sub.__klass.definitions.handlers.size.should eq 1
Sub.__klass.definitions.terminators.size.should eq 1
Sub.__klass.definitions.argument_list.size.should eq 1

Sub.definitions.all["arg"]?.should_not be_nil
Sub.definitions.all["-s"]?.should_not be_nil
Sub.definitions.all["-b"]?.should_not be_nil
Sub.definitions.all["-h"]?.should_not be_nil
Sub.definitions.all["--"]?.should_not be_nil
Sub.definitions.arguments["arg"]?.should_not be_nil
Sub.definitions.options["-s"]?.should_not be_nil
Sub.definitions.options["-b"]?.should_not be_nil
Sub.definitions.options["-h"]?.should_not be_nil
Sub.definitions.value_options["-s"]?.should_not be_nil
Sub.definitions.value_options["-b"]?.should_not be_nil
Sub.definitions.values["arg"]?.should_not be_nil
Sub.definitions.values["-s"]?.should_not be_nil
Sub.definitions.values["-b"]?.should_not be_nil
Sub.definitions.handlers["-h"]?.should_not be_nil
Sub.definitions.terminators["--"]?.should_not be_nil
Sub.definitions.argument_list[0]?.should_not be_nil
Sub.__klass.definitions.all["arg"]?.should_not be_nil
Sub.__klass.definitions.all["-s"]?.should_not be_nil
Sub.__klass.definitions.all["-b"]?.should_not be_nil
Sub.__klass.definitions.all["-h"]?.should_not be_nil
Sub.__klass.definitions.all["--"]?.should_not be_nil
Sub.__klass.definitions.arguments["arg"]?.should_not be_nil
Sub.__klass.definitions.options["-s"]?.should_not be_nil
Sub.__klass.definitions.options["-b"]?.should_not be_nil
Sub.__klass.definitions.options["-h"]?.should_not be_nil
Sub.__klass.definitions.value_options["-s"]?.should_not be_nil
Sub.__klass.definitions.value_options["-b"]?.should_not be_nil
Sub.__klass.definitions.values["arg"]?.should_not be_nil
Sub.__klass.definitions.values["-s"]?.should_not be_nil
Sub.__klass.definitions.values["-b"]?.should_not be_nil
Sub.__klass.definitions.handlers["-h"]?.should_not be_nil
Sub.__klass.definitions.terminators["--"]?.should_not be_nil
Sub.__klass.definitions.argument_list[0]?.should_not be_nil
end
end
6 changes: 3 additions & 3 deletions spec/internal/argument_display_name_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module OptargInternalArugmentDisplayNameFeature
end

it name do
Model.definitions.arguments["arg"].metadata.display_name.should eq "arg"
Upcase.definitions.arguments["arg"].metadata.display_name.should eq "ARG"
Upcase.definitions.options["--option"].metadata.display_name.should eq "--option"
Model.__klass.definitions.arguments["arg"].metadata.display_name.should eq "arg"
Upcase.__klass.definitions.arguments["arg"].metadata.display_name.should eq "ARG"
Upcase.__klass.definitions.options["--option"].metadata.display_name.should eq "--option"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module OptargInternalRaiseUnknownOptionIfConcatenatedOptionsNotMatchedFeature

it name do
model = Model.new(%w(-ab))
expect_raises(Optarg::UnknownOption, Optarg::UnknownOption.new(model.__parser, "-a").message) { model.parse }
expect_raises(Optarg::UnknownOption, Optarg::UnknownOption.new(model.__parser, "-a").message) { model.__parse }
end
end
2 changes: 1 addition & 1 deletion spec/internal/raise_unsupported_concatenation_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module OptargInternalRaiseUnsupportedConcatenationFeature

it name do
model = Model.new(%w(-sa))
expect_raises(Optarg::UnsupportedConcatenation, Optarg::UnsupportedConcatenation.new(model.__parser, Model.definitions.options["-s"]).message) { model.__parse}
expect_raises(Optarg::UnsupportedConcatenation, Optarg::UnsupportedConcatenation.new(model.__parser, Model.__klass.definitions.options["-s"]).message) { model.__parse}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ module OptargInternalRequiredArgumentErrorPreservesObjectFeature
error = ex
ensure
end
error.as(Optarg::Definitions::StringArgument::Validations::Existence::Error).definition.should be Model.definitions.arguments["arg1"]
error.as(Optarg::Definitions::StringArgument::Validations::Existence::Error).definition.should be Model.__klass.definitions.arguments["arg1"]
end
end
Loading

0 comments on commit 4b8957d

Please sign in to comment.