james_bond-core 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -6
- data/lib/james_bond/core.rb +0 -1
- metadata +6 -25
- data/.gitignore +0 -2
- data/.rspec +0 -2
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -36
- data/bin/bond +0 -6
- data/james_bond-core.gemspec +0 -25
- data/lib/james_bond/core/version.rb +0 -5
- data/spec/lib/james_bond/core/command_spec.rb +0 -78
- data/spec/lib/james_bond/core/mission_loader_spec.rb +0 -17
- data/spec/lib/james_bond/core/mission_spec.rb +0 -210
- data/spec/spec_helper.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc4a5b5d54b212eb91bd4fac66a36271fc56f13
|
4
|
+
data.tar.gz: 790d1fd4cd53aa6b5ae473c6a540fd1529ba4bc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74551a39268f6df614410bf755774c09b95c79286598b8a4ec4202951c4ff02fcce08860560f4d408302d9244b880fe3917c0e7b07f18fd2753532165a7da0ee
|
7
|
+
data.tar.gz: 3ad89069ee57e53c2e38e80990dbd508415f77e4044acfb039d9cd0723df08888d53f55a5d88153fd8e0b722bb945d13b132ac358c42654b3f9a9d57608179de
|
data/README.md
CHANGED
data/lib/james_bond/core.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: james_bond-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Airton Sobral
|
@@ -53,26 +53,16 @@ dependencies:
|
|
53
53
|
- - '='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 9.0.5
|
56
|
-
description:
|
57
|
-
you!
|
56
|
+
description: The glue between James Bond and his missions
|
58
57
|
email:
|
59
58
|
- airtonsobral@gmail.com
|
60
59
|
- guiocavalcanti@gmail.com
|
61
|
-
executables:
|
62
|
-
- bond
|
60
|
+
executables: []
|
63
61
|
extensions: []
|
64
62
|
extra_rdoc_files:
|
65
63
|
- README.md
|
66
64
|
files:
|
67
|
-
- ".gitignore"
|
68
|
-
- ".rspec"
|
69
|
-
- ".ruby-gemset"
|
70
|
-
- ".ruby-version"
|
71
|
-
- Gemfile
|
72
|
-
- Gemfile.lock
|
73
65
|
- README.md
|
74
|
-
- bin/bond
|
75
|
-
- james_bond-core.gemspec
|
76
66
|
- lib/james_bond.rb
|
77
67
|
- lib/james_bond/core.rb
|
78
68
|
- lib/james_bond/core/command.rb
|
@@ -83,12 +73,7 @@ files:
|
|
83
73
|
- lib/james_bond/core/mission/undefined_variable_error.rb
|
84
74
|
- lib/james_bond/core/mission_loader.rb
|
85
75
|
- lib/james_bond/core/mission_pool.rb
|
86
|
-
|
87
|
-
- spec/lib/james_bond/core/command_spec.rb
|
88
|
-
- spec/lib/james_bond/core/mission_loader_spec.rb
|
89
|
-
- spec/lib/james_bond/core/mission_spec.rb
|
90
|
-
- spec/spec_helper.rb
|
91
|
-
homepage: http://rubygemgem.org/gems/james_bond
|
76
|
+
homepage: http://rubygemgem.org/gems/james_bond-core
|
92
77
|
licenses:
|
93
78
|
- MIT
|
94
79
|
metadata: {}
|
@@ -111,9 +96,5 @@ rubyforge_project:
|
|
111
96
|
rubygems_version: 2.4.8
|
112
97
|
signing_key:
|
113
98
|
specification_version: 4
|
114
|
-
summary:
|
115
|
-
test_files:
|
116
|
-
- spec/lib/james_bond/core/command_spec.rb
|
117
|
-
- spec/lib/james_bond/core/mission_loader_spec.rb
|
118
|
-
- spec/lib/james_bond/core/mission_spec.rb
|
119
|
-
- spec/spec_helper.rb
|
99
|
+
summary: James Bond Core
|
100
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
james_bond-core
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.2.0
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
james_bond-core (0.0.1)
|
5
|
-
slop (= 4.4.1)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
byebug (9.0.5)
|
11
|
-
diff-lcs (1.2.5)
|
12
|
-
rspec (3.4.0)
|
13
|
-
rspec-core (~> 3.4.0)
|
14
|
-
rspec-expectations (~> 3.4.0)
|
15
|
-
rspec-mocks (~> 3.4.0)
|
16
|
-
rspec-core (3.4.4)
|
17
|
-
rspec-support (~> 3.4.0)
|
18
|
-
rspec-expectations (3.4.0)
|
19
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
-
rspec-support (~> 3.4.0)
|
21
|
-
rspec-mocks (3.4.1)
|
22
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
-
rspec-support (~> 3.4.0)
|
24
|
-
rspec-support (3.4.1)
|
25
|
-
slop (4.4.1)
|
26
|
-
|
27
|
-
PLATFORMS
|
28
|
-
ruby
|
29
|
-
|
30
|
-
DEPENDENCIES
|
31
|
-
byebug (= 9.0.5)
|
32
|
-
james_bond-core!
|
33
|
-
rspec (= 3.4.0)
|
34
|
-
|
35
|
-
BUNDLED WITH
|
36
|
-
1.12.5
|
data/bin/bond
DELETED
data/james_bond-core.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "james_bond/core/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |gem|
|
6
|
-
gem.name = "james_bond-core"
|
7
|
-
gem.version = JamesBond::Core::VERSION
|
8
|
-
gem.date = "2016-08-18"
|
9
|
-
gem.summary = "Fully automation, from development to deploy"
|
10
|
-
gem.description = "Fully automation, from development to deploy. Let a professional help you!"
|
11
|
-
gem.authors = ["Airton Sobral", "Guilherme Cavalcanti"]
|
12
|
-
gem.email = ["airtonsobral@gmail.com", "guiocavalcanti@gmail.com"]
|
13
|
-
gem.require_paths = %w[lib]
|
14
|
-
gem.files = `git ls-files -z`.split("\x0")
|
15
|
-
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
-
gem.test_files = gem.files.grep(%r{^spec/})
|
17
|
-
gem.extra_rdoc_files = %w[README.md]
|
18
|
-
gem.homepage = "http://rubygemgem.org/gems/james_bond"
|
19
|
-
gem.license = "MIT"
|
20
|
-
|
21
|
-
gem.required_ruby_version = ">= 2.1"
|
22
|
-
gem.add_dependency "slop", "4.4.1"
|
23
|
-
gem.add_development_dependency "rspec", "3.4.0"
|
24
|
-
gem.add_development_dependency "byebug", "9.0.5"
|
25
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe JamesBond::Core::Command do
|
4
|
-
describe "#argv" do
|
5
|
-
it "should return the argv received" do
|
6
|
-
argv = ["charizard", "papai", "noel", "--delta", "-t"]
|
7
|
-
instance = described_class.new(argv: ["charizard", "papai", "noel", "--delta", "-t"],
|
8
|
-
env: "dev")
|
9
|
-
expect(instance.argv).to eq(argv)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#user_command" do
|
14
|
-
it "should return the argv as one string" do
|
15
|
-
instance = described_class.new(argv: ["charizard", "papai", "noel", "--delta", "-t"],
|
16
|
-
env: "dev")
|
17
|
-
expect(instance.user_command).to eq("charizard papai noel --delta -t")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#main_command" do
|
22
|
-
it "should return the first command" do
|
23
|
-
instance = described_class.new(argv: ["charizard"], env: "dev")
|
24
|
-
expect(instance.main_command).to eq("charizard")
|
25
|
-
instance = described_class.new(argv: ["charizard", "delta"], env: "dev")
|
26
|
-
expect(instance.main_command).to eq("charizard")
|
27
|
-
instance = described_class.new(argv: ["charizard", "delta", "-t", "--gama"], env: "dev")
|
28
|
-
expect(instance.main_command).to eq("charizard")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#raw_arguments" do
|
33
|
-
it "should return the arguments array without the main_command" do
|
34
|
-
instance = described_class.new(argv: ["charizard"], env: "dev")
|
35
|
-
expect(instance.raw_arguments).to eq([])
|
36
|
-
instance = described_class.new(argv: ["charizard", "delta"], env: "dev")
|
37
|
-
expect(instance.raw_arguments).to eq(["delta"])
|
38
|
-
instance = described_class.new(argv: ["charizard", "delta", "-t", "--gama"], env: "dev")
|
39
|
-
expect(instance.raw_arguments).to eq(["delta", "-t", "--gama"])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "#arguments_string" do
|
44
|
-
it "should return the arguments array without the main_command as one string" do
|
45
|
-
instance = described_class.new(argv: ["charizard"], env: "dev")
|
46
|
-
expect(instance.arguments_string).to eq("")
|
47
|
-
instance = described_class.new(argv: ["charizard", "delta"], env: "dev")
|
48
|
-
expect(instance.arguments_string).to eq("delta")
|
49
|
-
instance = described_class.new(argv: ["charizard", "delta", "-t", "--gama"], env: "dev")
|
50
|
-
expect(instance.arguments_string).to eq("delta -t --gama")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#env" do
|
55
|
-
it "should return the environment" do
|
56
|
-
instance = described_class.new(argv: ["charizard"], env: "dev")
|
57
|
-
expect(instance.env).to eq("dev")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#empty?" do
|
62
|
-
subject { described_class.new(argv: argv, env: 'dev') }
|
63
|
-
|
64
|
-
context "when argv is empty" do
|
65
|
-
let(:argv) { [] }
|
66
|
-
it "returns true" do
|
67
|
-
expect(subject).to be_empty
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context "when argv is not empty" do
|
72
|
-
let(:argv) { ['foo'] }
|
73
|
-
it "returns false" do
|
74
|
-
expect(subject).to_not be_empty
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe JamesBond::Core::MissionLoader do
|
4
|
-
subject do
|
5
|
-
described_class
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#append_default_missions" do
|
9
|
-
let(:list) { [] }
|
10
|
-
let(:a_mission) { double 'a mission' }
|
11
|
-
|
12
|
-
it "appends default missions to mission_list" do
|
13
|
-
missions = subject.append_default_missions(list)
|
14
|
-
expect(missions).to include a_kind_of(JamesBond::Core::HelpMission)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,210 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe JamesBond::Core::Mission do
|
4
|
-
class GoldeneyeMission
|
5
|
-
include JamesBond::Core::Mission
|
6
|
-
|
7
|
-
def build(config, params)
|
8
|
-
config.name = "Facility"
|
9
|
-
config.main_commands = ["neutralize_alarms", "contact_double_agent"]
|
10
|
-
end
|
11
|
-
|
12
|
-
def run_neutralize_alarms_command(params)
|
13
|
-
end
|
14
|
-
|
15
|
-
def run_contact_double_agent_command(params)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#core_mission_config" do
|
20
|
-
subject { GoldeneyeMission.new }
|
21
|
-
|
22
|
-
it "should return the config selected by the mission" do
|
23
|
-
expect(subject.core_mission_config).to be
|
24
|
-
expect(subject.core_mission_config.name).to eq("Facility")
|
25
|
-
expect(subject.core_mission_config.main_commands).to eq(["neutralize_alarms", "contact_double_agent"])
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe "#build" do
|
30
|
-
context "given a mission without build method" do
|
31
|
-
class MissionWithoutBuildMethod
|
32
|
-
include JamesBond::Core::Mission
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should raise error on initialization" do
|
36
|
-
expect { MissionWithoutBuildMethod.new }.to raise_error(NotImplementedError)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "given a mission with build method without defining the name and main_commands" do
|
41
|
-
class MissionWithBuildMethod
|
42
|
-
include JamesBond::Core::Mission
|
43
|
-
|
44
|
-
def build(config, params)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should call build on initialization and raise UndefinedVariableError" do
|
49
|
-
expect_any_instance_of(MissionWithBuildMethod).to receive(:build).and_call_original
|
50
|
-
expect { MissionWithBuildMethod.new }.to raise_error(described_class::UndefinedVariableError, /The mission name must be defined in the build method/)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "given a mission with build method defining only the name" do
|
55
|
-
class AnotherMissionWithBuildMethod
|
56
|
-
include JamesBond::Core::Mission
|
57
|
-
|
58
|
-
def build(config, params)
|
59
|
-
config.name = "el_capitan"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should raise UndefinedVariableError" do
|
64
|
-
expect { AnotherMissionWithBuildMethod.new }.to raise_error(described_class::UndefinedVariableError, /The main commands must be defined in the build method/)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "given a mission with build method defining the name and the main_commands" do
|
69
|
-
class SomeMissionWithBuildMethod
|
70
|
-
include JamesBond::Core::Mission
|
71
|
-
|
72
|
-
def build(config, params)
|
73
|
-
config.name = "el_capitan"
|
74
|
-
config.main_commands = []
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should not raise error" do
|
79
|
-
expect { SomeMissionWithBuildMethod.new }.to_not raise_error
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context "given a mission with build method defining the name and the main_commands " \
|
84
|
-
+ "but without the implementation for the main_command" do
|
85
|
-
class OtherMissionWithBuildMethod
|
86
|
-
include JamesBond::Core::Mission
|
87
|
-
|
88
|
-
def build(config, params)
|
89
|
-
config.name = "el_capitan"
|
90
|
-
config.main_commands = ["capitalize"]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should raise NotImplementedError" do
|
95
|
-
expect { OtherMissionWithBuildMethod.new }.to \
|
96
|
-
raise_error(NotImplementedError, "The method \"run_capitalize_command\" must be implemented for the OtherMissionWithBuildMethod")
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "given a mission with build method defining the name and the main_commands " \
|
101
|
-
+ "and the implementation for the main_command" do
|
102
|
-
it "should not raise error" do
|
103
|
-
expect { GoldeneyeMission.new }.to_not raise_error
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "#run_command" do
|
109
|
-
let(:mission) { GoldeneyeMission.new }
|
110
|
-
let(:mission_pool) { double("mission pool") }
|
111
|
-
|
112
|
-
describe "given neutralize_alarms command" do
|
113
|
-
let(:command) { JamesBond::Core::Command.new(argv: ["neutralize_alarms", "--all"], env: "dev") }
|
114
|
-
|
115
|
-
it "should redirect the command to the correct method" do
|
116
|
-
expect(mission).to receive(:run_neutralize_alarms_command).
|
117
|
-
with({ command: command, mission_pool: mission_pool })
|
118
|
-
mission.run_command(
|
119
|
-
command: command,
|
120
|
-
mission_pool: mission_pool
|
121
|
-
)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "given neutralize_alarms command" do
|
126
|
-
let(:command) { JamesBond::Core::Command.new(argv: ["contact_double_agent", "--disguise", "scientist"], env: "dev") }
|
127
|
-
|
128
|
-
it "should redirect the command to the correct method" do
|
129
|
-
expect(mission).to receive(:run_contact_double_agent_command).
|
130
|
-
with({ command: command, mission_pool: mission_pool })
|
131
|
-
mission.run_command(
|
132
|
-
command: command,
|
133
|
-
mission_pool: mission_pool
|
134
|
-
)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe "#parse_arguments" do
|
140
|
-
context "given a mission using arguments_parser feature" do
|
141
|
-
class CassinoRoyaleMission
|
142
|
-
include JamesBond::Core::Mission
|
143
|
-
|
144
|
-
def build(config, params)
|
145
|
-
config.name = "Cassino"
|
146
|
-
config.main_commands = ["poker_face"]
|
147
|
-
|
148
|
-
arguments_parser do |parser|
|
149
|
-
parser.string "-t", "--target", "the poker face target"
|
150
|
-
parser.integer "--duration", "the poker face duration (in seconds)", default: 30
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def run_poker_face_command(params)
|
155
|
-
options = params[:command].options
|
156
|
-
poker_face_internal_method(options[:target], options[:duration])
|
157
|
-
end
|
158
|
-
|
159
|
-
def poker_face_internal_method(target, duration)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
let(:poker_face_to_le_chiffre) {
|
164
|
-
JamesBond::Core::Command.new(argv: ["poker_face", "--target", "Le Chiffre", "--duration", "10"],
|
165
|
-
env: "production")
|
166
|
-
}
|
167
|
-
let(:poker_face_to_felix) {
|
168
|
-
JamesBond::Core::Command.new(argv: ["poker_face", "--target", "Felix Leiter"],
|
169
|
-
env: "production")
|
170
|
-
}
|
171
|
-
|
172
|
-
it "should be able to store the option rules and use them to parse the arguments" do
|
173
|
-
mission = CassinoRoyaleMission.new
|
174
|
-
expect(mission).to receive(:poker_face_internal_method).with("Le Chiffre", 10)
|
175
|
-
mission.run_command(
|
176
|
-
command: poker_face_to_le_chiffre,
|
177
|
-
mission_pool: double("mission_pool")
|
178
|
-
)
|
179
|
-
|
180
|
-
mission = CassinoRoyaleMission.new
|
181
|
-
expect(mission).to receive(:poker_face_internal_method).with("Felix Leiter", 30)
|
182
|
-
mission.run_command(
|
183
|
-
command: poker_face_to_felix,
|
184
|
-
mission_pool: double("mission_pool")
|
185
|
-
)
|
186
|
-
end
|
187
|
-
|
188
|
-
it "stores option results in #results" do
|
189
|
-
mission = CassinoRoyaleMission.new
|
190
|
-
|
191
|
-
expect(mission.option_rules).to be
|
192
|
-
expect(mission.option_rules.to_s).to match /the poker face duration/
|
193
|
-
end
|
194
|
-
|
195
|
-
describe "#core_mission_options" do
|
196
|
-
let(:command) { JamesBond::Core::Command.new(argv: ["poker_face", "--target", "Vesper Lynd"], env: "dev") }
|
197
|
-
subject { CassinoRoyaleMission.new }
|
198
|
-
|
199
|
-
it "should return the options selected by the mission" do
|
200
|
-
subject.run_command(
|
201
|
-
command: command,
|
202
|
-
mission_pool: double("mission pool")
|
203
|
-
)
|
204
|
-
expect(subject.core_mission_options).to be
|
205
|
-
expect(subject.core_mission_options[:target]).to eq("Vesper Lynd")
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|