krl 0.1.60 → 0.1.62

Sign up to get free protection for your applications and to get access to all the features.
data/bin/krl-connect CHANGED
@@ -4,6 +4,7 @@ require "rubygems"
4
4
  require "sinatra/base"
5
5
  require "yaml"
6
6
  require "kynetx_am_api"
7
+ require "launchy"
7
8
 
8
9
  #TODO: add launchy gem to make the browser automatically popup.
9
10
  #TODO: make it so you can connect without a web page
@@ -58,4 +59,8 @@ class KRLConnect < Sinatra::Base
58
59
  end
59
60
  end
60
61
 
62
+ Thread.new do
63
+ sleep 3
64
+ Launchy::Browser.run("http://localhost:3009")
65
+ end
61
66
  KRLConnect.run!
data/lib/check.rb CHANGED
@@ -15,10 +15,11 @@ module KRL_CMD
15
15
  validateresponse = Net::HTTP.post_form(URI.parse(apiurl), apiargs).body.to_s
16
16
  jdata = JSON.parse(validateresponse, { :max_nesting => false })
17
17
  if jdata["error"]
18
+ puts "Errors:"
18
19
  puts jdata["error"]
19
20
  else
20
21
  puts "OK"
21
22
  end
22
23
  end
23
24
  end
24
- end
25
+ end
data/lib/common.rb CHANGED
@@ -24,7 +24,9 @@ module KRL_COMMON
24
24
  begin
25
25
  root_dir = Dir.pwd
26
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'))
27
+ config_file = File.join(root_dir, '.app')
28
+ raise "Unable to get the app information. You need to recheckout your app." unless File.exists?(config_file)
29
+ config = YAML::load_file(config_file)
28
30
  user = KRL_CMD::User.new
29
31
  app = user.find_application(:application_id => config[:ruleset_id], :version => version)
30
32
  return app
data/lib/generate.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  require 'fileutils'
2
2
  require 'base64'
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+ require 'launchy'
7
+
3
8
  module KRL_CMD
4
9
  class Generate
5
10
  def self.go(args)
@@ -20,20 +25,37 @@ module KRL_CMD
20
25
 
21
26
  end
22
27
 
23
- def self.gen_extension(type, args)
28
+ def self.gen_extension(type, args, env='prod')
24
29
  puts "Generating Extension (#{type.to_s}) #{args.join(', ')}"
25
- ext = app.extension(type, args[0] || "", args[1] || "", args[2] || "" )
26
- write_file(ext, "prod")
30
+ # ext = app.extension(type, args[0] || "", args[1] || "", args[2] || "" )
31
+ # write_file(ext, "prod")
32
+
33
+ opts = {}
34
+ opts[:extname] = args[0] if args[0]
35
+ opts[:extauthor] = args[1] if args[1]
36
+ opts[:extdesc] = args[2] if args[2]
37
+ opts[:env] = env
38
+ opts[:format] = 'url'
39
+
40
+ ext = app.endpoint(type, opts)
41
+ write_file(ext, env)
27
42
  end
28
43
 
29
44
  def self.gen_bookmarklet(args, env="prod")
30
45
  puts "Generating Bookmarklet (#{env})"
31
46
  bm = ""
32
- if args.to_s.empty?
33
- bm = app.bookmarklet(env)
47
+ opts = {}
48
+ opts[:env] = env
49
+ opts[:runtime] = args.to_s unless args.to_s.empty?
50
+
51
+ endpoint = app.endpoint(:bookmarklet, opts)
52
+
53
+ if endpoint["errors"].empty?
54
+ bm = endpoint["data"]
34
55
  else
35
- bm = app.bookmarklet(env, args.to_s)
56
+ raise "Invalid bookmark generated. \n#{endpoint.errors.join("\n")}"
36
57
  end
58
+
37
59
  bm_file = File.join(get_endpoint_dir(env), env + "_bookmarklet.html")
38
60
  File.open(bm_file, 'w') do |f|
39
61
  f.print("<textarea rows='5' cols='100'>#{bm}</textarea><br><br>")
@@ -44,12 +66,19 @@ module KRL_CMD
44
66
  puts bm
45
67
  puts
46
68
  puts "Saved bookmarklet to #{bm_file}."
69
+ Launchy::Browser.run('file://' + bm_file)
47
70
  end
48
71
 
49
72
  def self.gen_infocard(args, env="prod")
50
73
  raise "You must specify a name for the card" if args.empty?
51
74
  puts "Generating Infocard (#{env})"
52
- icard = app.infocard(args[0] || "", args[1] || "", env)
75
+ opts = {}
76
+ opts[:extname] = args[0] if args[0]
77
+ opts[:datasets] = args[1] if args[1]
78
+ opts[:env] = env
79
+ opts[:format] = 'url'
80
+
81
+ icard = app.endpoint(:info_card, opts)
53
82
  write_file(icard, env)
54
83
  end
55
84
 
@@ -71,13 +100,20 @@ module KRL_CMD
71
100
  if ext["errors"].empty?
72
101
  endpoint_dir = get_endpoint_dir(env)
73
102
  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
103
+ url = URI.parse(ext["data"])
104
+
105
+ # Download the file
106
+ puts "Downloading endpoint from #{ext["data"]} to #{ext_file_name}"
107
+ Net::HTTP.start(url.host, url.port) { |http|
108
+ resp = http.get url.path
109
+ open(ext_file_name, "wb") do |file|
110
+ file.write(resp.body)
111
+ end
112
+ }
77
113
  puts "Endpoint was created: #{ext_file_name}"
78
114
  else
79
115
  raise ext["errors"].join("\n")
80
116
  end
81
117
  end
82
118
  end
83
- end
119
+ end
data/lib/help.rb CHANGED
@@ -51,6 +51,7 @@ module KRL_CMD
51
51
  puts "show".ljust(20) + "Shows a specific version of the app."
52
52
  puts " ".ljust(20) + "Example: krl show 10"
53
53
  puts "generate".ljust(20) + "Generates an endpoint and places it in the endpoints directory."
54
+ puts " ".ljust(20) + "Name, author, and description are optional and default to the user and app settings."
54
55
  puts " ".ljust(20) + "Example: krl generate firefox"
55
56
  puts " ".ljust(20) + "Available endpoints: "
56
57
  puts " ".ljust(20) + "firefox name author description"
data/lib/user.rb CHANGED
@@ -10,9 +10,10 @@ module KRL_CMD
10
10
  KynetxAmApi::Oauth.accounts_server_url = "https://accounts.kynetx.com"
11
11
  KynetxAmApi::Oauth.consumer_key = "1j54YDLUcLW9ERBKalNm"
12
12
  KynetxAmApi::Oauth.consumer_secret = "QiWCbvTpCAejoceV3f6dD8ycifEkSumFAW1VSmwC"
13
+ raise "Unable to authenticate. You need to run krl-connect." unless File.exists? CONFIG_FILE
13
14
  config = YAML::load_file(CONFIG_FILE)
14
15
  super(opts.merge(config))
15
16
  end
16
17
 
17
18
  end
18
- end
19
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 60
9
- version: 0.1.60
8
+ - 62
9
+ version: 0.1.62
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Farmer, Cid Dennis
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-01 00:00:00 -06:00
17
+ date: 2010-06-24 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,8 +27,8 @@ dependencies:
27
27
  segments:
28
28
  - 0
29
29
  - 1
30
- - 26
31
- version: 0.1.26
30
+ - 27
31
+ version: 0.1.27
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
34
  - !ruby/object:Gem::Dependency
@@ -57,9 +57,23 @@ dependencies:
57
57
  type: :runtime
58
58
  version_requirements: *id003
59
59
  - !ruby/object:Gem::Dependency
60
- name: rspec
60
+ name: launchy
61
61
  prerelease: false
62
62
  requirement: &id004 !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ - 3
69
+ - 5
70
+ version: 0.3.5
71
+ type: :runtime
72
+ version_requirements: *id004
73
+ - !ruby/object:Gem::Dependency
74
+ name: rspec
75
+ prerelease: false
76
+ requirement: &id005 !ruby/object:Gem::Requirement
63
77
  requirements:
64
78
  - - ">="
65
79
  - !ruby/object:Gem::Version
@@ -67,7 +81,7 @@ dependencies:
67
81
  - 0
68
82
  version: "0"
69
83
  type: :development
70
- version_requirements: *id004
84
+ version_requirements: *id005
71
85
  description: " Build your Kynetx applications with the IDE of your choice! Installing the krl gem will give you \n command line tools that provides a simple interface that is similar to git or svn.\n"
72
86
  email: mjf@kynetx.com
73
87
  executables: