codegears 0.0.8.pre → 0.0.9.pre

Sign up to get free protection for your applications and to get access to all the features.
data/codegears.gemspec CHANGED
@@ -1,8 +1,7 @@
1
1
  # coding: utf-8
2
2
  $:.unshift File.expand_path("../lib/", __FILE__)
3
3
 
4
- require "cg/version"
5
- require "cg/app"
4
+ require "cg"
6
5
 
7
6
  Gem::Specification.new do |gem|
8
7
  gem.name = "codegears"
data/lib/cg/api.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "httparty"
2
+
3
+ module CG
4
+ class API
5
+ include HTTParty
6
+
7
+ def self.create_request(email)
8
+ self.post("http://localhost:3000/apps", :body => { :application => { :email => email } })
9
+ end
10
+ end
11
+ end
data/lib/cg/app.rb ADDED
@@ -0,0 +1,13 @@
1
+ require "singleton"
2
+
3
+ module CG
4
+ class APP
5
+ include Singleton
6
+
7
+ attr_accessor :secret_id, :secret_token, :id
8
+
9
+ def self.configure
10
+ yield(self.instance)
11
+ end
12
+ end
13
+ end
@@ -1,14 +1,10 @@
1
- require "httparty"
1
+ require "cg/api"
2
2
  require "colorize"
3
3
 
4
4
  module Command
5
5
  class App
6
- include HTTParty
7
-
8
- URL = "http://localhost:3000/apps"
9
-
10
- def self.create!(email = "")
11
- response = self.post(URL, :body => { :application => { :email => email } })
6
+ def self.create(email = "")
7
+ response = CG::API.create_request(email)
12
8
  if response["success"] == false
13
9
  response["errors"].each do |k,v|
14
10
  puts "#{k.capitalize} #{v.first}\n".red
@@ -16,9 +12,11 @@ module Command
16
12
  else
17
13
  puts "Application successfully created.\n".green
18
14
  puts "Add the following lines to the file config/initializers/codegears.rb:\n".green
19
- puts " CG::App.id(\"#{response['id']}\")".green
20
- puts " CG::App.secret_id(\"#{response['secret_id']}\")".green
21
- puts " CG::App.secret_token(\"#{response['secret_token']}\")\n".green
15
+ puts "CG::App.configure do |instance|".green
16
+ puts " instance.id = \"#{response['id']}\"".green
17
+ puts " instance.secret_id = \"#{response['secret_id']}\"".green
18
+ puts " instance.secret_token = \"#{response['secret_token']}\"\n".green
19
+ puts "end\n"
22
20
  puts "And restart application to start using the CodeGears platform.\n".green
23
21
  end
24
22
  end
data/lib/cg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CG
2
- VERSION = "0.0.8.pre"
2
+ VERSION = "0.0.9.pre"
3
3
  end
data/lib/cg.rb CHANGED
@@ -1,5 +1,9 @@
1
+ require "rails"
1
2
  require "cg/version"
2
3
  require "cg/app"
3
4
 
4
5
  module CG
6
+ class Engine < Rails::Engine
7
+
8
+ end
5
9
  end
@@ -0,0 +1,30 @@
1
+ require "cg/api"
2
+
3
+ module Cg
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ desc "This generator installs CodeGears configuration in config/initializers/codegears.rb"
8
+
9
+ argument :email, :type => :string, :default => ""
10
+
11
+ def create_config_file
12
+ init_settings
13
+ template "config.rb.template", "config/initializers/codegears.rb"
14
+ end
15
+
16
+ private
17
+
18
+ def init_settings
19
+ unless email.blank?
20
+ response = CG::API.create_request(email)
21
+ unless response["success"] == false
22
+ @id = response["id"]
23
+ @secret_id = response["secret_id"]
24
+ @secret_token = response["secret_token"]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ CG::APP.configure do |instance|
2
+ instance.id = "<%= @id %>"
3
+ instance.secret_id = "<%= @secret_id %>"
4
+ instance.secret_token = "<%= @secret_token %>"
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codegears
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8.pre
4
+ version: 0.0.9.pre
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -91,11 +91,15 @@ files:
91
91
  - bin/cg
92
92
  - codegears.gemspec
93
93
  - lib/cg.rb
94
+ - lib/cg/api.rb
95
+ - lib/cg/app.rb
94
96
  - lib/cg/cli.rb
95
97
  - lib/cg/command.rb
96
98
  - lib/cg/command/app.rb
97
99
  - lib/cg/pusher.rb
98
100
  - lib/cg/version.rb
101
+ - lib/generators/cg/install/install_generator.rb
102
+ - lib/generators/cg/install/templates/config.rb.template
99
103
  homepage: https://github.com/Semjonow/codegears
100
104
  licenses:
101
105
  - MIT