Class: Rtprov::Initializer
- Inherits:
-
Object
- Object
- Rtprov::Initializer
- Includes:
- FileUtils::Verbose
- Defined in:
- lib/rtprov/initializer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Initializer
constructor
A new instance of Initializer.
- #run ⇒ Object
Constructor Details
#initialize(name) ⇒ Initializer
Returns a new instance of Initializer.
15 16 17 |
# File 'lib/rtprov/initializer.rb', line 15 def initialize(name) @name = name.dup.freeze end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/rtprov/initializer.rb', line 9 def name @name end |
Class Method Details
.run(name) ⇒ Object
11 12 13 |
# File 'lib/rtprov/initializer.rb', line 11 def self.run(name) new(name).run end |
Instance Method Details
#run ⇒ Object
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 54 55 56 57 58 59 60 |
# File 'lib/rtprov/initializer.rb', line 19 def run raise "Already exists #{name} directory" if File.exist?(name) mkdir name Dir.chdir(name) do mkdir "routers" touch "routers/.keep" mkdir "templates" touch "templates/.keep" puts "Create encryption_key" key = Encryption.generate_key File.write("encryption_key", key) exec "bundle init" exec "bundle add rtprov -v #{VERSION}" exec "bundle binstubs rtprov" puts "Create .gitignore" gitignore = " /encryption_key\n EOS\n File.write(\".gitignore\", gitignore)\n\n exec \"git init\"\n exec \"git add .\"\n end\n\n puts <<~EOS\n\n ============================================================\n !!! Please remember `encryption_key`. Git ignores it. !!!\n ============================================================\n\n And do below.\n 1. cd \#{name}\n 2. bin/rtprov edit YOUR_ROUTER_NAME\n 3. bin/rtprov get YOUR_ROUTER_NAME > tempaltes/config.erb\n 4. Extract credentials in templates/config.erb\n EOS\nend\n" |