git-contest 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +21 -3
  3. data/README.md +5 -0
  4. data/Rakefile +8 -0
  5. data/appveyor.yml +21 -0
  6. data/bin/git-contest +4 -33
  7. data/bin/git-contest-config +4 -241
  8. data/bin/git-contest-finish +4 -151
  9. data/bin/git-contest-init +4 -65
  10. data/bin/git-contest-list +4 -64
  11. data/bin/git-contest-rebase +4 -64
  12. data/bin/git-contest-start +4 -57
  13. data/bin/git-contest-submit +4 -183
  14. data/git-contest.gemspec +2 -1
  15. data/lib/contest/driver/base.rb +7 -4
  16. data/lib/git/contest/command_line.rb +10 -0
  17. data/lib/git/contest/command_line/command.rb +117 -0
  18. data/lib/git/contest/command_line/main_command.rb +56 -0
  19. data/lib/git/contest/command_line/sub_commands.rb +35 -0
  20. data/lib/git/contest/command_line/sub_commands/config_command.rb +258 -0
  21. data/lib/git/contest/command_line/sub_commands/finish_command.rb +161 -0
  22. data/lib/git/contest/command_line/sub_commands/init_command.rb +79 -0
  23. data/lib/git/contest/command_line/sub_commands/list_command.rb +89 -0
  24. data/lib/git/contest/command_line/sub_commands/rebase_command.rb +87 -0
  25. data/lib/git/contest/command_line/sub_commands/start_command.rb +77 -0
  26. data/lib/git/contest/command_line/sub_commands/submit_command.rb +220 -0
  27. data/lib/git/contest/common.rb +6 -6
  28. data/lib/git/contest/git.rb +160 -156
  29. data/lib/git/contest/version.rb +1 -1
  30. data/spec/command/t004_git_contest_submit_spec.rb +254 -0
  31. data/spec/command/t005_git_contest_branching_spec.rb +90 -0
  32. data/spec/command/t007_git_contest_start_spec.rb +95 -0
  33. data/spec/command/t008_git_contest_finish_spec.rb +171 -0
  34. data/spec/command/t009_git_contest_init_spec.rb +85 -0
  35. data/spec/command/t012_git_contest_list_spec.rb +123 -0
  36. data/spec/command/t013_git_contest_config_spec.rb +186 -0
  37. data/spec/{lib/contest/driver → contest_driver}/t001_aizu_online_judge_spec.rb +1 -1
  38. data/spec/{lib/contest/driver → contest_driver}/t002_codeforces_spec.rb +1 -1
  39. data/spec/{lib/contest/driver → contest_driver}/t003_uva_online_judge_spec.rb +1 -1
  40. data/spec/{lib/contest/driver → contest_driver}/t010_kattis_spec.rb +1 -1
  41. data/spec/{lib/contest/driver → contest_driver}/t011_utils_spec.rb +0 -0
  42. data/spec/spec_helper.rb +18 -12
  43. data/spec/t006_config_spec.rb +37 -31
  44. metadata +57 -33
  45. data/spec/bin/t004_git_contest_submit_spec.rb +0 -223
  46. data/spec/bin/t005_git_contest_branching_spec.rb +0 -70
  47. data/spec/bin/t007_git_contest_start_spec.rb +0 -88
  48. data/spec/bin/t008_git_contest_finish_spec.rb +0 -162
  49. data/spec/bin/t009_git_contest_init_spec.rb +0 -55
  50. data/spec/bin/t012_git_contest_list_spec.rb +0 -99
  51. data/spec/bin/t013_git_contest_config_spec.rb +0 -149
  52. data/spec/spec_list.txt +0 -1
@@ -1,55 +0,0 @@
1
- require "spec_helper"
2
-
3
- # Don't forget --defaults option
4
-
5
- describe "T009: git-contest-init" do
6
- context "A001: --force" do
7
- it "001: init -> init" do
8
- ret1 = bin_exec "init --defaults"
9
- ret_config1 = git_do("config --get git.contest.branch.master")
10
- ret2 = bin_exec "init --defaults"
11
- ret_config1.should === "master"
12
- expect(ret1).not_to include "Error: unknown argument"
13
- expect(ret2).not_to include "Error: unknown argument"
14
- expect(ret1).not_to include "Already initialized for git-contest."
15
- expect(ret1).not_to include "use: git contest init -f"
16
- expect(ret2).to include "Already initialized for git-contest."
17
- expect(ret2).to include "use: git contest init -f"
18
- end
19
-
20
- it "002: init -> init -f -> init --force" do
21
- ret1 = bin_exec "init --defaults"
22
- ret_config1 = git_do("config --get git.contest.branch.master")
23
- ret2 = bin_exec "init --defaults -f"
24
- ret3 = bin_exec "init --defaults --force"
25
- ret_config1.should === "master"
26
- expect(ret1).not_to include "Error: unknown argument"
27
- expect(ret2).not_to include "Error: unknown argument"
28
- expect(ret3).not_to include "Error: unknown argument"
29
- expect(ret1).not_to include "Already initialized for git-contest."
30
- expect(ret1).not_to include "use: git contest init -f"
31
- expect(ret2).not_to include "Already initialized for git-contest."
32
- expect(ret2).not_to include "use: git contest init -f"
33
- expect(ret3).not_to include "Already initialized for git-contest."
34
- expect(ret3).not_to include "use: git contest init -f"
35
- end
36
-
37
- it "003: init -f -> init -f -> init --force" do
38
- ret1 = bin_exec "init --defaults -f"
39
- ret_config1 = git_do("config --get git.contest.branch.master")
40
- ret2 = bin_exec "init --defaults -f"
41
- ret3 = bin_exec "init --defaults --force"
42
- ret_config1.should === "master"
43
- expect(ret1).not_to include "Error: unknown argument"
44
- expect(ret2).not_to include "Error: unknown argument"
45
- expect(ret3).not_to include "Error: unknown argument"
46
- expect(ret1).not_to include "Already initialized for git-contest."
47
- expect(ret1).not_to include "use: git contest init -f"
48
- expect(ret2).not_to include "Already initialized for git-contest."
49
- expect(ret2).not_to include "use: git contest init -f"
50
- expect(ret3).not_to include "Already initialized for git-contest."
51
- expect(ret3).not_to include "use: git contest init -f"
52
- end
53
- end
54
- end
55
-
@@ -1,99 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "T012: git-contest-list" do
4
- before do
5
- ENV['GIT_CONTEST_CONFIG'] = "#{@temp_dir}/config.yml"
6
- ENV['GIT_CONTEST_HOME'] = @temp_dir
7
- end
8
-
9
- context "git-contest-list sites" do
10
- before do
11
- # create config
12
- File.open "#{@temp_dir}/config.yml", 'w' do |file|
13
- file.write <<EOF
14
- sites:
15
- test_site1:
16
- driver: test_driver1
17
- user: test_user1
18
- password: test_password1
19
- test_site2:
20
- driver: test_driver2
21
- user: test_user2
22
- password: test_password2
23
- test_site3:
24
- driver: test_driver3
25
- user: test_user3
26
- password: test_password3
27
- EOF
28
- end
29
- end
30
-
31
- it "should include site name" do
32
- ret = bin_exec "list sites"
33
- (1..3).each {|x| expect(ret).to include "test_site#{x}" }
34
- end
35
-
36
- it "should include user name" do
37
- ret = bin_exec "list sites"
38
- (1..3).each {|x| expect(ret).to include "test_user#{x}" }
39
- end
40
-
41
- it "should include driver name" do
42
- ret = bin_exec "list sites"
43
- (1..3).each {|x| expect(ret).to include "test_driver#{x}" }
44
- end
45
-
46
- it "should NOT include password" do
47
- ret = bin_exec "list sites"
48
- (1..3).each {|x| expect(ret).not_to include "test_password#{x}" }
49
- end
50
- end
51
-
52
- context "git-contest-list drivers" do
53
- before do
54
- # prepare drivers
55
- FileUtils.mkdir "#{@temp_dir}/plugins"
56
- File.open "#{@temp_dir}/plugins/test01_driver.rb", "w" do |f|
57
- f.write <<EOF
58
- module Contest
59
- module Driver
60
- class Test01Driver < DriverBase
61
- def get_site_name
62
- "test01_site_name"
63
- end
64
- def get_desc
65
- "test01_desc"
66
- end
67
- end
68
- end
69
- end
70
- EOF
71
- end
72
- File.open "#{@temp_dir}/plugins/test02_driver.rb", "w" do |f|
73
- f.write <<EOF
74
- module Contest
75
- module Driver
76
- class Test02Driver < DriverBase
77
- def get_site_name
78
- "test02_site_name"
79
- end
80
- def get_desc
81
- "test02_desc"
82
- end
83
- end
84
- end
85
- end
86
- EOF
87
- end
88
- end
89
-
90
- it "contains plugins" do
91
- ret = bin_exec "list drivers"
92
- expect(ret).to include "Test01Driver"
93
- expect(ret).to include "test01_desc"
94
- expect(ret).to include "Test02Driver"
95
- expect(ret).to include "test02_desc"
96
- end
97
- end
98
-
99
- end
@@ -1,149 +0,0 @@
1
- require 'spec_helper'
2
- require 'yaml'
3
-
4
- describe "T013: git-contest-config" do
5
- before do
6
- ENV['GIT_CONTEST_CONFIG'] = "#{@temp_dir}/config.yml"
7
- end
8
-
9
- context "git contest config set" do
10
- before(:each) do
11
- # create config file
12
- File.open "#{@temp_dir}/config.yml", 'w' do |file|
13
- file.write <<EOF
14
- key1: value1
15
- sites:
16
- test_site1:
17
- driver: test_driver1
18
- user: test_user1
19
- password: test_password1
20
- EOF
21
- end
22
- end
23
-
24
- it "git contest config set key value" do
25
- bin_exec "config set key1 value2"
26
- ret2 = YAML.load_file "#{@temp_dir}/config.yml"
27
- expect(ret2["key1"]).to eq "value2"
28
- end
29
-
30
- it "git contest config set key (input from pipe)" do
31
- bin_exec "config set key1", "value2"
32
- ret2 = YAML.load_file "#{@temp_dir}/config.yml"
33
- expect(ret2["key1"]).to eq "value2"
34
- end
35
-
36
- it "git contest config set sites.test_site1.driver test_driver2" do
37
- bin_exec "config set sites.test_site1.driver test_driver2"
38
- ret1 = YAML.load_file "#{@temp_dir}/config.yml"
39
- expect(ret1["sites"]["test_site1"]["driver"]).to eq "test_driver2"
40
- end
41
- end
42
-
43
- context "git contest config get" do
44
- before(:each) do
45
- # create config file
46
- File.open "#{@temp_dir}/config.yml", 'w' do |file|
47
- file.write <<EOF
48
- key1: value1
49
- sites:
50
- test_site1:
51
- driver: test_driver1
52
- user: test_user1
53
- password: test_password1
54
- EOF
55
- end
56
- end
57
-
58
- it "git contest config get key1" do
59
- ret = bin_exec "config get key1"
60
- expect(ret.strip).to eq "value1"
61
- end
62
-
63
- it "git contest config get sites.test_site1.user" do
64
- ret = bin_exec "config get sites.test_site1.user"
65
- expect(ret.strip).to eq "test_user1"
66
- end
67
-
68
- it "return keys" do
69
- ret = bin_exec "config get sites.test_site1"
70
- expect(ret).to include "driver"
71
- expect(ret).to include "user"
72
- expect(ret).to include "password"
73
- expect(ret).not_to include "test_driver1"
74
- expect(ret).not_to include "test_user1"
75
- expect(ret).not_to include "test_password1"
76
- end
77
-
78
- it "raise error: not found" do
79
- ret = bin_exec("config get foo.bar")
80
- expect(ret).to include "ERROR"
81
- end
82
- end
83
-
84
- context "git contest config site add" do
85
- before(:each) do
86
- # create config
87
- File.open "#{@temp_dir}/config.yml", "w" do |file|
88
- file.write <<EOF
89
- sites:
90
- test_site1:
91
- driver: test_driver1
92
- user: test_user1
93
- password: test_password1
94
- EOF
95
- end
96
- end
97
-
98
- it "add site" do
99
- bin_exec "config site add test_site2", "test_driver2\ntest_user2\ntest_password2"
100
- ret1 = YAML.load_file "#{@temp_dir}/config.yml"
101
- expect(ret1["sites"]["test_site1"]["driver"]).to eq "test_driver1"
102
- expect(ret1["sites"]["test_site1"]["user"]).to eq "test_user1"
103
- expect(ret1["sites"]["test_site1"]["password"]).to eq "test_password1"
104
- expect(ret1["sites"]["test_site2"]["driver"]).to eq "test_driver2"
105
- expect(ret1["sites"]["test_site2"]["user"]).to eq "test_user2"
106
- expect(ret1["sites"]["test_site2"]["password"]).to eq "test_password2"
107
- end
108
- end
109
-
110
- context "git contest config site rm" do
111
- before(:each) do
112
- # create config
113
- File.open "#{@temp_dir}/config.yml", "w" do |file|
114
- file.write <<EOF
115
- sites:
116
- test_site1:
117
- driver: test_driver1
118
- user: test_user1
119
- password: test_password1
120
- test_site2:
121
- driver: test_driver2
122
- user: test_user2
123
- password: test_password2
124
- EOF
125
- end
126
- end
127
-
128
- it "remove site: input yes" do
129
- bin_exec "config site rm test_site1", "yes"
130
- ret1 = YAML.load_file "#{@temp_dir}/config.yml"
131
- expect(ret1["sites"]["test_site1"]).to be_nil
132
- expect(ret1["sites"]["test_site2"]["driver"]).to eq "test_driver2"
133
- expect(ret1["sites"]["test_site2"]["user"]).to eq "test_user2"
134
- expect(ret1["sites"]["test_site2"]["password"]).to eq "test_password2"
135
- end
136
-
137
- it "remove site: input no" do
138
- bin_exec "config site rm test_site1", "no"
139
- ret1 = YAML.load_file "#{@temp_dir}/config.yml"
140
- expect(ret1["sites"]["test_site1"]["driver"]).to eq "test_driver1"
141
- expect(ret1["sites"]["test_site1"]["user"]).to eq "test_user1"
142
- expect(ret1["sites"]["test_site1"]["password"]).to eq "test_password1"
143
- expect(ret1["sites"]["test_site2"]["driver"]).to eq "test_driver2"
144
- expect(ret1["sites"]["test_site2"]["user"]).to eq "test_user2"
145
- expect(ret1["sites"]["test_site2"]["password"]).to eq "test_password2"
146
- end
147
- end
148
-
149
- end
data/spec/spec_list.txt DELETED
@@ -1 +0,0 @@
1
- T001: Git::Contest::Driver::AizuOnlineJudge