juici-interface 0.0.0 → 0.0.1.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 +5 -0
  3. metadata +8 -6
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)
@@ -5,4 +5,9 @@ module Juici
5
5
  START = "started"
6
6
  WAIT = "waiting"
7
7
  end
8
+
9
+ module Routes
10
+ NEW_BUILD = '/builds/new'
11
+ end
12
+
8
13
  end
metadata CHANGED
@@ -1,24 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juici-interface
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
5
- prerelease:
4
+ version: 0.0.1.alpha1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Richo Healey
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-02 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Interface definition for JuiCI callbacks and API
15
15
  email:
16
16
  - richo@psych0tik.net
17
- executables: []
17
+ executables:
18
+ - juicic
18
19
  extensions: []
19
20
  extra_rdoc_files: []
20
21
  files:
21
22
  - lib/juici/interface.rb
23
+ - bin/juicic
22
24
  homepage: http://github.com/richo/juici
23
25
  licenses: []
24
26
  post_install_message:
@@ -34,9 +36,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
34
36
  required_rubygems_version: !ruby/object:Gem::Requirement
35
37
  none: false
36
38
  requirements:
37
- - - ! '>='
39
+ - - ! '>'
38
40
  - !ruby/object:Gem::Version
39
- version: '0'
41
+ version: 1.3.1
40
42
  requirements: []
41
43
  rubyforge_project:
42
44
  rubygems_version: 1.8.24