tikici 0.0.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/tikici +5 -0
  3. data/lib/tikici.rb +143 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c5f2fb6ec6af55945a60ee753fe3b4637eb79a84
4
+ data.tar.gz: a1e29ff40349e6a4fb9b5eb939c9c631e1fc69d6
5
+ SHA512:
6
+ metadata.gz: 99b7c818447c8a198351c619551c3f8b30bcd7ca42ac0479b5f734ba65655efd285da1b8ef42055858ae146830e19007ebded4c52de08bd9cf2f66017cf935ed
7
+ data.tar.gz: aa5b24436fa1a21cd6e625945a7d8126f47bec8f225d8dcf309e616541ffd9e9b5390752d6d9cffa3a3c191044353de1cb723c2b59b6ad89cee242166055203c
data/bin/tikici ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'tikici'
4
+
5
+ Tikici.start
data/lib/tikici.rb ADDED
@@ -0,0 +1,143 @@
1
+ require 'yaml'
2
+
3
+ class Tikici
4
+ def initialize(config_file = 'tiki.yml')
5
+ @config_file = config_file
6
+ end
7
+
8
+ def symbolize(obj)
9
+ if obj.is_a? Hash
10
+ return obj.inject({}) do |memo, (k, v)|
11
+ memo.tap { |m| m[k.to_sym] = symbolize(v) }
12
+ end
13
+ elsif obj.is_a? Array
14
+ return obj.map { |memo| symbolize(memo) }
15
+ end
16
+ obj
17
+ end
18
+
19
+ def self.start
20
+ Tikici.new.exec
21
+ end
22
+
23
+ def config
24
+ @config ||= symbolize(YAML.load_file(@config_file))
25
+ rescue
26
+ {}
27
+ end
28
+
29
+ def dependencies
30
+ @dependencies ||= Dependencies.new(config.fetch(:dependencies, nil))
31
+ end
32
+
33
+ def test
34
+ @test ||= Test.new(config.fetch(:test, nil))
35
+ end
36
+
37
+ def deployment
38
+ @deployment ||= Deployment.new(config.fetch(:deployment, nil))
39
+ end
40
+
41
+ def exec
42
+ dependencies.exec
43
+ test.exec
44
+ deployment.exec
45
+ end
46
+ end
47
+
48
+ class Deployment
49
+ def initialize(config)
50
+ @config = config
51
+ end
52
+
53
+ def environments
54
+ {}.tap do |result|
55
+ @config.each do |key, val|
56
+ result[key.to_sym] = DeploymentEnv.new(val)
57
+ end unless @config.nil?
58
+ end
59
+ end
60
+
61
+ def environment_values
62
+ environments.values
63
+ end
64
+
65
+ def exec
66
+ environment_values.map(&:exec)
67
+ end
68
+ end
69
+
70
+ class DeploymentEnv
71
+ attr_accessor :branch, :commands
72
+
73
+ def initialize(config)
74
+ @config = config
75
+ end
76
+
77
+ def exec
78
+ commands.map(&:exec) if current_branch =~ Regexp.new(branch) unless branch.nil?
79
+ end
80
+
81
+ def current_branch
82
+ `git rev-parse --abbrev-ref HEAD`
83
+ end
84
+
85
+ def branch
86
+ @branch ||= @config.fetch(:branch, nil) unless @config.nil?
87
+ end
88
+
89
+ def commands
90
+ @config.fetch(:commands, []).map {|cmd| Command.new(cmd)}
91
+ rescue
92
+ []
93
+ end
94
+ end
95
+
96
+ class Test
97
+ def initialize(config)
98
+ @config = config
99
+ end
100
+
101
+ def commands
102
+ @config.fetch(:commands, []).map{|cmd| Command.new(cmd)}
103
+ rescue
104
+ []
105
+ end
106
+
107
+ def post_commands
108
+ @config.fetch(:post, []).map{|cmd| Command.new(cmd)}
109
+ rescue
110
+ []
111
+ end
112
+
113
+ def exec
114
+ commands.map(&:exec)
115
+ post_commands.map(&:exec)
116
+ end
117
+ end
118
+
119
+ class Dependencies
120
+ def initialize(config)
121
+ @config = config
122
+ end
123
+
124
+ def commands
125
+ @config.fetch(:commands, []).map{|cmd| Command.new(cmd)}
126
+ rescue
127
+ []
128
+ end
129
+
130
+ def exec
131
+ commands.map(&:exec)
132
+ end
133
+ end
134
+
135
+ class Command
136
+ def initialize(cmd)
137
+ @cmd = cmd
138
+ end
139
+
140
+ def exec
141
+ Kernel.system(@cmd)
142
+ end
143
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tikici
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Viet Nguyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Binary support run CI on Jenkins
14
+ email: viet.nguyen@tiki.vn
15
+ executables:
16
+ - tikici
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/tikici
21
+ - lib/tikici.rb
22
+ homepage: http://rubygems.org/gems/tikici
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.8
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Tiki CI!
46
+ test_files: []