Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to create an Sprint with a custom number #117

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
with `-o`.
* `burndown --plot-to-board` always sets the burndown chart as the cover.
Fix #114.
* Allow to create and update an Sprint with a custom number. Fix #78.

## Version 0.0.14

Expand Down
11 changes: 6 additions & 5 deletions lib/burndown_chart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,9 @@ def last_sprint(burndown_dir)
last_sprint
end

def load_last_sprint(burndown_dir)
self.sprint = last_sprint(burndown_dir)
# It loads the sprint for the given number or the last one if it is nil
def load_sprint(burndown_dir, number = nil)
self.sprint = number || last_sprint(burndown_dir)
burndown_data_path = File.join(burndown_dir, burndown_data_filename)
begin
read_data burndown_data_path
Expand All @@ -192,7 +193,7 @@ def load_last_sprint(burndown_dir)
end

def update(options)
burndown_data_path = load_last_sprint(options['output'] || Dir.pwd)
burndown_data_path = load_sprint(options['output'] || Dir.pwd, options[:sprint_number])

burndown_data = BurndownData.new(@settings)
burndown_data.board_id = board_id
Expand Down Expand Up @@ -222,8 +223,8 @@ def update(options)
end

def create_next_sprint(burndown_dir, options = {})
load_last_sprint(burndown_dir)
self.sprint = self.sprint + 1
load_sprint(burndown_dir)
self.sprint = options[:sprint_number] || (self.sprint + 1)
@data["meta"]["total_days"] = options[:total_days] if options[:total_days]
@data["meta"]["weekend_lines"] = options[:weekend_lines] unless options[:weekend_lines].blank?
@data["days"] = []
Expand Down
3 changes: 2 additions & 1 deletion lib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def burndown_init command = nil
desc "burndown", "Update burndown chart"
option :output, :aliases => :o, :desc => "Output directory", :required => false
option :new_sprint, :aliases => :n, :desc => "Create new sprint"
option :sprint_number, type: :numeric, :desc => "Provide the number of the sprint"
option :total_days, type: :numeric, desc: "Provide how many days the sprint longs. 10 days by default"
option :weekend_lines, type: :array, desc: "Set the weekend_lines. [3.5, 8.5] by default"
option :plot, :type => :boolean, :desc => "also plot the new data"
Expand All @@ -181,7 +182,7 @@ def burndown
chart = BurndownChart.new @@settings
begin
if options[:new_sprint]
chart.create_next_sprint(options[:output] || Dir.pwd, { total_days: options[:total_days], weekend_lines: options[:weekend_lines] })
chart.create_next_sprint(options[:output] || Dir.pwd, options)
end
chart.update(options)
puts "Updated data for sprint #{chart.sprint}"
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/burndown_chart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,11 @@
end
end

describe "load_last_sprint" do
describe "load_sprint" do
let(:path) { given_directory_from_data("burndown_dir") }

it "loads the burndown from the 2nd sprint into data" do
@chart.load_last_sprint(path)
@chart.load_sprint(path)
expect(@chart.data).to eq(
{ "meta" =>
{ "board_id" => "53186e8391ef8671265eba9d",
Expand Down Expand Up @@ -402,7 +402,7 @@
end

it "returns the path of the last sprint" do
expect(@chart.load_last_sprint(path)).to eq(File.join(path, "burndown-data-02.yaml"))
expect(@chart.load_sprint(path)).to eq(File.join(path, "burndown-data-02.yaml"))
end
end

Expand Down