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

grains: Move input (square) to input object #1191

Merged
merged 1 commit into from
Feb 15, 2018
Merged

grains: Move input (square) to input object #1191

merged 1 commit into from
Feb 15, 2018

Conversation

petertseng
Copy link
Member

grains 1.1.0

As proposed and accepted in #996

have_input = false

ARGF.each_line { |l|
  if l.include?('version')
    ver = l.split(?")[3]
    ver_components = ver.split(?.).map(&:to_i)
    ver_components[1] += 1
    ver_components[2] = 0
    l[ver] = ver_components.join(?.)
  end

  have_input &&= !l.include?('"description"')

  first_non_space = l.index(/\S/)
  if l.include?('"input"')
    have_input = true
    input = l.split(?:).last.to_i
    puts ' ' * first_non_space + '"input": {'
    puts ' ' * first_non_space + '  "square": ' + input.to_s
    puts ' ' * first_non_space + '},'
    next
  end

  puts ' ' * first_non_space + '"input": {},' if l.include?('"expected"') && !have_input

  puts l
}

grains 1.1.0

As proposed and accepted in #996

```ruby
have_input = false

ARGF.each_line { |l|
  if l.include?('version')
    ver = l.split(?")[3]
    ver_components = ver.split(?.).map(&:to_i)
    ver_components[1] += 1
    ver_components[2] = 0
    l[ver] = ver_components.join(?.)
  end

  have_input &&= !l.include?('"description"')

  first_non_space = l.index(/\S/)
  if l.include?('"input"')
    have_input = true
    input = l.split(?:).last.to_i
    puts ' ' * first_non_space + '"input": {'
    puts ' ' * first_non_space + '  "square": ' + input.to_s
    puts ' ' * first_non_space + '},'
    next
  end

  puts ' ' * first_non_space + '"input": {},' if l.include?('"expected"') && !have_input

  puts l
}
```
@petertseng
Copy link
Member Author

That's the last of them, so I need to revert the thing after.

@petertseng petertseng merged commit f079c2d into exercism:master Feb 15, 2018
@petertseng petertseng deleted the grans branch February 15, 2018 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants