fixman 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/History.txt +6 -0
- data/Manifest.txt +23 -0
- data/README.md +176 -0
- data/Rakefile +19 -0
- data/bin/fixman +50 -0
- data/lib/fixman.rb +13 -0
- data/lib/fixman/command_line.rb +184 -0
- data/lib/fixman/configuration.rb +161 -0
- data/lib/fixman/controller.rb +121 -0
- data/lib/fixman/raw_task.rb +103 -0
- data/lib/fixman/repository.rb +99 -0
- data/lib/fixman/task.rb +19 -0
- data/lib/fixman/task_parse_error.rb +12 -0
- data/lib/fixman/tester.rb +69 -0
- data/lib/fixman/utilities.rb +8 -0
- data/test/test_command_line.rb +250 -0
- data/test/test_configuration.rb +58 -0
- data/test/test_controller.rb +16 -0
- data/test/test_fixman.rb +7 -0
- data/test/test_raw_task.rb +97 -0
- data/test/test_repository.rb +21 -0
- data/test/test_task.rb +28 -0
- data/test/test_tester.rb +89 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dff2cf3e7e6c5dc503e797509e4cca24b94090cc
|
4
|
+
data.tar.gz: 9a497dbd95d32ca095de23fbddff918de7e680d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82f54fc14ae20ccbfd6effd0d4edb15db717f4cc246291f3ee1bbb0aa0d2a66da387cbf412000825bedbed23f64e5763c05856d0c15fa244f08eb6c5bfd3fafe
|
7
|
+
data.tar.gz: a4883f1d8f7bb1e4d1d1c2246b86b930e78827eb2b1c39fe482bce6621910c352ce0172d4779a2983ac30f6cbe7a6bd4837bd9bec965791e772cb8b56b4b877a
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.md
|
4
|
+
Rakefile
|
5
|
+
bin/fixman
|
6
|
+
lib/fixman.rb
|
7
|
+
lib/fixman/configuration.rb
|
8
|
+
lib/fixman/command_line.rb
|
9
|
+
lib/fixman/controller.rb
|
10
|
+
lib/fixman/raw_task.rb
|
11
|
+
lib/fixman/repository.rb
|
12
|
+
lib/fixman/task.rb
|
13
|
+
lib/fixman/task_parse_error.rb
|
14
|
+
lib/fixman/tester.rb
|
15
|
+
lib/fixman/utilities.rb
|
16
|
+
test/test_fixman.rb
|
17
|
+
test/test_command_line.rb
|
18
|
+
test/test_configuration.rb
|
19
|
+
test/test_controller.rb
|
20
|
+
test/test_raw_task.rb
|
21
|
+
test/test_repository.rb
|
22
|
+
test/test_task.rb
|
23
|
+
test/test_tester.rb
|
data/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# fixman
|
2
|
+
|
3
|
+
home :: https://github.com/madgen/fixman
|
4
|
+
|
5
|
+
## DESCRIPTION:
|
6
|
+
|
7
|
+
THIS PROJECT IS NOT YET READY FOR USAGE!
|
8
|
+
|
9
|
+
A tool to test source code analysis command line tools against source code
|
10
|
+
remotely available in git repositories such as GitHub.
|
11
|
+
|
12
|
+
## FEATURES/PROBLEMS:
|
13
|
+
|
14
|
+
## COMMAND LINE
|
15
|
+
|
16
|
+
### test
|
17
|
+
|
18
|
+
`fixman <test>`
|
19
|
+
|
20
|
+
### list/shortlist
|
21
|
+
|
22
|
+
`fixman <list|shortlist>`
|
23
|
+
|
24
|
+
Lists the repositories used in testing. Shortlist succint summary
|
25
|
+
of the repositories with canonical name and commit hash used for
|
26
|
+
testing.
|
27
|
+
|
28
|
+
### add
|
29
|
+
|
30
|
+
`fixman <add>`
|
31
|
+
Starts interactive session to add new repository with the details.
|
32
|
+
|
33
|
+
### delete
|
34
|
+
|
35
|
+
`fixman <delete> <canonical_name>`
|
36
|
+
|
37
|
+
Delete the repository identified by its canonical name from the list of places
|
38
|
+
to be tested.
|
39
|
+
|
40
|
+
### fetch
|
41
|
+
|
42
|
+
`fixman <fetch> [group...]`
|
43
|
+
|
44
|
+
Download all the repositories belonging to list of groups. The groups would be
|
45
|
+
specified in the configuration file. If group is left out all repositories are
|
46
|
+
fetched.
|
47
|
+
|
48
|
+
The version of the repository fetch is set to HEAD by default. If a different
|
49
|
+
commit is desired this can be specified while adding the repository or by
|
50
|
+
altering the YAML file containing the repositories.
|
51
|
+
|
52
|
+
If the remote repository cannot be reached or there are not sufficient
|
53
|
+
priveleges, fetch process skips to the next repository but produces a
|
54
|
+
warning.
|
55
|
+
|
56
|
+
### update
|
57
|
+
|
58
|
+
`fixman <update> <canonical_name> [commit_SHA]`
|
59
|
+
|
60
|
+
Updates the commit of the repository. This can be a future commit or an older
|
61
|
+
one. It only updates the repository listing as such `upgrade` needs to be run to
|
62
|
+
update the repo in the file system.
|
63
|
+
|
64
|
+
### upgrade
|
65
|
+
|
66
|
+
`fixman <upgrade> <group(s)>`
|
67
|
+
|
68
|
+
## CONFIGURATION FILE
|
69
|
+
|
70
|
+
Configuration file is a YAML file ordinarily located at `.fixman_conf.yaml`
|
71
|
+
unless it has been overridden by the `-c` command line option. It contains
|
72
|
+
task definitions, base path for the fixtures, and allows overriding various
|
73
|
+
defaults.
|
74
|
+
|
75
|
+
### Fixture base (compulsory)
|
76
|
+
|
77
|
+
The base path for repositories listed in the ledger.
|
78
|
+
|
79
|
+
Example
|
80
|
+
|
81
|
+
```
|
82
|
+
:fixture_base: /path/to/base_dir
|
83
|
+
```
|
84
|
+
|
85
|
+
### Task definitions (compulsory)
|
86
|
+
|
87
|
+
An array of tasks to be run on the repositories specified in the fixtures
|
88
|
+
ledger.
|
89
|
+
|
90
|
+
Example:
|
91
|
+
|
92
|
+
```
|
93
|
+
:tasks:
|
94
|
+
- :target_condition: :ruby: 2.even?
|
95
|
+
:command:
|
96
|
+
:extra_placeholders:
|
97
|
+
:cleanups:
|
98
|
+
:target_placeholder:
|
99
|
+
```
|
100
|
+
|
101
|
+
### Extra repository information (optional)
|
102
|
+
|
103
|
+
If set, it causes `add` command to direct more queries to the user than what
|
104
|
+
is necessary for fixman to function. This information can be things like notes,
|
105
|
+
licence, urls, and anything else. It further allows these fields to be optional,
|
106
|
+
chosen from set values, or mandatory.
|
107
|
+
|
108
|
+
Each extra repository information has the following subfields
|
109
|
+
|
110
|
+
#### Symbol (mandatory)
|
111
|
+
Unique symbol for the extra bit of information.
|
112
|
+
|
113
|
+
#### Prompt (mandatory)
|
114
|
+
Prompt directed at the user when `add` command is used.
|
115
|
+
|
116
|
+
#### Label (mandatory)
|
117
|
+
Label to be used when the repositories are listed for this information.
|
118
|
+
|
119
|
+
#### Choices (optional)
|
120
|
+
A list of strings corresponding to choices the value of the field can take.
|
121
|
+
|
122
|
+
#### Optional (optional)
|
123
|
+
If set to true, then the empty entry is acceptable. If omitted or set to false
|
124
|
+
the prompt is repeated until a valid input is received.
|
125
|
+
|
126
|
+
Example:
|
127
|
+
|
128
|
+
```
|
129
|
+
:extra_repo_info:
|
130
|
+
- :symbol: licence
|
131
|
+
:prompt: Please enter licence
|
132
|
+
:label: Licence
|
133
|
+
:choices: [MIT, Apache, GPL]
|
134
|
+
|
135
|
+
- :symbol: notes
|
136
|
+
:prompt: Any notes?
|
137
|
+
:label: Notes
|
138
|
+
:optional: true
|
139
|
+
```
|
140
|
+
|
141
|
+
### Groups (optional)
|
142
|
+
|
143
|
+
Not every repository in the ledger needs to be fetched and tested. This option
|
144
|
+
allows user to specify groups which can be separately fetched and tested. Refer
|
145
|
+
to the command line documentation for example usage.
|
146
|
+
|
147
|
+
Example:
|
148
|
+
|
149
|
+
```
|
150
|
+
:groups: [:public, :private]
|
151
|
+
```
|
152
|
+
|
153
|
+
### Fixture ledger (optional)
|
154
|
+
|
155
|
+
The path to the YAML file that acts as a ledger for the repositories. Defaults
|
156
|
+
to `.fixman_ledger.yaml`.
|
157
|
+
|
158
|
+
Example:
|
159
|
+
|
160
|
+
```
|
161
|
+
:fixture_ledger: /path/to/my_ledger.yaml
|
162
|
+
```
|
163
|
+
|
164
|
+
## REQUIREMENTS:
|
165
|
+
|
166
|
+
Requires Ruby 1.9.3 or onwards.
|
167
|
+
|
168
|
+
## INSTALL:
|
169
|
+
|
170
|
+
`gem install fixman`
|
171
|
+
|
172
|
+
## LICENSE
|
173
|
+
|
174
|
+
Refer to LICENCE file but it is basically Apache Licence v2.0.
|
175
|
+
|
176
|
+
Copyright 2015 Mistral Contrastin
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
Hoe.plugin :minitest
|
7
|
+
Hoe.plugin :git
|
8
|
+
Hoe.plugin :gemspec
|
9
|
+
|
10
|
+
Hoe.spec 'fixman' do
|
11
|
+
developer("Mistral Contrastin", "madgenhetic@gmail.com")
|
12
|
+
self.readme_file = 'README.md'
|
13
|
+
|
14
|
+
dependency 'classy_hash', '~> 0.1'
|
15
|
+
dependency 'git', '~> 1.2'
|
16
|
+
dependency 'pry-byebug', '~> 1.2', :dev
|
17
|
+
|
18
|
+
license 'Apache'
|
19
|
+
end
|
data/bin/fixman
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fixman'
|
4
|
+
|
5
|
+
include Fixman::CommandLine
|
6
|
+
include Fixman::Utilities
|
7
|
+
|
8
|
+
options = parse_options!(ARGV)
|
9
|
+
command, args = parse_positional_arguments!(ARGV)
|
10
|
+
conf = Fixman::Configuration.read options[:conf_path]
|
11
|
+
|
12
|
+
case command
|
13
|
+
when :test
|
14
|
+
tester = Fixman::Tester.new conf
|
15
|
+
tester.test
|
16
|
+
when [:list, :shortlist]
|
17
|
+
repos = Fixman::Controller.open conf do |controller|
|
18
|
+
controller.repos
|
19
|
+
end
|
20
|
+
|
21
|
+
puts(command == :list ? repos : repos.map(&:summary))
|
22
|
+
when :add
|
23
|
+
params = get_params conf.extra_repo_info, conf.groups
|
24
|
+
|
25
|
+
Fixman::Controller.open conf do |controller|
|
26
|
+
controller.add params, conf.fixtures_base, conf.extra_repo_info
|
27
|
+
end
|
28
|
+
when :delete
|
29
|
+
Fixman::Controller.open conf do |controller|
|
30
|
+
begin
|
31
|
+
controller.delete args[:canonical_name]
|
32
|
+
rescue ArgumentError
|
33
|
+
error "Input #{args[:canonical_name]} is not a valid canonical \
|
34
|
+
repository name."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
when :fetch
|
38
|
+
Fixman::Controller.open conf do |controller|
|
39
|
+
controller.fetch args[:groups]
|
40
|
+
end
|
41
|
+
when :update
|
42
|
+
Fixman::Controller.open conf do |controller|
|
43
|
+
update_args = [args[:canonical_name], args[:sha]].compact
|
44
|
+
controller.update(*update_args)
|
45
|
+
end
|
46
|
+
when :upgrade
|
47
|
+
Fixman::Controller.open conf do |controller|
|
48
|
+
controller.upgrade args[:groups]
|
49
|
+
end
|
50
|
+
end
|
data/lib/fixman.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'fixman/configuration'
|
2
|
+
require 'fixman/command_line'
|
3
|
+
require 'fixman/controller'
|
4
|
+
require 'fixman/raw_task'
|
5
|
+
require 'fixman/repository'
|
6
|
+
require 'fixman/task'
|
7
|
+
require 'fixman/task_parse_error'
|
8
|
+
require 'fixman/tester'
|
9
|
+
|
10
|
+
module Fixman
|
11
|
+
VERSION = '0.1.0'
|
12
|
+
NAME = 'fixman'
|
13
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'pathname'
|
3
|
+
require 'set'
|
4
|
+
require 'fixman/utilities'
|
5
|
+
require 'fixman/configuration'
|
6
|
+
|
7
|
+
module Fixman
|
8
|
+
module CommandLine
|
9
|
+
|
10
|
+
URL_TEMPLATE = {
|
11
|
+
symbol: :url,
|
12
|
+
prompt: 'Remote repository URL: ',
|
13
|
+
label: 'URL',
|
14
|
+
type: :mandatory
|
15
|
+
}
|
16
|
+
|
17
|
+
NAME_TEMPLATE = {
|
18
|
+
symbol: :name,
|
19
|
+
prompt: 'Repository name: ',
|
20
|
+
label: 'Name',
|
21
|
+
type: :mandatory
|
22
|
+
}
|
23
|
+
|
24
|
+
OWNER_TEMPLATE = {
|
25
|
+
symbol: :owner,
|
26
|
+
prompt: 'Owner: ',
|
27
|
+
label: 'Owner',
|
28
|
+
type: :mandatory
|
29
|
+
}
|
30
|
+
|
31
|
+
GROUPS_TEMPLATE = {
|
32
|
+
symbol: :groups,
|
33
|
+
prompt: 'Groups: ',
|
34
|
+
label: 'Groups',
|
35
|
+
type: :multiple_choice
|
36
|
+
}
|
37
|
+
|
38
|
+
include Utilities
|
39
|
+
|
40
|
+
def parse_options!(args)
|
41
|
+
options = {}
|
42
|
+
options[:conf_path] =
|
43
|
+
Pathname.new Fixman::Configuration::DEFAULT_CONF_FILE
|
44
|
+
|
45
|
+
parser = OptionParser.new do |opts|
|
46
|
+
opts.banner = "Usage: #{NAME} [option]"
|
47
|
+
|
48
|
+
opts.on_tail('-h', '--help', 'Display this message') do
|
49
|
+
puts 'help' # TODO
|
50
|
+
exit 0
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('-v', '--version', 'Display the version') do
|
54
|
+
puts VERSION
|
55
|
+
exit 0
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on('-c', '--configuration-file PATH') do |path|
|
59
|
+
options[:conf_path] = Pathname.new path
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
parser.parse! args
|
65
|
+
rescue OptionParser::InvalidaOption
|
66
|
+
error usage
|
67
|
+
end
|
68
|
+
|
69
|
+
options
|
70
|
+
end
|
71
|
+
|
72
|
+
# Options are parsed prior to the positional arguments allowing
|
73
|
+
# optional trailing positional arguments.
|
74
|
+
def parse_positional_arguments!(raw_args)
|
75
|
+
# Error if there are no commands
|
76
|
+
error usage if raw_args.size < 1
|
77
|
+
|
78
|
+
command = raw_args.shift.downcase.to_sym
|
79
|
+
args = {}
|
80
|
+
|
81
|
+
case command
|
82
|
+
when :test, :list, :shortlist, :add
|
83
|
+
error usage unless raw_args.size == 0
|
84
|
+
when :delete
|
85
|
+
error usage unless raw_args.size == 1
|
86
|
+
args[:canonical_name] = raw_args.shift
|
87
|
+
when :fetch, :upgrade
|
88
|
+
args[:groups] = raw_args.map { |group| group.downcase.to_sym }
|
89
|
+
raw_args.delete_if {true}
|
90
|
+
when :update
|
91
|
+
error usage unless [1, 2].include? raw_args.size
|
92
|
+
args[:canonical_name], args[:sha] = raw_args.shift 2
|
93
|
+
else
|
94
|
+
error usage
|
95
|
+
end
|
96
|
+
|
97
|
+
[command, args]
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_params extra_templates, groups
|
101
|
+
input = {}
|
102
|
+
start_session input, URL_TEMPLATE
|
103
|
+
|
104
|
+
input[:owner], input[:name] =
|
105
|
+
Fixman::Repository.extract_owner_and_name input[:url]
|
106
|
+
unless input[:owner] && input[:name]
|
107
|
+
start_session input, NAME_TEMPLATE
|
108
|
+
start_session input, OWNER_TEMPLATE
|
109
|
+
end
|
110
|
+
|
111
|
+
unless groups.empty?
|
112
|
+
GROUPS_TEMPLATE[:choices] = groups
|
113
|
+
start_session input, GROUPS_TEMPLATE
|
114
|
+
end
|
115
|
+
|
116
|
+
extra_templates.each do |template|
|
117
|
+
start_session input, template
|
118
|
+
end
|
119
|
+
|
120
|
+
input[:sha] = Repository.retrieve_head_sha input[:url]
|
121
|
+
|
122
|
+
input
|
123
|
+
end
|
124
|
+
|
125
|
+
def usage
|
126
|
+
#TODO
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def start_session input, template
|
132
|
+
raw_input = nil
|
133
|
+
case template[:type]
|
134
|
+
when :mandatory
|
135
|
+
loop do
|
136
|
+
print template[:prompt]
|
137
|
+
raw_input = get_input
|
138
|
+
break unless raw_input =~ /^\s*$/
|
139
|
+
end
|
140
|
+
when :optional, nil # nil in the case type is not specified
|
141
|
+
print template[:prompt]
|
142
|
+
raw_input = get_input
|
143
|
+
when :single_choice
|
144
|
+
loop do
|
145
|
+
puts template[:prompt]
|
146
|
+
print "Choose one from #{template[:choices].join('/')}: "
|
147
|
+
raw_input = get_input
|
148
|
+
choice_index =
|
149
|
+
template[:choices].map(&:downcase).find_index raw_input.strip.downcase
|
150
|
+
if choice_index
|
151
|
+
raw_input = template[:choices][choice_index]
|
152
|
+
break
|
153
|
+
end
|
154
|
+
end
|
155
|
+
when :multiple_choice
|
156
|
+
choices = template[:choices].map(&:strip)
|
157
|
+
downcase_choices = choices.map(&:downcase)
|
158
|
+
loop do
|
159
|
+
puts template[:prompt]
|
160
|
+
print "Comma separated multiple choice #{template[:choices].join('/')}: "
|
161
|
+
raw_input = get_input.split(',').map(&:strip)
|
162
|
+
raw_choices = raw_input.map(&:downcase).to_set
|
163
|
+
|
164
|
+
if raw_choices.subset? downcase_choices.to_set
|
165
|
+
raw_input =
|
166
|
+
raw_choices.inject([]) do |acc, choice|
|
167
|
+
i = downcase_choices.find_index choice
|
168
|
+
acc << choices[i]
|
169
|
+
end
|
170
|
+
break
|
171
|
+
end
|
172
|
+
end
|
173
|
+
else
|
174
|
+
# TODO error behaviour
|
175
|
+
end
|
176
|
+
|
177
|
+
input[template[:symbol]] = raw_input
|
178
|
+
end
|
179
|
+
|
180
|
+
def get_input
|
181
|
+
gets.chomp
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|