ehpt 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ehpt +1 -1
- data/lib/ehpt/base.rb +11 -1
- data/lib/ehpt/create_stories.rb +9 -6
- data/lib/ehpt/create_story.rb +2 -2
- data/lib/ehpt/get_project.rb +2 -2
- data/lib/ehpt.rb +14 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3653e66627846fae073f4173a4f51cf683b76284d1b413095347c9f3462a94e
|
4
|
+
data.tar.gz: f8835fe7726e1f883e9f5608328e7257f06abdf0a8552cd1332662ad64e64ace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae913c7ffbd558597ca0847638ffe32bdffdc8e5bf412c9352bfdd38faaa107809f8e092fbada9e68080f9704d2fc97f169b525e6cf68b10200978c106720b60
|
7
|
+
data.tar.gz: 63c49d8f401bf28dbdb407c00878f56d1fafe7b522211ea190197764a106b43d33253109df0fb67a95448892341fd5921986a96fb65e8548babacc7f39f5826a
|
data/bin/ehpt
CHANGED
data/lib/ehpt/base.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
module Ehpt
|
2
2
|
class Base
|
3
3
|
attr_reader :data, :errors
|
4
4
|
|
@@ -18,5 +18,15 @@ class Ehpt
|
|
18
18
|
def error?
|
19
19
|
!success?
|
20
20
|
end
|
21
|
+
|
22
|
+
def add_error(error)
|
23
|
+
if error.is_a?(Array)
|
24
|
+
error.each do |err|
|
25
|
+
add_error(err)
|
26
|
+
end
|
27
|
+
else
|
28
|
+
@errors << error
|
29
|
+
end
|
30
|
+
end
|
21
31
|
end
|
22
32
|
end
|
data/lib/ehpt/create_stories.rb
CHANGED
@@ -2,7 +2,7 @@ require 'csv'
|
|
2
2
|
require 'ehpt/base'
|
3
3
|
require 'ehpt/create_story'
|
4
4
|
|
5
|
-
|
5
|
+
module Ehpt
|
6
6
|
class CreateStories < Base
|
7
7
|
attr_reader :csv_file, :project
|
8
8
|
|
@@ -24,14 +24,16 @@ class Ehpt
|
|
24
24
|
validate_csv_file!
|
25
25
|
create_stories unless error?
|
26
26
|
rescue StandardError => e
|
27
|
-
|
27
|
+
add_error(e.message)
|
28
28
|
end
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def validate_csv_file!
|
33
|
-
|
34
|
-
|
33
|
+
if File.extname(csv_file) != '.csv'
|
34
|
+
add_error('Input file must be a csv file' )
|
35
|
+
end
|
36
|
+
add_error('CSV content is empty') if File.zero?(csv_file)
|
35
37
|
end
|
36
38
|
|
37
39
|
def create_stories
|
@@ -39,13 +41,14 @@ class Ehpt
|
|
39
41
|
story_attrs = create_story_attributes(row)
|
40
42
|
story_creator = Ehpt::CreateStory.new(project, story_attrs)
|
41
43
|
story_creator.call
|
44
|
+
|
42
45
|
if story_creator.success?
|
43
46
|
puts "Created story: #{story_creator.data.name}"
|
44
47
|
else
|
45
|
-
|
48
|
+
add_error({
|
46
49
|
row: row.to_h,
|
47
50
|
errors: story_creator.errors
|
48
|
-
}
|
51
|
+
})
|
49
52
|
end
|
50
53
|
end
|
51
54
|
end
|
data/lib/ehpt/create_story.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'ehpt/base'
|
2
2
|
|
3
|
-
|
3
|
+
module Ehpt
|
4
4
|
class CreateStory < Base
|
5
5
|
attr_reader :project, :story_attrs
|
6
6
|
|
@@ -14,7 +14,7 @@ class Ehpt
|
|
14
14
|
create_story
|
15
15
|
prefix_story_name_with_id
|
16
16
|
rescue StandardError => e
|
17
|
-
|
17
|
+
add_error(eval(e.message)[:body])
|
18
18
|
end
|
19
19
|
|
20
20
|
private
|
data/lib/ehpt/get_project.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'tracker_api'
|
2
2
|
require 'ehpt/base'
|
3
3
|
|
4
|
-
|
4
|
+
module Ehpt
|
5
5
|
class GetProject < Base
|
6
6
|
attr_reader :token, :project_id
|
7
7
|
|
@@ -15,7 +15,7 @@ class Ehpt
|
|
15
15
|
pt_client = TrackerApi::Client.new(token: token)
|
16
16
|
@data = pt_client.project(project_id)
|
17
17
|
rescue StandardError => e
|
18
|
-
|
18
|
+
add_error(eval(e.message)[:body])
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/ehpt.rb
CHANGED
@@ -3,35 +3,28 @@ require 'csv'
|
|
3
3
|
require 'ehpt/get_project'
|
4
4
|
require 'ehpt/create_stories'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
module Ehpt
|
7
|
+
def self.call(csv_file, token, project_id)
|
8
|
+
project_getter = Ehpt::GetProject.new(token, project_id)
|
9
|
+
project_getter.call
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
if project_getter.error?
|
12
|
+
puts "===== Errors ====="
|
13
|
+
pp project_getter.errors
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
puts "Found project: #{project_getter.data.name}"
|
18
|
+
project = project_getter.data
|
13
19
|
|
14
|
-
def call
|
15
20
|
stories_creator = Ehpt::CreateStories.new(csv_file, project)
|
16
21
|
stories_creator.call
|
22
|
+
|
17
23
|
puts "Done"
|
24
|
+
|
18
25
|
if stories_creator.error?
|
19
26
|
puts "===== Errors ====="
|
20
27
|
pp stories_creator.errors
|
21
28
|
end
|
22
29
|
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def get_project_by(token, project_id)
|
27
|
-
project_getter = Ehpt::GetProject.new(token, project_id)
|
28
|
-
project_getter.call
|
29
|
-
|
30
|
-
if project_getter.error?
|
31
|
-
raise StandardError, project_getter.errors
|
32
|
-
end
|
33
|
-
|
34
|
-
puts "Found project: #{project_getter.data.name}"
|
35
|
-
project_getter.data
|
36
|
-
end
|
37
30
|
end
|