est 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +2 -0
- data/.gitignore +7 -0
- data/.rubocop.yml +2 -0
- data/.rultor.yml +20 -0
- data/.simplecov +34 -0
- data/.travis.yml +12 -0
- data/Gemfile +25 -0
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +71 -0
- data/assets/est.xsd +49 -0
- data/assets/est.xsl +67 -0
- data/bin/est +84 -0
- data/cucumber.yml +3 -0
- data/est.gemspec +59 -0
- data/features/cli.feature +51 -0
- data/features/gem_package.feature +22 -0
- data/features/step_definitions/steps.rb +110 -0
- data/features/support/env.rb +25 -0
- data/lib/est.rb +123 -0
- data/lib/est/estimate.rb +65 -0
- data/lib/est/estimates.rb +57 -0
- data/lib/est/methods/champions.rb +50 -0
- data/lib/est/version.rb +30 -0
- data/test/test__helper.rb +26 -0
- data/test/test_champions.rb +61 -0
- data/test/test_est.rb +92 -0
- data/test/test_estimate.rb +71 -0
- data/test/test_estimates.rb +68 -0
- metadata +263 -0
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.rultor.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
assets:
|
2
|
+
rubygems.yml: "yegor256/home#assets/rubygems.yml"
|
3
|
+
s3cfg: "yegor256/home#assets/s3cfg"
|
4
|
+
|
5
|
+
install: |
|
6
|
+
sudo gem install pdd
|
7
|
+
|
8
|
+
release:
|
9
|
+
script: |
|
10
|
+
sudo bundle install
|
11
|
+
rake
|
12
|
+
rm -rf *.gem
|
13
|
+
sed -i "s/1\.0\.snapshot/${tag}/g" lib/est/version.rb
|
14
|
+
gem build est.gemspec
|
15
|
+
chmod 0600 ../rubygems.yml
|
16
|
+
gem push *.gem --config-file ../rubygems.yml
|
17
|
+
pdd --source=$(pwd) --verbose --file=est.xml
|
18
|
+
s3cmd --no-progress put est.xml --config=../s3cfg s3://pdd.teamed.io/est.xml
|
19
|
+
s3cmd --no-progress put assets/est.xsd --acl-public --config=../s3cfg s3://est-xsd.teamed.io/${tag}.xsd
|
20
|
+
s3cmd --no-progress put assets/est.xsl --acl-public --config=../s3cfg s3://est-xsl.teamed.io/${tag}.xsl
|
data/.simplecov
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014 TechnoPark Corp.
|
4
|
+
# Copyright (c) 2014 Yegor Bugayenko
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
require 'coveralls'
|
25
|
+
|
26
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
27
|
+
SimpleCov::Formatter::HTMLFormatter,
|
28
|
+
Coveralls::SimpleCov::Formatter
|
29
|
+
]
|
30
|
+
SimpleCov.start do
|
31
|
+
add_filter "/test/"
|
32
|
+
add_filter "/features/"
|
33
|
+
minimum_coverage 100
|
34
|
+
end
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014 TechnoPark Corp.
|
4
|
+
# Copyright (c) 2014 Yegor Bugayenko
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
source 'https://rubygems.org'
|
25
|
+
gemspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2014 TechnoPark Corp.
|
4
|
+
Copyright (c) 2014 Yegor Bugayenko
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
[![Made By Teamed.io](http://img.teamed.io/btn.svg)](http://www.teamed.io)
|
2
|
+
[![DevOps By Rultor.com](http://www.rultor.com/b/teamed/est)](http://www.rultor.com/p/teamed/est)
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/teamed/est.svg)](https://travis-ci.org/teamed/est)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/est.svg)](http://badge.fury.io/rb/est)
|
6
|
+
[![Dependency Status](https://gemnasium.com/teamed/est.svg)](https://gemnasium.com/teamed/est)
|
7
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/teamed/est.svg)](https://codeclimate.com/github/teamed/est)
|
8
|
+
[![Coverage Status](https://img.shields.io/coveralls/teamed/est.svg)](https://coveralls.io/r/teamed/est)
|
9
|
+
|
10
|
+
Install it first:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ gem install est
|
14
|
+
```
|
15
|
+
|
16
|
+
Run it locally and read its output:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ est --help
|
20
|
+
```
|
21
|
+
|
22
|
+
Every estimate should be in its own file, with `.yml` extension (YAML format).
|
23
|
+
Here is an example of an estimate file for a simple web app:
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
date: 19-12-2014
|
27
|
+
author: Yegor Bugayenko
|
28
|
+
method: champions.pert
|
29
|
+
scope:
|
30
|
+
1: basic Sinatra scaffolding
|
31
|
+
2: front-end HAML files
|
32
|
+
3: SASS stylesheet
|
33
|
+
4: five model classes with unit tests
|
34
|
+
5: PostgreSQL migrations
|
35
|
+
6: Cucumber tests for PostgreSQL
|
36
|
+
7: Capybara tests for HTML front
|
37
|
+
8: CasperJS tests
|
38
|
+
9: achieve 80% test coverage
|
39
|
+
champions:
|
40
|
+
7:
|
41
|
+
worst-case: 40
|
42
|
+
best-case: 10
|
43
|
+
most-likely: 18
|
44
|
+
4:
|
45
|
+
worst-case: 30
|
46
|
+
best-case: 8
|
47
|
+
most-likely: 16
|
48
|
+
```
|
49
|
+
|
50
|
+
All estimates found in a directory will be combined and a final
|
51
|
+
project estimate will be produced:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ est --dir=./est
|
55
|
+
Estimate: 90 hours
|
56
|
+
Accuracy (%): +300/-45
|
57
|
+
Precision (%): 6.5
|
58
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014 TechnoPark Corp.
|
4
|
+
# Copyright (c) 2014 Yegor Bugayenko
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in all
|
14
|
+
# copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
|
24
|
+
require 'rubygems'
|
25
|
+
require 'rake'
|
26
|
+
require 'rdoc'
|
27
|
+
require 'rake/clean'
|
28
|
+
|
29
|
+
def name
|
30
|
+
@name ||= File.basename(Dir['*.gemspec'].first, '.*')
|
31
|
+
end
|
32
|
+
|
33
|
+
def version
|
34
|
+
Gem::Specification.load(Dir['*.gemspec'].first).version
|
35
|
+
end
|
36
|
+
|
37
|
+
task default: [:clean, :test, :features, :rubocop]
|
38
|
+
|
39
|
+
require 'rake/testtask'
|
40
|
+
desc 'Run all unit tests'
|
41
|
+
Rake::TestTask.new(:test) do |test|
|
42
|
+
Rake::Cleaner.cleanup_files(['coverage'])
|
43
|
+
test.libs << 'lib' << 'test'
|
44
|
+
test.pattern = 'test/**/test_*.rb'
|
45
|
+
test.verbose = false
|
46
|
+
end
|
47
|
+
|
48
|
+
require 'rdoc/task'
|
49
|
+
desc 'Build RDoc documentation'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "#{name} #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
57
|
+
require 'rubocop/rake_task'
|
58
|
+
desc 'Run RuboCop on all directories'
|
59
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
60
|
+
task.fail_on_error = true
|
61
|
+
task.requires << 'rubocop-rspec'
|
62
|
+
end
|
63
|
+
|
64
|
+
require 'cucumber/rake/task'
|
65
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
66
|
+
Rake::Cleaner.cleanup_files(['coverage'])
|
67
|
+
t.profile = 'travis'
|
68
|
+
end
|
69
|
+
Cucumber::Rake::Task.new(:"features:html") do |t|
|
70
|
+
t.profile = 'html_report'
|
71
|
+
end
|
data/assets/est.xsd
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!--
|
3
|
+
* Copyright (c) 2014 TechnoPark Corp.
|
4
|
+
* Copyright (c) 2014 Yegor Bugayenko
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
-->
|
24
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
25
|
+
<xs:complexType name="est">
|
26
|
+
<xs:all>
|
27
|
+
<xs:element name="total" type="xs:int"/>
|
28
|
+
<xs:element name="date" type="xs:date"/>
|
29
|
+
<xs:element name="author" type="xs:string"/>
|
30
|
+
</xs:all>
|
31
|
+
<xs:attribute name="id" use="required" type="xs:int"/>
|
32
|
+
</xs:complexType>
|
33
|
+
<xs:element name="estimate">
|
34
|
+
<xs:complexType>
|
35
|
+
<xs:all>
|
36
|
+
<xs:element name="total" type="xs:int"/>
|
37
|
+
<xs:element name="ests">
|
38
|
+
<xs:complexType>
|
39
|
+
<xs:sequence>
|
40
|
+
<xs:element name="est" type="est" minOccurs="1" maxOccurs="unbounded" />
|
41
|
+
</xs:sequence>
|
42
|
+
</xs:complexType>
|
43
|
+
</xs:element>
|
44
|
+
</xs:all>
|
45
|
+
<xs:attribute name="version" use="required" type="xs:string"/>
|
46
|
+
<xs:attribute name="date" use="required" type="xs:dateTime"/>
|
47
|
+
</xs:complexType>
|
48
|
+
</xs:element>
|
49
|
+
</xs:schema>
|
data/assets/est.xsl
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!--
|
3
|
+
* Copyright (c) 2014 TechnoPark Corp.
|
4
|
+
* Copyright (c) 2014 Yegor Bugayenko
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the 'Software'), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
14
|
+
* copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
* SOFTWARE.
|
23
|
+
-->
|
24
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
25
|
+
version="1.0" xmlns="http://www.w3.org/1999/xhtml">
|
26
|
+
<xsl:template match="/">
|
27
|
+
<xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text>
|
28
|
+
<html lang="en">
|
29
|
+
<head>
|
30
|
+
<meta charset="UTF-8"/>
|
31
|
+
<meta name="description" content="Estimate"/>
|
32
|
+
<meta name="keywords" content="automated estimate"/>
|
33
|
+
<meta name="author" content="teamed.io"/>
|
34
|
+
<title><xsl:text>Estimate</xsl:text></title>
|
35
|
+
<style type="text/css">
|
36
|
+
body {
|
37
|
+
background-color: #e6e1ce;
|
38
|
+
font-family: Arial, sans-serif;
|
39
|
+
margin: 2em;
|
40
|
+
font-size: 22px;
|
41
|
+
}
|
42
|
+
table {
|
43
|
+
border-spacing: 0px;
|
44
|
+
border-collapse: collapse;
|
45
|
+
}
|
46
|
+
th, td {
|
47
|
+
vertical-align: top;
|
48
|
+
padding: 1em;
|
49
|
+
border: 1px solid gray;
|
50
|
+
}
|
51
|
+
th {
|
52
|
+
text-align: left;
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
<body>
|
57
|
+
<div>
|
58
|
+
<h1>Estimate</h1>
|
59
|
+
<p>
|
60
|
+
<xsl:text>Total: </xsl:text>
|
61
|
+
<xsl:value-of select="total"/>
|
62
|
+
</p>
|
63
|
+
</div>
|
64
|
+
</body>
|
65
|
+
</html>
|
66
|
+
</xsl:template>
|
67
|
+
</xsl:stylesheet>
|
data/bin/est
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
#
|
4
|
+
# Copyright (c) 2014 TechnoPark Corp.
|
5
|
+
# Copyright (c) 2014 Yegor Bugayenko
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in all
|
15
|
+
# copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
|
25
|
+
STDOUT.sync = true
|
26
|
+
|
27
|
+
require 'slop'
|
28
|
+
require 'nokogiri'
|
29
|
+
require 'est'
|
30
|
+
require 'est/version'
|
31
|
+
|
32
|
+
opts = Slop.parse(ARGV, strict: true, help: true) do
|
33
|
+
banner "Usage (#{Est::VERSION}): est [options]"
|
34
|
+
on 'v', 'verbose', 'Enable verbose mode'
|
35
|
+
on 'version', 'Show current version'
|
36
|
+
on(
|
37
|
+
'd',
|
38
|
+
'dir',
|
39
|
+
'Source directory to parse',
|
40
|
+
argument: :required
|
41
|
+
)
|
42
|
+
on(
|
43
|
+
'f',
|
44
|
+
'file',
|
45
|
+
'File to save output into',
|
46
|
+
argument: :required
|
47
|
+
)
|
48
|
+
on(
|
49
|
+
't',
|
50
|
+
'format',
|
51
|
+
'Format to use (xml|html)',
|
52
|
+
argument: :required
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
fail '-f is mandatory when using -v' if opts.verbose? && !opts.file?
|
57
|
+
|
58
|
+
if opts.help?
|
59
|
+
puts opts
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
if opts.version?
|
64
|
+
puts Est::VERSION
|
65
|
+
exit
|
66
|
+
end
|
67
|
+
|
68
|
+
Encoding.default_external = Encoding::UTF_8
|
69
|
+
Encoding.default_internal = Encoding::UTF_8
|
70
|
+
file = opts.file? ? File.new(opts[:file], 'w') : STDOUT
|
71
|
+
output = Est::Base.new(opts).xml
|
72
|
+
if opts[:format]
|
73
|
+
if opts[:format] == 'html'
|
74
|
+
xslt = File.join(
|
75
|
+
File.dirname(File.dirname(__FILE__)),
|
76
|
+
'assets', 'est.xsl'
|
77
|
+
)
|
78
|
+
output = Nokogiri::XSLT(File.read(xslt)).transform(Nokogiri::XML(output))
|
79
|
+
else
|
80
|
+
fail 'invalid format, use html or xml' if opts[:format] != 'xml'
|
81
|
+
end
|
82
|
+
output
|
83
|
+
end
|
84
|
+
file << output
|