Class: YSI::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/yes_ship_it/init.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Init

Returns a new instance of Init.



5
6
7
8
9
# File 'lib/yes_ship_it/init.rb', line 5

def initialize(path)
  @path = path

  @out = STDOUT
end

Instance Attribute Details

#outObject

Returns the value of attribute out.



3
4
5
# File 'lib/yes_ship_it/init.rb', line 3

def out
  @out
end

Instance Method Details

#setup_configObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/yes_ship_it/init.rb', line 11

def setup_config
  config_file = File.join(@path, "yes_ship_it.conf")

  if File.exist?(config_file)
    out.puts "There already is a file `yes_ship_it.conf`."
    out.puts
    out.puts "This project does not seem to need initialization."
    return
  end

  out.puts "Initialized directory for shipping."
  out.puts
  File.open(config_file, "w") do |f|
    f.puts "# Experimental release automation. See https://github.com/cornelius/yes_ship_it."
    if File.exist?(File.join(@path, "lib", "version.rb"))
      out.puts "It looks like this is is Ruby project."

      f.puts "include:"
      f.puts "  ruby_gem"
    else
      out.puts "Couldn't determine type of project, wrote a generic template."

      f.puts "assertions:"
      f.puts "  - release_branch"
      f.puts "  - working_directory"
      f.puts "  - version"
      f.puts "  - change_log"
      f.puts "  - tag"
      f.puts "  - pushed_tag"
      f.puts "  - pushed_code"
      f.puts "  - yes_it_shipped"
    end
  end
  out.puts
  out.puts "The generated configuration includes an assertion, which publishes the release on"
  out.puts "#{YesItShipped.url}, our release notification service. If you"
  out.puts "prefer to not publish releases there, simply remove the `yes_it_shipped`"
  out.puts "assertion."
  out.puts
  out.puts "Check the file `yes_ship_it.conf` and adapt it to your needs."
  out.puts
  out.puts "Happy shipping!"
end