bem 1.1.0 → 1.1.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.
- checksums.yaml +4 -4
- data/lib/bem/actions.rb +7 -3
- data/lib/bem/commands_tasks.rb +1 -0
- data/lib/bem/version.rb +1 -1
- data/spec/actions_spec.rb +121 -10
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da72844e774fbbf266a7c9820f3d5a6a0a8f020b
|
4
|
+
data.tar.gz: 490f23e2d974a380ea35b4b739fb8f7a95d5a4e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9c78d43fc32cdb20c945d144427e743a1980447e4b2dff3cb86ced217518572ae3a10fdd5716ff7ef869b16e493b4be9ce29b98af93e3a903278889e133bdcf
|
7
|
+
data.tar.gz: c50c7213cc02a6629bf4f588a566aa86e02aa02b1936ad9a502ef5c2a71615bbf44e5a00673f0d2e3d6fae658af69b33bf8bee9fd836a1a6e9c2f225d13b50d6
|
data/lib/bem/actions.rb
CHANGED
@@ -16,13 +16,17 @@ module BEM
|
|
16
16
|
BEM.configuration.technologies.each do |tech|
|
17
17
|
path = build_path_for(tech[:extension], options, tech[:group])
|
18
18
|
|
19
|
+
path_without_extension = path.split("#{ tech[:group] }/").last.sub(tech[:extension], '')
|
20
|
+
|
19
21
|
remove_file File.expand_path('..', path)
|
20
22
|
|
21
|
-
|
23
|
+
manifest_name = options[:manifest].present? ? options[:manifest] : 'application'
|
22
24
|
|
23
|
-
|
25
|
+
manifest = File.join(Rails.root, 'app', 'assets', tech[:group], manifest_name + tech[:extension])
|
26
|
+
|
27
|
+
path = options[:remove_from_manifest] ? manifest : level_path(options[:level], tech)
|
24
28
|
|
25
|
-
gsub_file(
|
29
|
+
gsub_file(path, string_to_append(tech, path_without_extension), '') if File.exist? path
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
data/lib/bem/commands_tasks.rb
CHANGED
@@ -27,6 +27,7 @@ class CommandsTasks < Thor
|
|
27
27
|
method_option :value, :type => :string, :aliases => '-v', :desc => 'Value for modificator.'
|
28
28
|
method_option :level, :type => :string, :aliases => '-l', :desc => 'Destroy or use given level.'
|
29
29
|
method_option :manifest, :type => :string, :aliases => '-a', :desc => 'Manifests to append level'
|
30
|
+
method_option :remove_from_manifest, :type => :boolean, :aliases => '-i', :desc => 'Remove css asset from manifest'
|
30
31
|
def destroy
|
31
32
|
destroy_with options
|
32
33
|
end
|
data/lib/bem/version.rb
CHANGED
data/spec/actions_spec.rb
CHANGED
@@ -32,7 +32,9 @@ describe BEM::Actions do
|
|
32
32
|
{ :js => true, :css => true }
|
33
33
|
end
|
34
34
|
|
35
|
-
it { expect(capture(:stdout) { subject }).to match "
|
35
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
36
|
+
"create spec/sandbox/app/assets/stylesheets/fakeapp/fakeapp.scss\n " +
|
37
|
+
"create spec/sandbox/app/assets/javascripts/fakeapp/fakeapp.js\n"
|
36
38
|
}
|
37
39
|
end
|
38
40
|
|
@@ -45,7 +47,8 @@ describe BEM::Actions do
|
|
45
47
|
{ :css => true }
|
46
48
|
end
|
47
49
|
|
48
|
-
it { expect(capture(:stdout) { subject }).to match "
|
50
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
51
|
+
"create spec/sandbox/app/assets/stylesheets/fakeapp/fakeapp.scss\n"
|
49
52
|
}
|
50
53
|
end
|
51
54
|
|
@@ -58,7 +61,9 @@ describe BEM::Actions do
|
|
58
61
|
{ :css => true, :level => 'somelevel' }
|
59
62
|
end
|
60
63
|
|
61
|
-
it { expect(capture(:stdout) { subject }).to match "
|
64
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
65
|
+
"create spec/sandbox/app/assets/stylesheets/somelevel/somelevel.scss\n" +
|
66
|
+
"javascripts are omitted\n"
|
62
67
|
}
|
63
68
|
end
|
64
69
|
|
@@ -71,7 +76,10 @@ describe BEM::Actions do
|
|
71
76
|
{ :css => true, :block => 'someblock' }
|
72
77
|
end
|
73
78
|
|
74
|
-
it { expect(capture(:stdout) { subject }).to match "
|
79
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
80
|
+
"create spec/sandbox/app/assets/stylesheets/fakeapp/someblock/someblock.scss\n " +
|
81
|
+
"append spec/sandbox/app/assets/stylesheets/fakeapp/fakeapp.scss\n" +
|
82
|
+
"javascripts are omitted\n"
|
75
83
|
}
|
76
84
|
end
|
77
85
|
|
@@ -79,14 +87,19 @@ describe BEM::Actions do
|
|
79
87
|
before do
|
80
88
|
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/someblock.scss"
|
81
89
|
|
82
|
-
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/__someelement/
|
90
|
+
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/__someelement/" +
|
91
|
+
"someblock__someelement.scss"
|
83
92
|
end
|
84
93
|
|
85
94
|
def options
|
86
95
|
{ :css => true, :block => 'someblock', :element => 'someelement' }
|
87
96
|
end
|
88
97
|
|
89
|
-
it { expect(capture(:stdout) { subject }).to match "
|
98
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
99
|
+
"create spec/sandbox/app/assets/stylesheets/fakeapp/someblock/__someelement/someblock__someelement.scss\n" +
|
100
|
+
" " +
|
101
|
+
"append spec/sandbox/app/assets/stylesheets/fakeapp/fakeapp.scss\n" +
|
102
|
+
"javascripts are omitted\n"
|
90
103
|
}
|
91
104
|
end
|
92
105
|
|
@@ -94,14 +107,18 @@ describe BEM::Actions do
|
|
94
107
|
before do
|
95
108
|
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/someblock.scss"
|
96
109
|
|
97
|
-
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/_somemod/
|
110
|
+
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/_somemod/" +
|
111
|
+
"someblock_somemod.scss"
|
98
112
|
end
|
99
113
|
|
100
114
|
def options
|
101
115
|
{ :css => true, :block => 'someblock', :modificator => 'somemod' }
|
102
116
|
end
|
103
117
|
|
104
|
-
it { expect(capture(:stdout) { subject }).to match "
|
118
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
119
|
+
"create spec/sandbox/app/assets/stylesheets/fakeapp/someblock/_somemod/someblock_somemod.scss\n " +
|
120
|
+
"append spec/sandbox/app/assets/stylesheets/fakeapp/fakeapp.scss\n" +
|
121
|
+
"javascripts are omitted\n"
|
105
122
|
}
|
106
123
|
end
|
107
124
|
|
@@ -109,14 +126,108 @@ describe BEM::Actions do
|
|
109
126
|
before do
|
110
127
|
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/someblock.scss"
|
111
128
|
|
112
|
-
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/__someelement/
|
129
|
+
@dummy_object.remove_file "#{ sandbox_root }/app/assets/stylesheets/fakeapp/someblock/__someelement/" +
|
130
|
+
"_somemod/someblock__someelement_somemod.scss"
|
113
131
|
end
|
114
132
|
|
115
133
|
def options
|
116
134
|
{ :css => true, :block => 'someblock', :modificator => 'somemod', :element => 'someelement' }
|
117
135
|
end
|
118
136
|
|
119
|
-
it { expect(capture(:stdout) { subject }).to match "
|
137
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
138
|
+
"create spec/sandbox/app/assets/stylesheets/fakeapp/someblock/__someelement/_somemod/" +
|
139
|
+
"someblock__someelement_somemod.scss\n " +
|
140
|
+
"append spec/sandbox/app/assets/stylesheets/fakeapp/fakeapp.scss\n" +
|
141
|
+
"javascripts are omitted\n"
|
142
|
+
}
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe '#destroy_with' do
|
147
|
+
before do
|
148
|
+
class DummyClass < Thor
|
149
|
+
include BEM::Actions
|
150
|
+
include Thor::Actions
|
151
|
+
|
152
|
+
def self.source_root
|
153
|
+
File.join(File.dirname(__FILE__), 'sandbox')
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
@dummy_object = DummyClass.new
|
158
|
+
|
159
|
+
@dummy_object.create_file 'spec/sandbox/scss.tt'
|
160
|
+
|
161
|
+
Rails.stub(:root).and_return(sandbox_root)
|
162
|
+
|
163
|
+
Rails.application.class.stub(:parent_name).and_return('fakeapp')
|
164
|
+
end
|
165
|
+
|
166
|
+
subject { @dummy_object.destroy_with(options) }
|
167
|
+
|
168
|
+
describe 'when empty default options' do
|
169
|
+
def options
|
170
|
+
{ :js => true, :css => true }
|
171
|
+
end
|
172
|
+
|
173
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
174
|
+
"remove spec/sandbox/app/assets/stylesheets/fakeapp\n " +
|
175
|
+
"remove spec/sandbox/app/assets/javascripts/fakeapp\n"
|
176
|
+
}
|
177
|
+
end
|
178
|
+
|
179
|
+
describe 'when destroy only specific level' do
|
180
|
+
def options
|
181
|
+
{ :level => 'somelevel' }
|
182
|
+
end
|
183
|
+
|
184
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
185
|
+
"remove spec/sandbox/app/assets/stylesheets/somelevel\n" + " "
|
186
|
+
"remove spec/sandbox/app/assets/stylesheets/somelevel\n"
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
describe 'when destroy a block' do
|
191
|
+
def options
|
192
|
+
{ :block => 'someblock' }
|
193
|
+
end
|
194
|
+
|
195
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
196
|
+
"remove spec/sandbox/app/assets/stylesheets/fakeapp/someblock\n " +
|
197
|
+
"remove spec/sandbox/app/assets/javascripts/fakeapp/someblock\n"
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
201
|
+
describe 'when destroy an element within a block' do
|
202
|
+
def options
|
203
|
+
{ :block => 'someblock', :element => 'someelement' }
|
204
|
+
end
|
205
|
+
|
206
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
207
|
+
"remove spec/sandbox/app/assets/stylesheets/fakeapp/someblock/__someelement\n" + " " +
|
208
|
+
"remove spec/sandbox/app/assets/javascripts/fakeapp/someblock/__someelement\n"
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
describe 'when destroy a block modificator' do
|
213
|
+
def options
|
214
|
+
{ :block => 'someblock', :modificator => 'somemod' }
|
215
|
+
end
|
216
|
+
|
217
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
218
|
+
"remove spec/sandbox/app/assets/stylesheets/fakeapp/someblock/_somemod\n " +
|
219
|
+
"remove spec/sandbox/app/assets/javascripts/fakeapp/someblock/_somemod\n"
|
220
|
+
}
|
221
|
+
end
|
222
|
+
|
223
|
+
describe 'when destroy an element modificator within a block' do
|
224
|
+
def options
|
225
|
+
{ :block => 'someblock', :modificator => 'somemod', :element => 'someelement' }
|
226
|
+
end
|
227
|
+
|
228
|
+
it { expect(capture(:stdout) { subject }).to match " " +
|
229
|
+
"remove spec/sandbox/app/assets/stylesheets/fakeapp/someblock/__someelement/_somemod\n " +
|
230
|
+
"remove spec/sandbox/app/assets/javascripts/fakeapp/someblock/__someelement/_somemod\n"
|
120
231
|
}
|
121
232
|
end
|
122
233
|
end
|