krl 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +21 -0
- data/bin/krl +33 -0
- data/bin/krl-connect +52 -0
- data/bin/views/index.erb +24 -0
- data/bin/views/success.erb +32 -0
- data/lib/apps.rb +14 -0
- data/lib/check.rb +20 -0
- data/lib/checkout.rb +28 -0
- data/lib/commit.rb +15 -0
- data/lib/common.rb +37 -0
- data/lib/create.rb +15 -0
- data/lib/deploy.rb +12 -0
- data/lib/generate.rb +83 -0
- data/lib/help.rb +67 -0
- data/lib/note.rb +13 -0
- data/lib/show.rb +11 -0
- data/lib/test.rb +21 -0
- data/lib/update.rb +12 -0
- data/lib/user.rb +18 -0
- data/lib/versions.rb +17 -0
- metadata +132 -0
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010 Kynetx Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/bin/krl
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
LIB_DIR = File.dirname(__FILE__) + "/../lib/"
|
5
|
+
|
6
|
+
COMMANDS = {
|
7
|
+
"help" => lambda { |args| require LIB_DIR + 'help'; KRL_CMD::Help.go },
|
8
|
+
"apps" => lambda { |args| require LIB_DIR + 'apps'; KRL_CMD::Apps.go },
|
9
|
+
"checkout" => lambda { |args| require LIB_DIR + 'checkout'; KRL_CMD::Checkout.go(args) },
|
10
|
+
"create" => lambda { |args| require LIB_DIR + 'create'; KRL_CMD::Create.go(args) },
|
11
|
+
"update" => lambda { |args| require LIB_DIR + 'update'; KRL_CMD::Update.go(args) },
|
12
|
+
"versions" => lambda { |args| require LIB_DIR + 'versions'; KRL_CMD::Versions.go(args) },
|
13
|
+
"deploy" => lambda { |args| require LIB_DIR + 'deploy'; KRL_CMD::Deploy.go(args) },
|
14
|
+
"commit" => lambda { |args| require LIB_DIR + 'commit'; KRL_CMD::Commit.go },
|
15
|
+
"show" => lambda { |args| require LIB_DIR + 'show'; KRL_CMD::Show.go(args) },
|
16
|
+
"note" => lambda { |args| require LIB_DIR + 'note'; KRL_CMD::Note.go(args) },
|
17
|
+
"check" => lambda { |args| require LIB_DIR + 'check'; KRL_CMD::Check.go },
|
18
|
+
"generate" => lambda { |args| require LIB_DIR + 'generate'; KRL_CMD::Generate.go(args) },
|
19
|
+
"test" => lambda { |args| require LIB_DIR + 'test'; KRL_CMD::Test.go(args) }
|
20
|
+
}
|
21
|
+
|
22
|
+
banner = "Usage: krl <command> <args>\nUse 'krl help' for more information."
|
23
|
+
|
24
|
+
cmd = ARGV.shift
|
25
|
+
if COMMANDS.keys.include? cmd
|
26
|
+
begin
|
27
|
+
COMMANDS[cmd].call(ARGV)
|
28
|
+
rescue Exception => e
|
29
|
+
puts "Error: #{e.message}\n#{e.backtrace.join("\n")}"
|
30
|
+
end
|
31
|
+
else
|
32
|
+
puts banner
|
33
|
+
end
|
data/bin/krl-connect
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "sinatra"
|
5
|
+
require "yaml"
|
6
|
+
require "kynetx_am_api"
|
7
|
+
|
8
|
+
set :environment, :production
|
9
|
+
set :sessions, :false
|
10
|
+
set :logging, :false
|
11
|
+
set :port, 3009
|
12
|
+
|
13
|
+
CONFIG_FILE = ENV["HOME"] + "/.krl/credentials.yml"
|
14
|
+
|
15
|
+
puts "#{"\n"*10}Go to the following url to authorize. Press ctrl+c when finished.\n http://localhost:3009#{"\n"*10}"
|
16
|
+
|
17
|
+
get '/authorize' do
|
18
|
+
rt = YAML::load_file(CONFIG_FILE)
|
19
|
+
api = setup_api(rt.merge({:oauth_verifier => params[:oauth_verifier]}))
|
20
|
+
@oauth_user = api.get_user_info
|
21
|
+
File.open(CONFIG_FILE, "w") {|f| f.print @oauth_user.to_h.to_yaml}
|
22
|
+
erb :success
|
23
|
+
end
|
24
|
+
|
25
|
+
get '/' do
|
26
|
+
FileUtils.mkdir_p ENV["HOME"] + "/.krl" unless File.exist?(CONFIG_FILE)
|
27
|
+
rt = get_request_token
|
28
|
+
config = {}
|
29
|
+
config[:request_token] = rt[:request_token]
|
30
|
+
config[:request_secret] = rt[:request_secret]
|
31
|
+
File.open(CONFIG_FILE, "w") {|f| f.print config.to_yaml}
|
32
|
+
|
33
|
+
@auth_url = rt[:url]
|
34
|
+
|
35
|
+
erb :index
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def get_request_token
|
41
|
+
api = setup_api
|
42
|
+
rt = api.get_request_token
|
43
|
+
return {:request_token => rt.token, :request_secret => rt.secret, :url => api.get_authorize_url}
|
44
|
+
end
|
45
|
+
|
46
|
+
def setup_api(opts={})
|
47
|
+
KynetxAmApi::Oauth.api_server_url = "http://amapi.kynetx.com"
|
48
|
+
KynetxAmApi::Oauth.accounts_server_url = "https://accounts.kynetx.com"
|
49
|
+
KynetxAmApi::Oauth.consumer_key = "1j54YDLUcLW9ERBKalNm"
|
50
|
+
KynetxAmApi::Oauth.consumer_secret = "QiWCbvTpCAejoceV3f6dD8ycifEkSumFAW1VSmwC"
|
51
|
+
return KynetxAmApi::DirectApi.new(opts)
|
52
|
+
end
|
data/bin/views/index.erb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
+
|
8
|
+
<title>KRL Connect</title>
|
9
|
+
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
|
14
|
+
Authenticate the Kynetx Command line Tool!
|
15
|
+
|
16
|
+
<br>
|
17
|
+
|
18
|
+
<a href="<%= @auth_url %>" >Click here to get started!</a>
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
</body>
|
24
|
+
</html>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
+
|
8
|
+
<title>Success</title>
|
9
|
+
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
Welcome, <%= @oauth_user.name %><br>
|
14
|
+
|
15
|
+
A file called <code><%= CONFIG_FILE %></code> was created that holds your credentials. You will now be able to do the following:
|
16
|
+
|
17
|
+
<br><br>
|
18
|
+
|
19
|
+
<strong>View your apps:</strong><br>
|
20
|
+
<code>krl list</code><br>
|
21
|
+
<br>
|
22
|
+
<strong>Check out an app:</strong><br>
|
23
|
+
<code>krl checkout <app id></code><br>
|
24
|
+
<br>
|
25
|
+
<strong>View all options</strong><br>
|
26
|
+
<code>krl help</code><br>
|
27
|
+
<br><br>
|
28
|
+
Have Fun!
|
29
|
+
|
30
|
+
|
31
|
+
</body>
|
32
|
+
</html>
|
data/lib/apps.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Apps
|
3
|
+
def self.go
|
4
|
+
require LIB_DIR + 'user'
|
5
|
+
require LIB_DIR + 'common'
|
6
|
+
user = User.new
|
7
|
+
KRL_COMMON::pretty_table(user.applications["apps"], [
|
8
|
+
{:field => "Ruleset ID", :value => lambda { |r| r["appid"] }},
|
9
|
+
{:field => "Name", :value => lambda { |r| r["name"].to_s }},
|
10
|
+
{:field => "Role", :value => lambda { |r| r["role"] }}
|
11
|
+
])
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/check.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Check
|
3
|
+
def self.go
|
4
|
+
require LIB_DIR + 'common'
|
5
|
+
require 'json'
|
6
|
+
app = KRL_COMMON::get_app
|
7
|
+
krl_file = File.join(Dir.pwd, app.application_id + ".krl")
|
8
|
+
raise "Cannot find .krl file." unless File.exists?(krl_file)
|
9
|
+
apiurl = "http://krl.kobj.net/manage/parse/ruleset"
|
10
|
+
apiargs = { "krl" => File.open(krl_file, 'r') { |f| f.read } }
|
11
|
+
validateresponse = Net::HTTP.post_form(URI.parse(apiurl), apiargs).body.to_s
|
12
|
+
jdata = JSON.parse(validateresponse, { :max_nesting => false })
|
13
|
+
if jdata["error"]
|
14
|
+
puts jdata["error"]
|
15
|
+
else
|
16
|
+
puts "OK"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/checkout.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require LIB_DIR + 'user'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module KRL_CMD
|
5
|
+
class Checkout
|
6
|
+
def self.go(args)
|
7
|
+
ruleset_id = args.to_s
|
8
|
+
puts "Checking out: #{ruleset_id}"
|
9
|
+
raise "Please specify a ruleset id." if ruleset_id.empty?
|
10
|
+
root_dir = Dir.pwd + "/#{ruleset_id}"
|
11
|
+
raise "Directory already exists." if File.exists?(root_dir)
|
12
|
+
user = User.new
|
13
|
+
app = user.find_application({:application_id => ruleset_id})
|
14
|
+
|
15
|
+
puts "Creating directory: #{root_dir}"
|
16
|
+
FileUtils.mkdir root_dir
|
17
|
+
app_details = {
|
18
|
+
:name => app.name,
|
19
|
+
:ruleset_id => app.application_id,
|
20
|
+
:role => user.owns_current? ? "owner" : "developer"
|
21
|
+
}
|
22
|
+
File.open(root_dir + "/.app", "w") { |f| f.print(app_details.to_yaml) }
|
23
|
+
File.open(root_dir + "/#{ruleset_id}.krl", "w") { |f| f.print(app.krl) }
|
24
|
+
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/commit.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Commit
|
3
|
+
def self.go
|
4
|
+
require LIB_DIR + 'common'
|
5
|
+
app = KRL_COMMON::get_app
|
6
|
+
krl_file = File.join(Dir.pwd, app.application_id + ".krl")
|
7
|
+
if File.exists?(krl_file)
|
8
|
+
app.krl = File.open(krl_file, 'r') { |f| f.read }
|
9
|
+
else
|
10
|
+
raise "Unable to find file: #{krl_file}"
|
11
|
+
end
|
12
|
+
puts "Committed version #{app.version}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/common.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'terminal-table/import'
|
2
|
+
module KRL_COMMON
|
3
|
+
def self.pretty_table(collection, fields, limit=0)
|
4
|
+
ptable = table do |t|
|
5
|
+
|
6
|
+
t.headings = fields.collect{ |h| h[:field] }
|
7
|
+
counter = 0
|
8
|
+
collection.each do |c|
|
9
|
+
row = []
|
10
|
+
fields.each do |f|
|
11
|
+
row << f[:value].call(c)
|
12
|
+
end
|
13
|
+
t << row
|
14
|
+
counter += 1
|
15
|
+
break if limit > 0 && limit == counter
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
puts ptable
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_app(version="development")
|
23
|
+
require LIB_DIR + "user"
|
24
|
+
begin
|
25
|
+
root_dir = Dir.pwd
|
26
|
+
raise "Please re-checkout your app or make sure you are in the root directory of an app." unless File.exists?(File.join(root_dir, ".app"))
|
27
|
+
config = YAML::load_file(File.join(root_dir, '.app'))
|
28
|
+
user = KRL_CMD::User.new
|
29
|
+
app = user.find_application(:application_id => config[:ruleset_id], :version => version)
|
30
|
+
return app
|
31
|
+
rescue Exception => e
|
32
|
+
raise "Unable to get app information. #{e.message}"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/create.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Create
|
3
|
+
def self.go(args)
|
4
|
+
raise "An application name must be specified" if args.to_s.empty?
|
5
|
+
name = args.first
|
6
|
+
desc = args.last # if description wasn't specified, set it to the name
|
7
|
+
require LIB_DIR + 'user'
|
8
|
+
require LIB_DIR + 'checkout'
|
9
|
+
user = KRL_CMD::User.new
|
10
|
+
new_app = user.create_application(name, desc)
|
11
|
+
KRL_CMD::Checkout.go(new_app.application_id)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/deploy.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Deploy
|
3
|
+
def self.go(args)
|
4
|
+
version = args.to_s.empty? ? "development" : args.to_s.to_i
|
5
|
+
require LIB_DIR + 'common'
|
6
|
+
app = KRL_COMMON::get_app
|
7
|
+
app.production_version = version
|
8
|
+
puts "Deployed version: #{app.production_version}"
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/generate.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'base64'
|
3
|
+
module KRL_CMD
|
4
|
+
class Generate
|
5
|
+
def self.go(args)
|
6
|
+
raise "Please specify an endpoint to generate" if args.to_s.empty?
|
7
|
+
type = args.shift
|
8
|
+
endpoints = {
|
9
|
+
"firefox" => lambda {gen_extension(type, args)},
|
10
|
+
"chrome" => lambda {gen_extension(type, args)},
|
11
|
+
"ie" => lambda {gen_extension(type, args)},
|
12
|
+
"bookmarklet" => lambda {gen_bookmarklet(args)},
|
13
|
+
"infocard" => lambda {gen_infocard(args)}
|
14
|
+
}
|
15
|
+
if endpoints[type]
|
16
|
+
endpoints[type].call
|
17
|
+
else
|
18
|
+
raise "Unknown endpoint specified (#{type})"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.gen_extension(type, args)
|
24
|
+
puts "Generating Extension (#{type.to_s}) #{args.join(', ')}"
|
25
|
+
ext = app.extension(type, args[0] || "", args[1] || "", args[2] || "" )
|
26
|
+
write_file(ext, "prod")
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.gen_bookmarklet(args, env="prod")
|
30
|
+
puts "Generating Bookmarklet (#{env})"
|
31
|
+
bm = ""
|
32
|
+
if args.to_s.empty?
|
33
|
+
bm = app.bookmarklet(env)
|
34
|
+
else
|
35
|
+
bm = app.bookmarklet(env, args.to_s)
|
36
|
+
end
|
37
|
+
bm_file = File.join(get_endpoint_dir(env), env + "_bookmarklet.html")
|
38
|
+
File.open(bm_file, 'w') do |f|
|
39
|
+
f.print("<textarea rows='5' cols='100'>#{bm}</textarea><br><br>")
|
40
|
+
link = env == "prod" ? app.name : env + "_" + app.name
|
41
|
+
f.print("<a href='#{bm}'>#{link}</a>")
|
42
|
+
end
|
43
|
+
puts "BOOKMARKLET:"
|
44
|
+
puts bm
|
45
|
+
puts
|
46
|
+
puts "Saved bookmarklet to #{bm_file}."
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.gen_infocard(args, env="prod")
|
50
|
+
raise "You must specify a name for the card" if args.empty?
|
51
|
+
puts "Generating Infocard (#{env})"
|
52
|
+
icard = app.infocard(args[0] || "", args[1] || "", env)
|
53
|
+
write_file(icard, env)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.app
|
57
|
+
return @@app if defined?@@app
|
58
|
+
require LIB_DIR + 'common'
|
59
|
+
@@app = KRL_COMMON::get_app
|
60
|
+
return @@app
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.get_endpoint_dir(env)
|
64
|
+
dir_name = env == "prod" ? "/endpoints" : "/test"
|
65
|
+
endpoint_dir = Dir.pwd + dir_name
|
66
|
+
FileUtils.mkdir(endpoint_dir) unless File.directory?(endpoint_dir)
|
67
|
+
return endpoint_dir
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.write_file(ext, env)
|
71
|
+
if ext["errors"].empty?
|
72
|
+
endpoint_dir = get_endpoint_dir(env)
|
73
|
+
ext_file_name = File.join(endpoint_dir, ext["file_name"])
|
74
|
+
File.open(ext_file_name, 'wb') do |f|
|
75
|
+
f.write Base64.decode64(ext["data"])
|
76
|
+
end
|
77
|
+
puts "Endpoint was created: #{ext_file_name}"
|
78
|
+
else
|
79
|
+
raise ext["errors"].join("\n")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/help.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Help
|
3
|
+
def self.go
|
4
|
+
puts
|
5
|
+
puts "Kynetx Rule Language Commandline tool."
|
6
|
+
puts "Authenticating / Connecting"
|
7
|
+
puts "In order to connect to your Kynetx account you must first"
|
8
|
+
puts "go through an OAuth ceremony. This is a process that must "
|
9
|
+
puts "be done on the web for now. In order to connect run the "
|
10
|
+
puts "following command:"
|
11
|
+
puts "krl-connect"
|
12
|
+
puts
|
13
|
+
puts "Once connected, you will be able to run the following commands:"
|
14
|
+
puts "Usage: krl <command> <args>"
|
15
|
+
puts
|
16
|
+
puts "Commands:"
|
17
|
+
puts "apps".ljust(20) + "Lists your apps"
|
18
|
+
puts " ".ljust(20) + "Example: krl apps"
|
19
|
+
puts "checkout".ljust(20) + "Creates a directory structure with the application."
|
20
|
+
puts " ".ljust(20) + "you have checked out. "
|
21
|
+
puts " ".ljust(20) + "Example: krl checkout a1x2"
|
22
|
+
puts "create".ljust(20) + "Creates a new application. Specify an app name and, optionally, a description."
|
23
|
+
puts " ".ljust(20) + "Example: krl create 'Hello World'"
|
24
|
+
puts " ".ljust(20) + "or: krl create 'Hello World' 'App that displays Hello World'"
|
25
|
+
puts ""
|
26
|
+
puts "You must be in the root directory of your app to run the following commands:"
|
27
|
+
puts "update".ljust(20) + "Overwrites your current .krl file with the specified version."
|
28
|
+
puts " ".ljust(20) + "If no version is specified, then the latest version will be used."
|
29
|
+
puts " ".ljust(20) + "Example: krl update"
|
30
|
+
puts " ".ljust(20) + "or: krl update 10"
|
31
|
+
puts "commit".ljust(20) + "Saves your .krl file as the latest version. "
|
32
|
+
puts " ".ljust(20) + "Example: krl commit"
|
33
|
+
puts "deploy".ljust(20) + "Deploys a version of your application. If no version is"
|
34
|
+
puts " ".ljust(20) + "specified then the latest version is deployed."
|
35
|
+
puts " ".ljust(20) + "Example: krl deploy"
|
36
|
+
puts " ".ljust(20) + "or: krl deploy 10 -- deploys version 10"
|
37
|
+
puts "versions".ljust(20) + "Displays a list of all the versions of your app."
|
38
|
+
puts " ".ljust(20) + "Example: krl versions"
|
39
|
+
puts " ".ljust(20) + "You can also display just the last (n) versions by specifying a limit."
|
40
|
+
puts " ".ljust(20) + "Example: krl versions 10 -- shows only the previous 10 versions"
|
41
|
+
puts "note".ljust(20) + "Adds a note to a version."
|
42
|
+
puts " ".ljust(20) + "Example: krl note 10 'This is the deployed version'"
|
43
|
+
puts " ".ljust(20) + " -- Adds a note to version 10 of 'This is the deployed version'"
|
44
|
+
puts "show".ljust(20) + "Shows a specific version of the app."
|
45
|
+
puts " ".ljust(20) + "Example: krl show 10"
|
46
|
+
puts "generate".ljust(20) + "Generates an endpoint and places it in the endpoints directory."
|
47
|
+
puts " ".ljust(20) + "Example: krl generate firefox"
|
48
|
+
puts " ".ljust(20) + "Available endpoints: "
|
49
|
+
puts " ".ljust(20) + "firefox name author description"
|
50
|
+
puts " ".ljust(20) + "chrome name author description"
|
51
|
+
puts " ".ljust(20) + "ie name author description"
|
52
|
+
puts " ".ljust(20) + "bookmarklet"
|
53
|
+
puts " ".ljust(20) + "infocard name datasets(optional)"
|
54
|
+
puts "test".ljust(20) + "Generates a test endpoint that always executes the latest version."
|
55
|
+
puts " ".ljust(20) + "The endpoint is saved in the test directory. If no endpoint is "
|
56
|
+
puts " ".ljust(20) + "specified a bookmarklet will be generated."
|
57
|
+
puts " ".ljust(20) + "Example: krl test"
|
58
|
+
puts " ".ljust(20) + "or: krl test infocard"
|
59
|
+
puts " ".ljust(20) + "Available test endpoints: "
|
60
|
+
puts " ".ljust(20) + "bookmarklet runtime(optional)"
|
61
|
+
puts " ".ljust(20) + "infocard name datasets(optional)"
|
62
|
+
puts "check".ljust(20) + "Performs a syntax check of your .krl file."
|
63
|
+
puts
|
64
|
+
puts "* not implemented yet."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/note.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Note
|
3
|
+
def self.go(args)
|
4
|
+
raise "Please supply a version and a note. (note must be enclosed in quotes)" unless args.length == 2
|
5
|
+
version = args.first.to_i
|
6
|
+
note = args.last.to_s
|
7
|
+
require LIB_DIR + 'common'
|
8
|
+
app = KRL_COMMON::get_app
|
9
|
+
app.set_version_note(version, note)
|
10
|
+
puts "Done."
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/show.rb
ADDED
data/lib/test.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
module KRL_CMD
|
3
|
+
class Test
|
4
|
+
def self.go(args)
|
5
|
+
type = args[0] || "bookmarklet"
|
6
|
+
args.shift if args
|
7
|
+
|
8
|
+
require LIB_DIR + 'generate'
|
9
|
+
if type == "bookmarklet"
|
10
|
+
KRL_CMD::Generate.gen_bookmarklet(args, "dev")
|
11
|
+
elsif type == "infocard"
|
12
|
+
KRL_CMD::Generate.gen_infocard(args, "dev")
|
13
|
+
else
|
14
|
+
puts "Unknown test endpoint (#{type})"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/update.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Update
|
3
|
+
def self.go(args)
|
4
|
+
version = args.to_s.empty? ? "development" : args.to_s.to_i
|
5
|
+
require LIB_DIR + 'common'
|
6
|
+
app = KRL_COMMON::get_app
|
7
|
+
root_dir = Dir.pwd
|
8
|
+
File.open(File.join(Dir.pwd, app.application_id + ".krl"), "w") { |f| f.print(app.krl(version)) }
|
9
|
+
puts "Updated to version: #{version}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/user.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require "kynetx_am_api"
|
3
|
+
CONFIG_FILE = ENV["HOME"] + "/.krl/credentials.yml"
|
4
|
+
|
5
|
+
module KRL_CMD
|
6
|
+
class User < KynetxAmApi::User
|
7
|
+
|
8
|
+
def initialize(opts={})
|
9
|
+
KynetxAmApi::Oauth.api_server_url = "http://amapi.kynetx.com"
|
10
|
+
KynetxAmApi::Oauth.accounts_server_url = "https://accounts.kynetx.com"
|
11
|
+
KynetxAmApi::Oauth.consumer_key = "1j54YDLUcLW9ERBKalNm"
|
12
|
+
KynetxAmApi::Oauth.consumer_secret = "QiWCbvTpCAejoceV3f6dD8ycifEkSumFAW1VSmwC"
|
13
|
+
config = YAML::load_file(CONFIG_FILE)
|
14
|
+
super(opts.merge(config))
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/versions.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module KRL_CMD
|
2
|
+
class Versions
|
3
|
+
def self.go(args)
|
4
|
+
require LIB_DIR + 'common'
|
5
|
+
limit = args.to_s.to_i
|
6
|
+
app = KRL_COMMON::get_app
|
7
|
+
p_version = app.production_version.to_i
|
8
|
+
KRL_COMMON::pretty_table(app.versions, [
|
9
|
+
{:field => "Version", :value => lambda { |r| r["version"] }},
|
10
|
+
{:field => "User", :value => lambda { |r| r["name"] }},
|
11
|
+
{:field => "Date", :value => lambda { |r| r["created"].to_s }},
|
12
|
+
{:field => "Note", :value => lambda { |r| r["note"].to_s }},
|
13
|
+
{:field => "Production", :value => lambda { |r| r["version"] == p_version ? "Yes" : "No" }}
|
14
|
+
], limit)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: krl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Michael Farmer, Cid Dennis
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-04 00:00:00 -06:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: kynetx_am_api
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 1
|
30
|
+
- 2
|
31
|
+
version: 0.1.2
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: terminal-table
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: sinatra
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 1
|
55
|
+
- 0
|
56
|
+
version: "1.0"
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rspec
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id004
|
71
|
+
description: " Installing this gem will give you command line tools that will allow you\n to develop your Kynetx applications using any IDE you desire. It provides \n a simple interface that is similar to git or svn.\n"
|
72
|
+
email: mjf@kynetx.com
|
73
|
+
executables:
|
74
|
+
- krl
|
75
|
+
- krl-connect
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files:
|
79
|
+
- LICENSE
|
80
|
+
files:
|
81
|
+
- lib/apps.rb
|
82
|
+
- lib/check.rb
|
83
|
+
- lib/checkout.rb
|
84
|
+
- lib/commit.rb
|
85
|
+
- lib/common.rb
|
86
|
+
- lib/create.rb
|
87
|
+
- lib/deploy.rb
|
88
|
+
- lib/generate.rb
|
89
|
+
- lib/help.rb
|
90
|
+
- lib/note.rb
|
91
|
+
- lib/show.rb
|
92
|
+
- lib/test.rb
|
93
|
+
- lib/update.rb
|
94
|
+
- lib/user.rb
|
95
|
+
- lib/versions.rb
|
96
|
+
- bin/krl
|
97
|
+
- bin/krl-connect
|
98
|
+
- bin/views/index.erb
|
99
|
+
- bin/views/success.erb
|
100
|
+
- LICENSE
|
101
|
+
has_rdoc: true
|
102
|
+
homepage: http://www.kynetx.com
|
103
|
+
licenses: []
|
104
|
+
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options:
|
107
|
+
- --charset=UTF-8
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.3.6
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Provides terminal access to the Kynetx Applicaiton API
|
131
|
+
test_files: []
|
132
|
+
|