juici-interface 0.0.0.alpha1

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.
Files changed (3) hide show
  1. data/bin/juicic +54 -0
  2. data/lib/juici/interface.rb +13 -0
  3. metadata +48 -0
data/bin/juicic ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+ require 'net/http'
3
+ require 'json'
4
+ require 'juici/interface'
5
+
6
+ # TODO Refactor
7
+ def main(args)
8
+ action = args.shift.to_sym
9
+ options = {}
10
+
11
+ until args.empty?
12
+ case args.shift
13
+ when "--command"
14
+ command = args.shift
15
+ options[:command] = if command == "-"
16
+ File.read(command)
17
+ else
18
+ command
19
+ end
20
+ when "--host"
21
+ options[:host] = args.shift
22
+ when "--title"
23
+ options[:title] = args.shift
24
+ when "--project"
25
+ options[:project] = args.shift
26
+ when "--priority"
27
+ options[:priority] = args.shift
28
+ end
29
+ end
30
+
31
+ send(action, options)
32
+ end
33
+
34
+ def build(opts)
35
+ host = URI(opts[:host])
36
+ Net::HTTP.start(host.host, host.port) do |h|
37
+ req = Net::HTTP::Post.new(Juici::Routes::NEW_BUILD)
38
+ req.body = _create_payload(opts)
39
+ h.request req
40
+ end
41
+ end
42
+
43
+ def _create_payload(opts)
44
+ URI.encode_www_form({
45
+ "project" => opts[:project],
46
+ "environment" => (opts[:environment] || {}).to_json,
47
+ "command" => opts[:command],
48
+ "priority" => opts[:priority] || 1,
49
+ "callbacks" => (opts[:callbacks] || []).to_json,
50
+ "title" => opts[:title]
51
+ })
52
+ end
53
+
54
+ main(ARGV.dup)
@@ -0,0 +1,13 @@
1
+ module Juici
2
+ module BuildStatus
3
+ PASS = "success"
4
+ FAIL = "failed"
5
+ START = "started"
6
+ WAIT = "waiting"
7
+ end
8
+
9
+ module Routes
10
+ NEW_BUILD = '/builds/new'
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: juici-interface
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0.alpha1
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Richo Healey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Interface definition for JuiCI callbacks and API
15
+ email:
16
+ - richo@psych0tik.net
17
+ executables:
18
+ - juicic
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/juici/interface.rb
23
+ - bin/juicic
24
+ homepage: http://github.com/richo/juici
25
+ licenses: []
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>'
40
+ - !ruby/object:Gem::Version
41
+ version: 1.3.1
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.24
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: Interface definition for JuiCI callbacks and API
48
+ test_files: []