siteleaf 0.9.14 → 0.9.15

Sign up to get free protection for your applications and to get access to all the features.
data/bin/siteleaf CHANGED
@@ -141,7 +141,7 @@ def put_theme_assets(site_id)
141
141
  print '(y/n)? '
142
142
  if $stdin.gets.chomp == 'y'
143
143
  missing_assets.each do |asset|
144
- print "Deleteing #{asset.filename}..."
144
+ print "Deleting #{asset.filename}..."
145
145
  asset.delete
146
146
  print "complete.\n"
147
147
  end
@@ -1,36 +1,42 @@
1
1
  require 'httmultiparty'
2
2
 
3
3
  module Siteleaf
4
- class Client
4
+ class Client
5
5
  def self.auth(email, password)
6
6
  begin
7
- request = HTTParty.post(Siteleaf.api_url('auth'), {:basic_auth => {:username => email, :password => password}})
7
+ request = HTTParty.post(Siteleaf.api_url('auth'), {
8
+ :basic_auth => {:username => email, :password => password}
9
+ })
8
10
  return request.parsed_response # parse JSON
9
11
  rescue => e
10
12
  return e.inspect # error
11
13
  end
12
14
  end
13
-
15
+
14
16
  def self.get(path, params = nil)
15
17
  self.execute(:get, path, params)
16
18
  end
17
-
19
+
18
20
  def self.post(path, params)
19
21
  self.execute(:post, path, params)
20
22
  end
21
-
23
+
22
24
  def self.put(path, params)
23
25
  self.execute(:put, path, params)
24
26
  end
25
-
27
+
26
28
  def self.delete(path, params = nil)
27
29
  self.execute(:delete, path, params)
28
30
  end
29
-
31
+
30
32
  def self.execute(method, path, params = nil)
31
33
  Siteleaf.load_settings if !Siteleaf.api_key
32
34
  begin
33
- request = HTTMultiParty.send(method, Siteleaf.api_url(path), {:query => params, :basic_auth => {:username => Siteleaf.api_key, :password => Siteleaf.api_secret}})
35
+ request = HTTMultiParty.send(method, Siteleaf.api_url(path), {
36
+ :query => params,
37
+ :basic_auth => {:username => Siteleaf.api_key, :password => Siteleaf.api_secret},
38
+ :timeout => 300
39
+ })
34
40
  if request.respond_to?('parsed_response')
35
41
  return request.parsed_response # parse JSON
36
42
  else
@@ -41,4 +47,4 @@ module Siteleaf
41
47
  end
42
48
  end
43
49
  end
44
- end
50
+ end
@@ -1,24 +1,24 @@
1
1
  module Siteleaf
2
2
  class Entity
3
-
3
+
4
4
  def initialize(attributes = {})
5
- self.attributes = attributes
5
+ self.attributes = attributes
6
6
  end
7
-
7
+
8
8
  def self.all
9
9
  result = Client.get "#{self.endpoint}"
10
10
  result.map { |r| self.new(r) } if result
11
11
  end
12
-
12
+
13
13
  def self.find(id)
14
14
  result = Client.get "#{self.endpoint}/#{id}"
15
15
  self.new(result) if result
16
16
  end
17
-
17
+
18
18
  def self.create(attributes = {})
19
19
  self.new(attributes).save
20
20
  end
21
-
21
+
22
22
  def save
23
23
  if self.id
24
24
  result = Client.put "#{self.class.endpoint}/#{self.id}", self.attributes
@@ -30,34 +30,34 @@ module Siteleaf
30
30
  return self
31
31
  end
32
32
  end
33
-
33
+
34
34
  def self.delete(id)
35
35
  Client.delete "#{self.endpoint}/#{id}"
36
36
  end
37
-
37
+
38
38
  def delete
39
39
  Client.delete "#{self.class.endpoint}/#{self.id}"
40
40
  end
41
-
41
+
42
42
  def attributes
43
43
  Hash[self.instance_variables.map { |name| [name[1..-1], self.instance_variable_get(name)] }]
44
44
  end
45
-
45
+
46
46
  def attributes=(attributes = {})
47
47
  attributes.each_pair { |k, v| self.instance_variable_set("@#{k}", v) }
48
48
  end
49
-
49
+
50
50
  def self.class_name
51
51
  self.name.split('::')[-1]
52
52
  end
53
-
53
+
54
54
  def self.endpoint
55
55
  "#{self.class_name.downcase}s"
56
56
  end
57
-
57
+
58
58
  def create_endpoint
59
59
  self.class.endpoint
60
60
  end
61
-
61
+
62
62
  end
63
- end
63
+ end
@@ -1,3 +1,3 @@
1
1
  module Siteleaf
2
- VERSION = "0.9.14"
2
+ VERSION = "0.9.15"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siteleaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.14
4
+ version: 0.9.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-09 00:00:00.000000000 Z
12
+ date: 2013-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty