Class: Microstatic::CLI
- Inherits:
-
Thor
- Object
- Thor
- Microstatic::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/microstatic/cli.rb
Instance Method Summary collapse
- #bucket(bucket_name = false) ⇒ Object
- #dns(app_name = false) ⇒ Object
- #rakefile(bucket_name = false) ⇒ Object
- #setup(app_name = false) ⇒ Object
Instance Method Details
#bucket(bucket_name = false) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/microstatic/cli.rb', line 22 def bucket( bucket_name = false ) bucket_name ||= guess_bucket_name # TODO: check it doesn't already exist for you # TODO: check bucket_name looks like a site name (e.g. foo.thepete.net, not just foo) # TODO: handle the bucket name already being taken by someone else # TODO: fail gracefully if aws creds not available describe_operation( "create S3 bucket '#{bucket_name}'" ) do S3BucketCreator.new( config.aws_creds ).create( bucket_name ) end rescue Microstatic::Config::MissingEnvVar raise Thor::Error.new($!) end |
#dns(app_name = false) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/microstatic/cli.rb', line 37 def dns( app_name = false ) app_name ||= inferred_app_name bucket_name = subdomain_for(app_name) # # TODO: handle the subdomain DNS record already existing describe_operation( "create Route 53 entry '#{bucket_name}'" ) do Route53Dns.new( config.aws_creds ).add_s3_record_for_bucket( bucket_name ) end rescue Microstatic::Config::MissingEnvVar raise Thor::Error.new($!) end |
#rakefile(bucket_name = false) ⇒ Object
52 53 54 55 56 |
# File 'lib/microstatic/cli.rb', line 52 def rakefile( bucket_name = false ) bucket_name ||= guess_bucket_name # TODO: check if Rakefile already exists template( "Rakefile.erb", "Rakefile", :bucket_name => bucket_name ) end |
#setup(app_name = false) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/microstatic/cli.rb', line 11 def setup( app_name = false ) app_name ||= inferred_app_name bucket_name = subdomain_for(app_name) bucket = bucket( bucket_name ) # TODO: pass bucket through to dns setup so we don't have to look it up again dns( app_name ) rakefile( bucket_name ) end |