siteleaf 0.8.1 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/siteleaf CHANGED
@@ -18,15 +18,15 @@ def auth(re_auth = false)
18
18
  password = $stdin.gets.chomp
19
19
  system 'stty echo'
20
20
 
21
- print "\nAuthorizing...\n"
21
+ puts "Authorizing..."
22
22
 
23
- if auth = Siteleaf::Client.auth(email, password) and auth.has_key?('api_key')
23
+ if auth = Siteleaf::Client.auth(email, password) and auth.is_a?(Hash) and auth.has_key?('api_key')
24
24
  File.open(Siteleaf.settings_file,'w') do|file|
25
25
  Marshal.dump({:api_key => auth['api_key'], :api_secret => auth['api_secret']}, file)
26
26
  end
27
- print "=> Gem authorized.\n" if re_auth
27
+ puts "=> Gem authorized." if re_auth
28
28
  else
29
- print "Could not authorize, check your e-mail or password.\n"
29
+ puts "Could not authorize, check your e-mail or password."
30
30
  end
31
31
  end
32
32
  end
@@ -36,14 +36,14 @@ def config(site)
36
36
  # See https://github.com/siteleaf/siteleaf-gem for documentation.
37
37
 
38
38
  require 'siteleaf'
39
- run Siteleaf::Server.new(site_id:'#{site.id}')" }
39
+ run Siteleaf::Server.new(:site_id => '#{site.id}')" }
40
40
 
41
41
  pow_path = "#{Etc.getpwuid.dir}/.pow"
42
- if Dir.exists?(pow_path)
42
+ if File.directory?(pow_path)
43
43
  site_no_tld = site.domain.gsub(/\.[a-z]{0,4}$/i,'')
44
44
  site_symlink = "#{pow_path}/#{site_no_tld}"
45
45
  FileUtils.rm(site_symlink) if File.symlink?(site_symlink)
46
- FileUtils.symlink(File.absolute_path("."), site_symlink)
46
+ FileUtils.symlink(File.dirname(__FILE__), site_symlink)
47
47
  puts "=> Site configured with Pow, open `http://#{site_no_tld}.dev` to test site locally.\n"
48
48
  else
49
49
  puts "=> Site configured, run `siteleaf server` to test site locally.\n"
@@ -56,7 +56,7 @@ when '-v', '--version'
56
56
  when '-h', '--help'
57
57
  puts help
58
58
  when 's', 'server'
59
- if File.exists?('config.ru')
59
+ if File.exist?('config.ru')
60
60
  `rackup config.ru`
61
61
  else
62
62
  puts "No config found, run `siteleaf config yoursite.com`.\n"
@@ -74,7 +74,7 @@ when 'n', 'new'
74
74
  auth
75
75
  if site = Siteleaf::Site.create(:title => ARGV[1], :domain => ARGV[1])
76
76
  dir = ARGV.size >= 3 ? ARGV[2] : ARGV[1]
77
- Dir.mkdir(dir) unless Dir.exists?(dir)
77
+ Dir.mkdir(dir) unless File.directory?(dir)
78
78
  Dir.chdir(dir)
79
79
  config site
80
80
  else
@@ -32,16 +32,16 @@ module Siteleaf
32
32
  def self.execute(method, path, payload = nil, params = nil)
33
33
  Siteleaf.load_settings if !Siteleaf.api_key
34
34
  request = RestClient::Request.new(:url => Siteleaf.api_url(path), :method => method, :payload => payload, :headers => { :params => params }, :user => Siteleaf.api_key, :password => Siteleaf.api_secret)
35
- begin
35
+ #begin
36
36
  response = request.execute
37
37
  if response.headers[:content_type].to_s.include?('json')
38
38
  return JSON.parse(response) # parse JSON
39
39
  else
40
40
  return response # raw
41
41
  end
42
- rescue => e
43
- return e.inspect # error
44
- end
42
+ #rescue => e
43
+ # return e.inspect # error
44
+ #end
45
45
  end
46
46
  end
47
47
  end
@@ -44,7 +44,7 @@ module Siteleaf
44
44
  end
45
45
 
46
46
  def attributes=(attributes = {})
47
- attributes.each_pair { |k, v| k != "attributes" and respond_to?(name = "#{k}=") and send(name, v) }
47
+ attributes.each_pair { |k, v| k != "attributes" and self.instance_variable_set("@#{k}", v) }
48
48
  end
49
49
 
50
50
  def self.class_name
data/lib/siteleaf/meta.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Siteleaf
2
2
  class Meta < Entity
3
3
 
4
- attr_accessor :id, :key, :value, :page_id, :post_id
5
- protected :id=
4
+ attr_accessor :key, :value, :page_id, :post_id
5
+ attr_reader :id
6
6
 
7
7
  def create_endpoint
8
8
  if self.page_id
data/lib/siteleaf/page.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Siteleaf
2
2
  class Page < Entity
3
3
 
4
- attr_accessor :id, :title, :body, :slug, :url, :parent_id, :site_id, :published_at, :created_at, :updated_at, :meta
5
- protected :id=, :created_at=, :updated_at=
4
+ attr_accessor :title, :body, :slug, :url, :parent_id, :site_id, :published_at, :meta
5
+ attr_reader :id, :created_at, :updated_at
6
6
 
7
7
  def create_endpoint
8
8
  "sites/#{self.site_id}/pages"
@@ -1,5 +1,6 @@
1
1
  module Siteleaf
2
2
  class Server
3
+
3
4
  attr_accessor :site_id
4
5
 
5
6
  def initialize(attributes = {})
@@ -25,7 +26,7 @@ module Siteleaf
25
26
  templates.push("default.html")
26
27
 
27
28
  templates.each do |t|
28
- return File.read(t) if File.exists?(t)
29
+ return File.read(t) if File.exist?(t)
29
30
  end
30
31
 
31
32
  return nil
@@ -37,7 +38,7 @@ module Siteleaf
37
38
  url = env['PATH_INFO']
38
39
  path = url.gsub(/\/\z|\A\//, '') #strip beginning and trailing slashes
39
40
 
40
- if !File.directory?(path) and File.exists?(path)
41
+ if !File.directory?(path) and File.exist?(path)
41
42
  Rack::File.new(Dir.pwd).call(env)
42
43
  else
43
44
  template_data = nil
data/lib/siteleaf/site.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Siteleaf
2
2
  class Site < Entity
3
3
 
4
- attr_accessor :id, :title, :domain, :timezone, :user_id, :created_at, :updated_at
5
- protected :id=, :user_id=, :created_at=, :updated_at=
4
+ attr_accessor :title, :domain, :timezone
5
+ attr_reader :id, :user_id, :created_at, :updated_at
6
6
 
7
7
  def self.find_by_domain(domain)
8
8
  result = Client.get "sites", {"domain" => domain}
data/lib/siteleaf/user.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Siteleaf
2
2
  class User < Entity
3
3
 
4
- attr_accessor :id, :email, :firstname, :lastname, :created_at, :updated_at
5
- protected :id=, :created_at=, :updated_at=
4
+ attr_accessor :email, :firstname, :lastname
5
+ attr_reader :id, :created_at, :updated_at
6
6
 
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Siteleaf
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.3"
3
3
  end
data/lib/siteleaf.rb CHANGED
@@ -28,7 +28,7 @@ module Siteleaf
28
28
  end
29
29
 
30
30
  def self.load_settings
31
- if File.exists?(self.settings_file)
31
+ if File.exist?(self.settings_file)
32
32
  config = File.open(self.settings_file) do|file|
33
33
  Marshal.load(file)
34
34
  end
data/siteleaf.gemspec CHANGED
@@ -12,11 +12,11 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = "Siteleaf Ruby interface"
13
13
  gem.homepage = "http://siteleaf.com"
14
14
 
15
- # gem.required_ruby_version = '>= 1.9.2'
15
+ gem.required_ruby_version = '>= 1.8'
16
16
 
17
17
  gem.add_dependency 'rest-client'
18
18
  gem.add_dependency 'json'
19
- # gem.add_dependency 'liquid'
19
+ gem.add_dependency 'rack'
20
20
 
21
21
  gem.files = `git ls-files`.split($/)
22
22
  gem.files += Dir.glob("lib/**/*.rb")
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.8.1
4
+ version: 0.8.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rack
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
46
62
  description: A Ruby interface and command line utility for the Siteleaf API.
47
63
  email:
48
64
  - api@siteleaf.com
@@ -79,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
95
  requirements:
80
96
  - - ! '>='
81
97
  - !ruby/object:Gem::Version
82
- version: '0'
98
+ version: '1.8'
83
99
  required_rubygems_version: !ruby/object:Gem::Requirement
84
100
  none: false
85
101
  requirements: