tradesman 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tradesman/parser.rb +2 -2
- data/spec/parser_spec.rb +90 -2
- data/spec/tradesman_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775cba2453d710d366ab8baefe83cb5f159bce97
|
4
|
+
data.tar.gz: 54e46fd0e368979137809e39398a6cec79319d74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fea98170b6eb07ee3e1415bcf6ef9231c2a9968a71994d8859e61c4d54654971e3fc223f8d4ef9ce01b98c107b8b6011880e53490c03134716bfe7fde2717ea
|
7
|
+
data.tar.gz: d182ec3e7ca01341b4224cc99144460cc6ab1ea569b6d4d829b7f156c0fcfdec01ced8755b75aa31106601b7a3757c36068987d39baad6ae4d66e1c06013c1ee
|
data/lib/tradesman/parser.rb
CHANGED
@@ -3,7 +3,7 @@ module Tradesman
|
|
3
3
|
attr_reader :class_name, :action_string, :subject_string, :parent_string
|
4
4
|
|
5
5
|
PARSE_REGEX = /(Create|Update|Delete)(.+)/
|
6
|
-
PARSE_REGEX_WITH_PARENT = /(Create
|
6
|
+
PARSE_REGEX_WITH_PARENT = /(Create)([A-Z]+.+)For([A-Z]+.+)/
|
7
7
|
|
8
8
|
def initialize(class_name)
|
9
9
|
@class_name = class_name
|
@@ -31,7 +31,7 @@ module Tradesman
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def regex
|
34
|
-
/.+
|
34
|
+
/.+For[A-Z]+.+/.match(@class_name) ? PARSE_REGEX_WITH_PARENT : PARSE_REGEX
|
35
35
|
end
|
36
36
|
|
37
37
|
def str_to_sym(str)
|
data/spec/parser_spec.rb
CHANGED
@@ -18,8 +18,8 @@ describe Tradesman::Parser do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
context '
|
22
|
-
subject { Tradesman::Parser.new('
|
21
|
+
context 'CreateUserForEmployer' do
|
22
|
+
subject { Tradesman::Parser.new('CreateUserForEmployer') }
|
23
23
|
|
24
24
|
it 'finds a match' do
|
25
25
|
expect(subject.match?).to be true
|
@@ -38,6 +38,94 @@ describe Tradesman::Parser do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
context 'CreateFortressForSkeletor' do
|
42
|
+
subject { Tradesman::Parser.new('CreateFortressForSkeletor') }
|
43
|
+
|
44
|
+
it 'finds a match' do
|
45
|
+
expect(subject.match?).to be true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'parses the action' do
|
49
|
+
expect(subject.action).to eq :create
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'parses the subject' do
|
53
|
+
expect(subject.subject).to eq :fortress
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'parses the parent' do
|
57
|
+
expect(subject.parent).to eq :skeletor
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'CreateCloudFormationForSky' do
|
62
|
+
subject { Tradesman::Parser.new('CreateCloudFormationForSky') }
|
63
|
+
|
64
|
+
it 'finds a match' do
|
65
|
+
expect(subject.match?).to be true
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'parses the action' do
|
69
|
+
expect(subject.action).to eq :create
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'parses the subject' do
|
73
|
+
expect(subject.subject).to eq :cloud_formation
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'parses the parent' do
|
77
|
+
expect(subject.parent).to eq :sky
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'CreateWallForFortress' do
|
82
|
+
subject { Tradesman::Parser.new('CreateWallForFortress') }
|
83
|
+
|
84
|
+
it 'finds a match' do
|
85
|
+
expect(subject.match?).to be true
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'parses the action' do
|
89
|
+
expect(subject.action).to eq :create
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'parses the subject' do
|
93
|
+
expect(subject.subject).to eq :wall
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'parses the parent' do
|
97
|
+
expect(subject.parent).to eq :fortress
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'CreateHailForCloudFormation' do
|
102
|
+
subject { Tradesman::Parser.new('CreateHailForCloudFormation') }
|
103
|
+
|
104
|
+
it 'finds a match' do
|
105
|
+
expect(subject.match?).to be true
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'parses the action' do
|
109
|
+
expect(subject.action).to eq :create
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'parses the subject' do
|
113
|
+
expect(subject.subject).to eq :hail
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'parses the parent' do
|
117
|
+
expect(subject.parent).to eq :cloud_formation
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'UpdateFortressForSkeletor' do
|
122
|
+
subject { Tradesman::Parser.new('UpdateFortressForSkeletor') }
|
123
|
+
|
124
|
+
it 'finds a match' do
|
125
|
+
expect(subject.match?).to be false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
41
129
|
context 'DeleteCustomerInvoice' do
|
42
130
|
subject { Tradesman::Parser.new('DeleteCustomerInvoice') }
|
43
131
|
|
data/spec/tradesman_spec.rb
CHANGED
@@ -81,7 +81,7 @@ describe Tradesman do
|
|
81
81
|
|
82
82
|
context 'for parent' do
|
83
83
|
let(:employer) { TradesmanSpec::Employer.create }
|
84
|
-
let(:outcome) { Tradesman::
|
84
|
+
let(:outcome) { Tradesman::CreateUserForEmployer.run(parent_id: employer.id, last_name: 'Turner') }
|
85
85
|
|
86
86
|
it 'creates a new record' do
|
87
87
|
expect(outcome.success?).to be true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tradesman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Turner
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: horza
|