codegears 0.0.1 → 0.0.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cg +5 -1
- data/codegears.gemspec +5 -5
- data/lib/cg/command/app.rb +2 -30
- data/lib/cg/command.rb +1 -11
- data/lib/cg/version.rb +1 -1
- data/lib/cg.rb +0 -5
- metadata +6 -27
- data/lib/cg/api.rb +0 -32
- data/lib/cg/app.rb +0 -83
- data/lib/cg/command/version.rb +0 -9
- data/lib/generators/cg/install/install_generator.rb +0 -32
- data/lib/generators/cg/install/templates/config.rb.template +0 -7
data/bin/cg
CHANGED
data/codegears.gemspec
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
3
4
|
|
4
|
-
require "cg"
|
5
|
+
require "cg/version"
|
5
6
|
|
6
7
|
Gem::Specification.new do |gem|
|
7
8
|
gem.name = "codegears"
|
@@ -10,9 +11,9 @@ Gem::Specification.new do |gem|
|
|
10
11
|
gem.email = ["js@codegears.co"]
|
11
12
|
gem.description = %q{Client library and CLI to manage apps on CodeGears}
|
12
13
|
gem.summary = %q{Client library and command-line tool to manage apps on CodeGears}
|
13
|
-
gem.homepage = "https://github.com/
|
14
|
+
gem.homepage = "https://github.com/Semjonow/codegears"
|
14
15
|
gem.license = "MIT"
|
15
|
-
gem.executables
|
16
|
+
gem.executables = ["cg"]
|
16
17
|
gem.default_executable = "cg"
|
17
18
|
|
18
19
|
gem.files = %x{ git ls-files }.split("\n").select { |d| d =~ %r{^(LICENSE|README|bin/|lib/|)} }
|
@@ -20,5 +21,4 @@ Gem::Specification.new do |gem|
|
|
20
21
|
gem.add_dependency "rails"
|
21
22
|
gem.add_dependency "jquery-rails"
|
22
23
|
gem.add_dependency "httparty"
|
23
|
-
gem.add_dependency "colorize"
|
24
24
|
end
|
data/lib/cg/command/app.rb
CHANGED
@@ -1,35 +1,7 @@
|
|
1
|
-
require "cg/api"
|
2
|
-
require "colorize"
|
3
|
-
|
4
1
|
module Command
|
5
2
|
class App
|
6
|
-
def self.create
|
7
|
-
|
8
|
-
if response["success"] == false
|
9
|
-
response["errors"].each do |k,v|
|
10
|
-
puts "#{k.capitalize} #{v.first}\n".red
|
11
|
-
end
|
12
|
-
else
|
13
|
-
puts "Application successfully created.".green
|
14
|
-
puts "Add the following lines to the file config/initializers/codegears.rb:\n".green
|
15
|
-
puts "require \"cg\"\n".green
|
16
|
-
puts "CG::App.configure do |instance|".green
|
17
|
-
puts " instance.id = \"#{response['id']}\"".green
|
18
|
-
puts " instance.secret_id = \"#{response['secret_id']}\"".green
|
19
|
-
puts " instance.secret_token = \"#{response['secret_token']}\"\n".green
|
20
|
-
puts "end\n".green
|
21
|
-
puts "And restart application to start using the CodeGears platform.".green
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.status(id = "")
|
26
|
-
response = CG::API.show_app_request(id)
|
27
|
-
if response["success"] == false
|
28
|
-
puts "Application not found".red
|
29
|
-
else
|
30
|
-
status = response["active"]
|
31
|
-
puts "Active: #{status}".send(status ? :green : :red)
|
32
|
-
end
|
3
|
+
def self.create!
|
4
|
+
puts "ok"
|
33
5
|
end
|
34
6
|
end
|
35
7
|
end
|
data/lib/cg/command.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "cg/version"
|
2
|
-
|
3
1
|
module CG
|
4
2
|
class Command
|
5
3
|
def initialize(*args)
|
@@ -11,15 +9,7 @@ module CG
|
|
11
9
|
namespace = Kernel.const_get("Command").const_get(namespace) rescue nil
|
12
10
|
task = args.shift.downcase rescue nil
|
13
11
|
|
14
|
-
|
15
|
-
if task
|
16
|
-
namespace.send(task, *args)
|
17
|
-
else
|
18
|
-
namespace.send("main", *args)
|
19
|
-
end
|
20
|
-
else
|
21
|
-
puts CG::VERSION
|
22
|
-
end
|
12
|
+
namespace.send(task, *args)
|
23
13
|
end
|
24
14
|
end
|
25
15
|
end
|
data/lib/cg/version.rb
CHANGED
data/lib/cg.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codegears
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Juri Semjonov
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -59,22 +59,6 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: colorize
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :runtime
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
62
|
description: Client library and CLI to manage apps on CodeGears
|
79
63
|
email:
|
80
64
|
- js@codegears.co
|
@@ -91,17 +75,12 @@ files:
|
|
91
75
|
- bin/cg
|
92
76
|
- codegears.gemspec
|
93
77
|
- lib/cg.rb
|
94
|
-
- lib/cg/api.rb
|
95
|
-
- lib/cg/app.rb
|
96
78
|
- lib/cg/cli.rb
|
97
79
|
- lib/cg/command.rb
|
98
80
|
- lib/cg/command/app.rb
|
99
|
-
- lib/cg/command/version.rb
|
100
81
|
- lib/cg/pusher.rb
|
101
82
|
- lib/cg/version.rb
|
102
|
-
|
103
|
-
- lib/generators/cg/install/templates/config.rb.template
|
104
|
-
homepage: https://github.com/code-gears/codegears
|
83
|
+
homepage: https://github.com/Semjonow/codegears
|
105
84
|
licenses:
|
106
85
|
- MIT
|
107
86
|
post_install_message:
|
@@ -117,9 +96,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
97
|
none: false
|
119
98
|
requirements:
|
120
|
-
- - ! '
|
99
|
+
- - ! '>'
|
121
100
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
101
|
+
version: 1.3.1
|
123
102
|
requirements: []
|
124
103
|
rubyforge_project:
|
125
104
|
rubygems_version: 1.8.23
|
data/lib/cg/api.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require "httparty"
|
2
|
-
|
3
|
-
module CG
|
4
|
-
class API
|
5
|
-
include HTTParty
|
6
|
-
ROOT_URL = "http://api.codegears.co"
|
7
|
-
PUSHER_URL = "#{ROOT_URL}:9292/stream"
|
8
|
-
|
9
|
-
def self.create_app_request(email)
|
10
|
-
JSON.parse(self.post("#{ROOT_URL}/apps", :body => { :application => { :email => email } }).body)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.show_app_request(id, secret_id = nil, secret_token = nil)
|
14
|
-
JSON.parse(self.get("#{ROOT_URL}/apps/#{id}?#{self.attach_auth(secret_id, secret_token)}").body)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.push_message_request(channel, message)
|
18
|
-
message = { :channel => channel,
|
19
|
-
:message => message,
|
20
|
-
:ext => { :secret_id => CG::APP.secret_id, :secret_token => CG::APP.secret_token } }.to_json
|
21
|
-
JSON.parse(Net::HTTP.post_form(URI.parse(PUSHER_URL), :message => message).body)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.attach_auth(secret_id, secret_token)
|
25
|
-
if secret_id && secret_token
|
26
|
-
"secret_id=#{secret_id}&secret_token=#{secret_token}"
|
27
|
-
else
|
28
|
-
""
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/lib/cg/app.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
require "singleton"
|
2
|
-
require "cg/api"
|
3
|
-
|
4
|
-
module CG
|
5
|
-
class APP
|
6
|
-
include Singleton
|
7
|
-
|
8
|
-
attr_accessor :secret_id, :secret_token, :id, :channel, :message, :sent, :response
|
9
|
-
|
10
|
-
def self.configure
|
11
|
-
yield(self.instance)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.id
|
15
|
-
self.instance.id
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.secret_id
|
19
|
-
self.instance.secret_id
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.secret_token
|
23
|
-
self.instance.secret_token
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.init_message
|
27
|
-
yield(self.instance)
|
28
|
-
self.instance
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.message
|
32
|
-
self.instance.message
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.channel
|
36
|
-
self.instance.channel
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.sent?
|
40
|
-
!!self.instance.sent
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.response
|
44
|
-
self.instance.response
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.push(channel)
|
48
|
-
instance = self.instance
|
49
|
-
|
50
|
-
instance.channel = channel
|
51
|
-
instance.message = yield
|
52
|
-
|
53
|
-
instance.response = CG::API.push_message_request(instance.channel, instance.message)
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.push(channel, message)
|
57
|
-
instance = self.instance
|
58
|
-
|
59
|
-
instance.channel = instance.perform(channel)
|
60
|
-
instance.message = message
|
61
|
-
|
62
|
-
instance.response = CG::API.push_message_request(instance.channel, instance.message)
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.stats
|
66
|
-
instance = self.instance
|
67
|
-
|
68
|
-
CG::API.show_app_request(instance.id, instance.secret_id, instance.secret_token)
|
69
|
-
end
|
70
|
-
|
71
|
-
def channel=(ch)
|
72
|
-
@channel = perform(ch)
|
73
|
-
end
|
74
|
-
|
75
|
-
def push
|
76
|
-
instance.response = CG::API.push_message_request(channel, message)
|
77
|
-
end
|
78
|
-
|
79
|
-
def perform(channel)
|
80
|
-
channel[0] == "/" ? channel : "/#{channel}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
data/lib/cg/command/version.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require "cg/api"
|
2
|
-
require "colorize"
|
3
|
-
|
4
|
-
module Cg
|
5
|
-
module Generators
|
6
|
-
class InstallGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
desc "This generator installs CodeGears configuration in config/initializers/codegears.rb"
|
9
|
-
|
10
|
-
argument :email, :type => :string, :default => ""
|
11
|
-
|
12
|
-
def create_config_file
|
13
|
-
init_settings
|
14
|
-
template "config.rb.template", "config/initializers/codegears.rb"
|
15
|
-
puts "Restart application to start using the CodeGears platform.".green
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def init_settings
|
21
|
-
unless email.blank?
|
22
|
-
response = CG::API.create_app_request(email)
|
23
|
-
unless response["success"] == false
|
24
|
-
@id = response['id']
|
25
|
-
@secret_id = response['secret_id']
|
26
|
-
@secret_token = response['secret_token']
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|