scm-workflow 0.4.0 → 0.5.0
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/scw +2 -4
- data/bin/scw-init +1 -2
- data/lib/ext/string.rb +0 -3
- data/lib/scm-workflow.rb +0 -1
- data/lib/scm-workflow/configuration.rb +0 -3
- data/lib/scm-workflow/workflow-init-repo.rb +162 -0
- data/scm-workflow.gemspec +2 -2
- data/spec/initrepo_spec.rb +46 -0
- data/spec/logger_spec.rb +66 -0
- metadata +15 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00092a546e9fca2858bfb1d8f2d40cd94d51e003
|
4
|
+
data.tar.gz: 295a6e95ef7e08381d446b5c092b3b1e3451abe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef2e310530c09bc75d186ac27901dbce650be52c12253fbfd6356b4f827ee51e62662e9f166b169532cc85f036bd00b15b428fbbd22fe6bdfe64ee9690a2eb29
|
7
|
+
data.tar.gz: 4db09fc429575e1ffb736a0454003ac1fe7de47e4266974fd0c60f0dee1c9325c4d849c58265fc69eaa030689d98effe6a945f5a203e24641fa280ad5464882e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/bin/scw
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require "
|
4
|
-
|
5
|
-
|
6
|
-
require "utils/command-dispatcher.rb"
|
3
|
+
require "scm-workflow"
|
4
|
+
require "utils/command-dispatcher"
|
7
5
|
|
8
6
|
# -----------------------------------------------------------------------------
|
9
7
|
# This program is meant to be used as an extention to the git scm program. It
|
data/bin/scw-init
CHANGED
data/lib/ext/string.rb
CHANGED
data/lib/scm-workflow.rb
CHANGED
@@ -0,0 +1,162 @@
|
|
1
|
+
|
2
|
+
module Scm
|
3
|
+
module Workflow
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Scm::Workflow
|
8
|
+
|
9
|
+
class InitRepoWorkflow
|
10
|
+
include Logging
|
11
|
+
include Workflow
|
12
|
+
|
13
|
+
# -------------------------------------------------------------------------
|
14
|
+
# -------------------------------------------------------------------------
|
15
|
+
def initialize(repo, configuration, &block)
|
16
|
+
@repo = repo
|
17
|
+
@config = repo.config
|
18
|
+
@configuration = configuration
|
19
|
+
@callback = block
|
20
|
+
logger.info("asdasdsa")
|
21
|
+
end
|
22
|
+
|
23
|
+
# -------------------------------------------------------------------------
|
24
|
+
# -------------------------------------------------------------------------
|
25
|
+
workflow do
|
26
|
+
state :start do
|
27
|
+
event :validate, :transitions_to => :validating
|
28
|
+
end
|
29
|
+
state :validating do
|
30
|
+
event :retrieveInfo, :transitions_to => :retrieving
|
31
|
+
event :terminate, :transitions_to => :terminated
|
32
|
+
end
|
33
|
+
state :retrieving do
|
34
|
+
event :inquireUser, :transitions_to => :querying
|
35
|
+
end
|
36
|
+
state :querying do
|
37
|
+
event :cancel, :transitions_to => :terminated
|
38
|
+
event :persistInfo, :transitions_to => :persisting
|
39
|
+
end
|
40
|
+
state :persisting do
|
41
|
+
event :terminate, :transitions_to => :terminated
|
42
|
+
end
|
43
|
+
state :terminated
|
44
|
+
end
|
45
|
+
|
46
|
+
# -------------------------------------------------------------------------
|
47
|
+
# -------------------------------------------------------------------------
|
48
|
+
def on_validating_entry(new_state, event, *args)
|
49
|
+
logger.info("E: Init worflow ready to go")
|
50
|
+
@repoValid = @repo.repo.valid?
|
51
|
+
end
|
52
|
+
|
53
|
+
def on_validating_exit(new_state, event, *args)
|
54
|
+
logger.info("X: Init worflow done")
|
55
|
+
end
|
56
|
+
|
57
|
+
# -------------------------------------------------------------------------
|
58
|
+
# -------------------------------------------------------------------------
|
59
|
+
def on_retrieving_entry(new_state, event, *args)
|
60
|
+
logger.info("E: Retrieving configuration info")
|
61
|
+
|
62
|
+
@configuration.each { |c|
|
63
|
+
entryTitle = c.class.name.split('::').last.downcase
|
64
|
+
c.instance_variables.each do |sv|
|
65
|
+
begin
|
66
|
+
entry = c.instance_variable_get(sv)
|
67
|
+
entry.value = @config.getValue("scm-workflow.#{entryTitle}.#{sv[1..-1]}")
|
68
|
+
rescue => exception
|
69
|
+
# That's ok, a missing value is ok.
|
70
|
+
end
|
71
|
+
end
|
72
|
+
}
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def on_retrieving_exit(new_state, event, *args)
|
77
|
+
logger.info("X: Retrieving configuration info done")
|
78
|
+
end
|
79
|
+
|
80
|
+
# -------------------------------------------------------------------------
|
81
|
+
# -------------------------------------------------------------------------
|
82
|
+
def on_querying_entry(new_state, event, *args)
|
83
|
+
logger.info("E: Querying configuration info")
|
84
|
+
@callback.call(@configuration)
|
85
|
+
end
|
86
|
+
|
87
|
+
def on_querying_exit(new_state, event, *args)
|
88
|
+
logger.info("X: Querying configuration info done")
|
89
|
+
end
|
90
|
+
|
91
|
+
# -------------------------------------------------------------------------
|
92
|
+
# -------------------------------------------------------------------------
|
93
|
+
def on_persisting_entry(new_state, event, *args)
|
94
|
+
logger.info("E: Persisting configuration info")
|
95
|
+
|
96
|
+
@configuration.each { |c|
|
97
|
+
globalEntry = c
|
98
|
+
|
99
|
+
entryTitle = c.class.name.split('::').last.downcase
|
100
|
+
c.instance_variables.each do |sv|
|
101
|
+
begin
|
102
|
+
entry = c.instance_variable_get(sv)
|
103
|
+
value = entry.value unless entry.hideinput
|
104
|
+
value = entry.value.encrypt if entry.hideinput
|
105
|
+
|
106
|
+
@config.setValue("scm-workflow.#{entryTitle}.#{sv[1..-1]}", value)
|
107
|
+
rescue => exception
|
108
|
+
logger.error(exception.to_s)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
}
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
def on_persisting_exit(new_state, event, *args)
|
116
|
+
logger.info("X: Persisting configuration info done")
|
117
|
+
end
|
118
|
+
|
119
|
+
def repoIsValid?
|
120
|
+
return @repoValid
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
class InitializeRepo
|
126
|
+
|
127
|
+
# -------------------------------------------------------------------------
|
128
|
+
# -------------------------------------------------------------------------
|
129
|
+
def initialize(repo, configuration)
|
130
|
+
@repo = repo
|
131
|
+
@configuration = configuration
|
132
|
+
|
133
|
+
raise "Invalid repo specified" if @repo.nil?
|
134
|
+
raise "Invalid configuration specified" if @configuration.nil?
|
135
|
+
end
|
136
|
+
|
137
|
+
# -------------------------------------------------------------------------
|
138
|
+
# -------------------------------------------------------------------------
|
139
|
+
def execute(&block)
|
140
|
+
callback = block
|
141
|
+
@initWorkflow = InitRepoWorkflow.new(@repo, @configuration, &callback)
|
142
|
+
@initWorkflow.validate!
|
143
|
+
|
144
|
+
if @initWorkflow.repoIsValid?
|
145
|
+
@initWorkflow.retrieveInfo!
|
146
|
+
@initWorkflow.inquireUser!
|
147
|
+
@initWorkflow.persistInfo!
|
148
|
+
@initWorkflow.terminate!
|
149
|
+
@success = true
|
150
|
+
else
|
151
|
+
@initWorkflow.terminate!
|
152
|
+
@success = false
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def wasSuccessfull?
|
157
|
+
return @success
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
data/scm-workflow.gemspec
CHANGED
@@ -23,11 +23,11 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_development_dependency 'cli-colorize'
|
24
24
|
gem.add_development_dependency 'rdoc', '>= 3.12'
|
25
25
|
gem.add_development_dependency 'cucumber', '>= 1.0'
|
26
|
-
gem.add_development_dependency 'bundler', '>= 1.0.0'
|
27
26
|
gem.add_development_dependency 'simplecov'
|
28
27
|
|
28
|
+
gem.add_runtime_dependency 'bundler', '>= 1.0.0'
|
29
29
|
gem.add_runtime_dependency 'ruby'
|
30
|
-
gem.add_runtime_dependency 'gitit', '>= 0.
|
30
|
+
gem.add_runtime_dependency 'gitit', '>= 0.5.0'
|
31
31
|
gem.add_runtime_dependency 'highline'
|
32
32
|
gem.add_runtime_dependency 'builder'
|
33
33
|
gem.add_runtime_dependency 'kruptos', '>= 0.2.0'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'highline/import'
|
3
|
+
|
4
|
+
describe Scm::Workflow do
|
5
|
+
|
6
|
+
TMP_PATH = "/tmp/"
|
7
|
+
BAD_PATH = "/adsdsadasdsa"
|
8
|
+
TEST_REPO_PATH = "/tmp/test_git"
|
9
|
+
TEST_REPO_PATH_BARE = "/tmp/test_git_bare"
|
10
|
+
|
11
|
+
# -------------------------------------------------------------------------
|
12
|
+
# -------------------------------------------------------------------------
|
13
|
+
describe "#testInitializeRepo" do
|
14
|
+
before(:each) do
|
15
|
+
FileUtils.mkpath TEST_REPO_PATH
|
16
|
+
@git = Gitit::Git.new(TEST_REPO_PATH)
|
17
|
+
@git.repo.init
|
18
|
+
@config = @git.config
|
19
|
+
end
|
20
|
+
|
21
|
+
it "will successfully encrypt a string" do
|
22
|
+
encrypted = "abcd".encrypt
|
23
|
+
encrypted.encrypt.should_not eq "abcd"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "will successfully decrypt an encrypted string" do
|
27
|
+
encrypted = "abcd".encrypt
|
28
|
+
encrypted.decrypt.should eq "abcd"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "will successfully encrypt and decrypt a string when using a custom key" do
|
32
|
+
encrypted = "abcd".encrypt("My custom key")
|
33
|
+
encrypted.encrypt.should_not eq "abcd"
|
34
|
+
encrypted.decrypt.should_not eq "abcd"
|
35
|
+
encrypted.decrypt("My custom key").should eq "abcd"
|
36
|
+
end
|
37
|
+
|
38
|
+
after(:each) do
|
39
|
+
FileUtils.rm_rf TEST_REPO_PATH
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
data/spec/logger_spec.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Logger do
|
4
|
+
|
5
|
+
# -------------------------------------------------------------------------
|
6
|
+
# -------------------------------------------------------------------------
|
7
|
+
describe "#testLogSettings" do
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
end
|
11
|
+
|
12
|
+
it "will initialize successfully" do
|
13
|
+
expect{ Scm::Workflow::Utils::LogSettings.new }.to raise_error
|
14
|
+
expect{ Scm::Workflow::Utils::LogSettings.instance }.to_not raise_error
|
15
|
+
log_settings = Scm::Workflow::Utils::LogSettings.instance
|
16
|
+
log_settings.level.should eq Logger::FATAL
|
17
|
+
log_settings.output.should eq STDOUT
|
18
|
+
end
|
19
|
+
|
20
|
+
after(:each) do
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
# -------------------------------------------------------------------------
|
26
|
+
# -------------------------------------------------------------------------
|
27
|
+
describe "#testLoggingClass" do
|
28
|
+
|
29
|
+
before(:each) do
|
30
|
+
end
|
31
|
+
|
32
|
+
it "will initialize successfully" do
|
33
|
+
expect{ Scm::Workflow::Utils::Logging.new }.to raise_error
|
34
|
+
expect{ Scm::Workflow::Utils::Logging.instance }.to_not raise_error
|
35
|
+
logging = Scm::Workflow::Utils::Logging.instance
|
36
|
+
logging.logger.level.should eq Logger::FATAL
|
37
|
+
end
|
38
|
+
|
39
|
+
after(:each) do
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
# -------------------------------------------------------------------------
|
45
|
+
# -------------------------------------------------------------------------
|
46
|
+
describe "#testLoggingMixIn" do
|
47
|
+
include Logging
|
48
|
+
|
49
|
+
before(:each) do
|
50
|
+
end
|
51
|
+
|
52
|
+
it "will initialize successfully" do
|
53
|
+
|
54
|
+
log_settings = Scm::Workflow::Utils::LogSettings.instance
|
55
|
+
log_settings.level = Logger::INFO
|
56
|
+
logger.info("boo")
|
57
|
+
end
|
58
|
+
|
59
|
+
after(:each) do
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scm-workflow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Laplante
|
@@ -67,33 +67,33 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
90
|
-
type: :
|
89
|
+
version: 1.0.0
|
90
|
+
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.0.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: ruby
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.5.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.5.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: highline
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -214,11 +214,14 @@ files:
|
|
214
214
|
- lib/scm-workflow.rb
|
215
215
|
- lib/scm-workflow/configuration.rb
|
216
216
|
- lib/scm-workflow/version.rb
|
217
|
+
- lib/scm-workflow/workflow-init-repo.rb
|
217
218
|
- lib/tasks/version.rake
|
218
219
|
- lib/test_unit_extensions.rb
|
219
220
|
- lib/utils/command-dispatcher.rb
|
220
221
|
- lib/utils/logging.rb
|
221
222
|
- scm-workflow.gemspec
|
223
|
+
- spec/initrepo_spec.rb
|
224
|
+
- spec/logger_spec.rb
|
222
225
|
- spec/spec_helper.rb
|
223
226
|
- spec/stringext_spec.rb
|
224
227
|
- test/test_rally.rb
|
@@ -247,6 +250,8 @@ signing_key:
|
|
247
250
|
specification_version: 4
|
248
251
|
summary: '""'
|
249
252
|
test_files:
|
253
|
+
- spec/initrepo_spec.rb
|
254
|
+
- spec/logger_spec.rb
|
250
255
|
- spec/spec_helper.rb
|
251
256
|
- spec/stringext_spec.rb
|
252
257
|
- test/test_rally.rb
|