kalipso 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.1.7
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
3
  require 'kalipso'
4
+ require 'kalipso/cli_init'
4
5
  require 'kalipso/cli'
5
-
6
6
  Kalipso::CLI.start
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kalipso}
8
- s.version = "0.1.6"
8
+ s.version = "0.1.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Campbell"]
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "kalipso.gemspec",
31
31
  "lib/kalipso.rb",
32
32
  "lib/kalipso/cli.rb",
33
+ "lib/kalipso/cli_init.rb",
33
34
  "lib/kalipso/public_key.rb",
34
35
  "lib/kalipso/site.rb"
35
36
  ]
@@ -13,37 +13,4 @@ require 'pathname'
13
13
 
14
14
  # models
15
15
  require 'kalipso/site'
16
- require 'kalipso/public_key'
17
-
18
- # app
19
- Dir[File.expand_path('app/*/*.rb', __FILE__)].each do |file|
20
- require file
21
- end
22
-
23
- Jaysus::Local.store_dir = File.expand_path("~/.kalipso")
24
- Jaysus::Local.store_dir.mkpath unless Jaysus::Local.store_dir.exist?
25
-
26
- token_path = Jaysus::Local.store_dir.join('token')
27
-
28
- if token_path.exist?
29
- token = token_path.read
30
- else
31
- email = ask("Enter your email: ") { |q| q.echo = true }
32
- password = ask("Enter your password: ") { |q| q.echo = "*" }
33
- token = ActiveSupport::JSON.decode(RestClient.get("http://#{CGI.escape(email)}:#{CGI.escape(password)}@oncalypso.com/api/v1/users.json"))['token']
34
- token_path.open('w') do |file|
35
- file.write token
36
- end
37
- end
38
-
39
- Jaysus::Remote.base_url = "http://#{token}:x@oncalypso.com/api/v1"
40
-
41
- if !Jaysus::Local.store_dir.join('keys').exist?
42
- key_dir = Jaysus::Local.store_dir.join('keys')
43
- key_dir.mkpath unless key_dir.exist?
44
- key_path = key_dir.join('id_rsa')
45
- public_key_path = key_dir.join('id_rsa.pub')
46
- puts "generating and uploading public key"
47
- `ssh-keygen -N '' -t rsa -q -f #{key_path.to_s.strip}`
48
- Kalipso::PublicKey::Remote.create(:key => public_key_path.read)
49
- end
16
+ require 'kalipso/public_key'
@@ -1,16 +1,37 @@
1
1
  module Kalipso
2
2
  class CLI < Thor
3
3
 
4
+ desc "path", "print linked path for a site"
5
+ def path(name)
6
+ site = Site::Local.find_by_name(name)
7
+ if site.present?
8
+ if site.path.present?
9
+ puts site.path
10
+ else
11
+ puts "Path not present. You need to link this site to a path."
12
+ end
13
+ else
14
+ puts "Could not find site #{name}"
15
+ end
16
+ end
17
+
4
18
  desc "create", "add a site"
5
- def create(name = nil)
6
- path = Dir.pwd
19
+ def create(name = nil, path = nil)
7
20
  if name.present?
8
- puts "Creating #{name} linked to #{path}"
21
+ puts "Creating #{name}"
9
22
  else
10
- puts "Creating a new site linked to #{path}"
23
+ puts "Creating a new site"
11
24
  end
12
25
  begin
13
- Site::Remote.create(:name => name)
26
+ remote_site = Site::Remote.create(:name => name)
27
+ path = path || File.expand_path("~/Sites/oncalypso/#{remote_site.name}")
28
+ Site::Local.create({
29
+ :name => remote_site.name,
30
+ :id => remote_site.id,
31
+ :path => path
32
+ })
33
+ Pathname.new(path).mkpath unless Pathname.new(path).exist?
34
+ puts "Site #{remote_site.name} site created and linked to #{path}"
14
35
 
15
36
  rescue RestClient::UnprocessableEntity
16
37
  puts "There was an error uploading your site"
@@ -32,6 +53,20 @@ module Kalipso
32
53
  end
33
54
  end
34
55
 
56
+ desc "open", "open a site in browser"
57
+ def open(site = nil)
58
+ if site.present?
59
+ site = Site::Local.find_by_name(site)
60
+ else
61
+ site = Site::Local.find_by_path(Dir.pwd)
62
+ end
63
+ if site.present?
64
+ `open http://#{site.name}.oncalypso.com`
65
+ else
66
+ puts "Could not find site"
67
+ end
68
+ end
69
+
35
70
  desc "link", "link a local path to a site"
36
71
  def link(site, path = nil)
37
72
  site = Site::Local.find_by_name(site)
@@ -76,7 +111,9 @@ module Kalipso
76
111
  path = File.expand_path("~/Sites/oncalypso/#{name}")
77
112
  pathname = Pathname.new(path)
78
113
  pathname.mkpath unless pathname.exist?
79
- local_site.update_attributes(site.attributes.merge(:path => path))
114
+ local_site.name = site.name
115
+ local_site.path = path
116
+ local_site.save
80
117
  `rsync -arvH -e "ssh -i #{Jaysus::Local.store_dir.join('keys', 'id_rsa')}" sites@diddlydum.com:/home/sites/#{site.name}/ #{path.gsub(/\/+$/, '')}/`
81
118
  puts "Site #{name} downloaded to #{path.gsub(/\/+$/, '')}"
82
119
  else
@@ -108,5 +145,10 @@ module Kalipso
108
145
  puts "site not found with path #{path}"
109
146
  end
110
147
  end
148
+
149
+ desc "version", "print the version of the kalipso gem"
150
+ def version
151
+ puts File.read(File.expand_path('../../../VERSION', __FILE__))
152
+ end
111
153
  end
112
154
  end
@@ -0,0 +1,27 @@
1
+ Jaysus::Local.store_dir = File.expand_path("~/.kalipso")
2
+ Jaysus::Local.store_dir.mkpath unless Jaysus::Local.store_dir.exist?
3
+
4
+ token_path = Jaysus::Local.store_dir.join('token')
5
+
6
+ if token_path.exist?
7
+ token = token_path.read
8
+ else
9
+ email = ask("Enter your email: ") { |q| q.echo = true }
10
+ password = ask("Enter your password: ") { |q| q.echo = "*" }
11
+ token = ActiveSupport::JSON.decode(RestClient.get("http://#{CGI.escape(email)}:#{CGI.escape(password)}@oncalypso.com/api/v1/users.json"))['token']
12
+ token_path.open('w') do |file|
13
+ file.write token
14
+ end
15
+ end
16
+
17
+ Jaysus::Remote.base_url = "http://#{token}:x@oncalypso.com/api/v1"
18
+
19
+ if !Jaysus::Local.store_dir.join('keys').exist?
20
+ key_dir = Jaysus::Local.store_dir.join('keys')
21
+ key_dir.mkpath unless key_dir.exist?
22
+ key_path = key_dir.join('id_rsa')
23
+ public_key_path = key_dir.join('id_rsa.pub')
24
+ puts "generating and uploading public key"
25
+ `ssh-keygen -N '' -t rsa -q -f #{key_path.to_s.strip}`
26
+ Kalipso::PublicKey::Remote.create(:key => public_key_path.read)
27
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kalipso
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 6
10
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Campbell
@@ -191,6 +191,7 @@ files:
191
191
  - kalipso.gemspec
192
192
  - lib/kalipso.rb
193
193
  - lib/kalipso/cli.rb
194
+ - lib/kalipso/cli_init.rb
194
195
  - lib/kalipso/public_key.rb
195
196
  - lib/kalipso/site.rb
196
197
  - spec/kalipso_spec.rb