stastic 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/stastic.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Stastic
2
2
 
3
- VERSION = "0.2.6"
3
+ VERSION = "0.2.7"
4
4
 
5
5
  end
@@ -44,12 +44,13 @@ module Stastic
44
44
  request(:delete, "/sites/#{site_id}/domains/#{domain_name}")
45
45
  end
46
46
 
47
- def initialize(host = "https://stastic.com")
47
+ def initialize
48
48
  if Stastic::Config.exists?
49
49
  self.user = Stastic::Config.user
50
50
  self.token = Stastic::Config.token
51
+ self.host = Stastic::Config.host
51
52
  end
52
- self.host = host
53
+ self.host ||= "https://stastic.com"
53
54
  end
54
55
 
55
56
  def request(method, uri, payload = nil, headers = {})
@@ -50,6 +50,17 @@ module Stastic::Command
50
50
  return password
51
51
  end
52
52
 
53
+ def print_error_and_exit(e)
54
+ puts "Error."
55
+ puts "There was an error with the request:"
56
+ puts
57
+ JSON.parse(e.response)['errors'].each do |msg|
58
+ printf(" * %s\n", msg)
59
+ end
60
+ puts
61
+ exit -1
62
+ end
63
+
53
64
  def with_valid_user
54
65
  request_credentials unless Stastic::Config.credentials?
55
66
  begin
@@ -58,13 +69,7 @@ module Stastic::Command
58
69
  request_credentials
59
70
  retry
60
71
  rescue RestClient::UnprocessableEntity => e
61
- puts "There was an error with the request:"
62
- puts
63
- JSON.parse(e.response)['errors'].each do |msg|
64
- printf(" * %s\n", msg)
65
- end
66
- puts
67
- exit -1
72
+ print_error_and_exit(e)
68
73
  end
69
74
  end
70
75
 
@@ -77,10 +82,7 @@ module Stastic::Command
77
82
  request_credentials
78
83
  retry
79
84
  rescue RestClient::UnprocessableEntity => e
80
- puts "Error:"
81
- puts e.response.to_s
82
- puts
83
- exit
85
+ print_error_and_exit(e)
84
86
  end
85
87
  end
86
88
 
@@ -89,7 +91,7 @@ module Stastic::Command
89
91
  puts
90
92
  puts " stastic create"
91
93
  puts
92
- exit
94
+ exit -1
93
95
  end
94
96
 
95
97
  def print_site_info(site, marker = " ")
@@ -27,6 +27,7 @@ module Stastic::Command
27
27
  end
28
28
 
29
29
  def index
30
+ print "Creating site... "
30
31
  if template
31
32
  copy_template("#{File.dirname(__FILE__)}/../../../templates/#{template}/")
32
33
  end
@@ -41,7 +42,8 @@ module Stastic::Command
41
42
 
42
43
  if response["name"]
43
44
  Stastic::Config.add(:name => response["name"])
44
- print "Your site has been created!\n\n"
45
+ print "Success!\n"
46
+ print "Your site has been created.\n\n"
45
47
  print " Site Name: #{Stastic::Config.name}\n"
46
48
  print " Site URL: #{Stastic::Config.name}.stastic.com\n\n"
47
49
  print "Use `stastic publish` to publish your site whenever you're ready.\n"
@@ -18,6 +18,8 @@ module Stastic::Command
18
18
  end
19
19
  Stastic::Config.update(:name => response["name"])
20
20
  puts "Success\n"
21
+ print " Site Name: #{Stastic::Config.name}\n"
22
+ print " Site URL: #{Stastic::Config.name}.stastic.com\n\n"
21
23
  end
22
24
 
23
25
  end
@@ -4,7 +4,7 @@ module Stastic
4
4
  module Config
5
5
  extend self
6
6
 
7
- VALID_SETTINGS = %w(user token name site_id site_root)
7
+ VALID_SETTINGS = %w(user token name site_id site_root host)
8
8
  def exists?
9
9
  File.exists?(config_path) || File.exists?(global_path)
10
10
  end
@@ -30,7 +30,7 @@ module Stastic
30
30
 
31
31
  def package(dir)
32
32
  tmpfile = Tempfile.new('st-archive')
33
- system "cd #{dir} && tar -cjf #{tmpfile.path} -X #{exclude_file(dir)} . "
33
+ system "cd \"#{dir}\" && tar -cjf \"#{tmpfile.path}\" -X #{exclude_file(dir)} . "
34
34
  tmpfile.path
35
35
  end
36
36
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 6
9
- version: 0.2.6
8
+ - 7
9
+ version: 0.2.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brian Smith
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-09 00:00:00 -08:00
17
+ date: 2011-03-30 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency