social_snippet 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,8 @@ class SocialSnippet::Snippet
7
7
  # Constructor
8
8
  def initialize(snippet_path)
9
9
  @path = snippet_path
10
- @code = ::File.read(@path)
11
- @lines = @code.split("\n")
10
+ @code = ::File.read(path)
11
+ @lines = code.split($/)
12
12
  end
13
13
 
14
14
  end
@@ -50,9 +50,9 @@ class SocialSnippet::TagParser
50
50
 
51
51
  def get_lines(s)
52
52
  if s.is_a?(String)
53
- return s.split("\n")
53
+ s.split($/)
54
54
  elsif s.is_a?(Array)
55
- return s
55
+ s
56
56
  end
57
57
  end
58
58
 
@@ -0,0 +1,18 @@
1
+ module SocialSnippet
2
+
3
+ require "tsort"
4
+
5
+ class TSortableHash < ::Hash
6
+
7
+ include ::TSort
8
+
9
+ alias tsort_each_node each_key
10
+
11
+ def tsort_each_child(node, &block)
12
+ fetch(node).each(&block)
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
@@ -1,6 +1,6 @@
1
1
  module SocialSnippet
2
2
 
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
 
5
5
  module Version
6
6
 
@@ -17,17 +17,21 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_runtime_dependency "bundler"
21
- spec.add_runtime_dependency "rake"
22
- spec.add_runtime_dependency "version_sorter"
20
+ spec.add_runtime_dependency "version_sorter", "~> 1.1.0"
23
21
  spec.add_runtime_dependency "rugged", ["~> 0.21.4", ">= 0.21.4"]
24
- spec.add_runtime_dependency "rest-client"
22
+ spec.add_runtime_dependency "rest-client", "~> 1.7.0"
23
+ spec.add_runtime_dependency "highline", "~> 1.6.0"
25
24
 
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
26
27
  spec.add_development_dependency "yard"
27
- spec.add_development_dependency "pry"
28
28
  spec.add_development_dependency "guard"
29
29
  spec.add_development_dependency "guard-shell"
30
- spec.add_development_dependency "pry-byebug"
30
+
31
+ if ENV["SOCIAL_SNIPPET_DEBUG"] == "true"
32
+ spec.add_development_dependency "pry"
33
+ spec.add_development_dependency "pry-byebug"
34
+ end
31
35
 
32
36
  spec.add_development_dependency "rspec"
33
37
  spec.add_development_dependency "fakefs"
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ module SocialSnippet::CommandLine
4
+
5
+ describe SSpm::SubCommands::InitCommand, :current => true do
6
+
7
+ describe "$ sspm init" do
8
+
9
+ let(:sspm_init_command) { SSpm::SubCommands::InitCommand .new [] }
10
+
11
+ example do
12
+ expect(fake_social_snippet.api).to receive(:init_manifest).with({}).once
13
+ sspm_init_command.init
14
+ sspm_init_command.run
15
+ end
16
+
17
+ end
18
+
19
+ end # SSpm::InitCommand
20
+
21
+ end # SocialSnippet::CommandLine
@@ -30,14 +30,14 @@ module SocialSnippet
30
30
  ' "language": "C++",',
31
31
  ' "main": "src/"',
32
32
  '}',
33
- ].join("\n")
33
+ ].join($/)
34
34
 
35
35
  # src/get_42.cpp
36
36
  File.write "#{repo_path}/my-repo/src/get_42.cpp", [
37
37
  'int get_42() {',
38
38
  ' return 42;',
39
39
  '}',
40
- ].join("\n")
40
+ ].join($/)
41
41
 
42
42
  repo_config = Proc.new do |path|
43
43
  repo = ::SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/my-repo")
@@ -62,7 +62,7 @@ module SocialSnippet
62
62
  ' std::cout << get_42() << std::endl;',
63
63
  ' return 0;',
64
64
  '}',
65
- ].join("\n")
65
+ ].join($/)
66
66
  end
67
67
 
68
68
  let(:output) do
@@ -73,7 +73,7 @@ module SocialSnippet
73
73
  ' std::cout << get_42() << std::endl;',
74
74
  ' return 0;',
75
75
  '}',
76
- ].join("\n")
76
+ ].join($/)
77
77
  end
78
78
 
79
79
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -93,7 +93,7 @@ module SocialSnippet
93
93
  ' std::cout << get_42() << std::endl;',
94
94
  ' return 0;',
95
95
  '}',
96
- ].join("\n")
96
+ ].join($/)
97
97
  end
98
98
 
99
99
  let(:output) do
@@ -109,7 +109,7 @@ module SocialSnippet
109
109
  ' std::cout << get_42() << std::endl;',
110
110
  ' return 0;',
111
111
  '}',
112
- ].join("\n")
112
+ ].join($/)
113
113
  end
114
114
 
115
115
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -0,0 +1,131 @@
1
+ require "spec_helper"
2
+
3
+ describe SocialSnippet::Resolvers::InsertResolver, :current => true do
4
+
5
+ context "prepare stubs" do
6
+
7
+ before do
8
+ allow(fake_social_snippet.repo_manager).to receive(:resolve_snippet_path) do |c, t|
9
+ t.repo
10
+ end
11
+ allow(fake_social_snippet.repo_manager).to receive(:get_snippet) do |c, t|
12
+ t.repo
13
+ end
14
+ end
15
+
16
+ context "no options" do
17
+
18
+ let(:resolver) do
19
+ ::SocialSnippet::Resolvers::InsertResolver.new(fake_social_snippet)
20
+ end
21
+
22
+ let(:input) do
23
+ [
24
+ "// @snip <my-repo-1:path/to/file.d>",
25
+ "// @snip <my-repo-2:path/to/file.d>",
26
+ "// @snip <my-repo-3:path/to/file.d>",
27
+ ].join($/)
28
+ end
29
+
30
+ let(:expected) do
31
+ [
32
+ "// @snippet <my-repo-1:path/to/file.d>",
33
+ "my-repo-1",
34
+ "// @snippet <my-repo-2:path/to/file.d>",
35
+ "my-repo-2",
36
+ "// @snippet <my-repo-3:path/to/file.d>",
37
+ "my-repo-3",
38
+ ].join($/)
39
+ end
40
+
41
+ subject { resolver.insert input }
42
+ it { should eq expected }
43
+
44
+ end # no options
45
+
46
+ context ":margin_top => 3" do
47
+
48
+ let(:resolver) do
49
+ ::SocialSnippet::Resolvers::InsertResolver.new(fake_social_snippet, {
50
+ :margin_top => 3,
51
+ })
52
+ end
53
+
54
+ let(:input) do
55
+ [
56
+ "// @snip <my-repo-1:path/to/file.d>",
57
+ "// @snip <my-repo-2:path/to/file.d>",
58
+ "// @snip <my-repo-3:path/to/file.d>",
59
+ ].join($/)
60
+ end
61
+
62
+ let(:expected) do
63
+ [
64
+ "",
65
+ "",
66
+ "",
67
+ "// @snippet <my-repo-1:path/to/file.d>",
68
+ "my-repo-1",
69
+ "",
70
+ "",
71
+ "",
72
+ "// @snippet <my-repo-2:path/to/file.d>",
73
+ "my-repo-2",
74
+ "",
75
+ "",
76
+ "",
77
+ "// @snippet <my-repo-3:path/to/file.d>",
78
+ "my-repo-3",
79
+ ].join($/)
80
+ end
81
+
82
+ subject { resolver.insert input }
83
+ it { should eq expected }
84
+
85
+ end # :margin_top
86
+
87
+ context ":margin_bottom => 3" do
88
+
89
+ let(:resolver) do
90
+ ::SocialSnippet::Resolvers::InsertResolver.new(fake_social_snippet, {
91
+ :margin_bottom => 3,
92
+ })
93
+ end
94
+
95
+ let(:input) do
96
+ [
97
+ "// @snip <my-repo-1:path/to/file.d>",
98
+ "// @snip <my-repo-2:path/to/file.d>",
99
+ "// @snip <my-repo-3:path/to/file.d>",
100
+ ].join($/)
101
+ end
102
+
103
+ let(:expected) do
104
+ [
105
+ "// @snippet <my-repo-1:path/to/file.d>",
106
+ "my-repo-1",
107
+ "",
108
+ "",
109
+ "",
110
+ "// @snippet <my-repo-2:path/to/file.d>",
111
+ "my-repo-2",
112
+ "",
113
+ "",
114
+ "",
115
+ "// @snippet <my-repo-3:path/to/file.d>",
116
+ "my-repo-3",
117
+ "",
118
+ "",
119
+ "",
120
+ ].join($/)
121
+ end
122
+
123
+ subject { resolver.insert input }
124
+ it { should eq expected }
125
+
126
+ end # :margin_bottom
127
+
128
+ end # prepare stubs
129
+
130
+ end # SocialSnippet::Resolvers::InsertResolver
131
+
@@ -26,7 +26,7 @@ module SocialSnippet
26
26
  [
27
27
  '#include <iostream>',
28
28
  '',
29
- ].join("\n").freeze
29
+ ].join($/).freeze
30
30
  end
31
31
 
32
32
  it { expect(instance.to_s).to eq output }
@@ -44,7 +44,7 @@ module SocialSnippet
44
44
  '#include <iostream>',
45
45
  '',
46
46
  '// @snippet<my-repo:path/to/func.cpp>',
47
- ].join("\n").freeze
47
+ ].join($/).freeze
48
48
  end
49
49
 
50
50
  it { expect(instance.to_s).to eq output }
@@ -67,7 +67,7 @@ module SocialSnippet
67
67
  'code',
68
68
  'code',
69
69
  'code',
70
- ].join("\n").freeze
70
+ ].join($/).freeze
71
71
  end
72
72
 
73
73
  it { expect(instance.to_s).to eq output }
@@ -101,7 +101,7 @@ module SocialSnippet
101
101
  '1',
102
102
  '2',
103
103
  '3',
104
- ].join("\n").freeze
104
+ ].join($/).freeze
105
105
  end
106
106
 
107
107
  it { expect(instance.to_s).to eq output }
@@ -115,7 +115,7 @@ module SocialSnippet
115
115
  '1',
116
116
  '2',
117
117
  '3',
118
- ].join("\n").freeze
118
+ ].join($/).freeze
119
119
  end
120
120
 
121
121
  it { expect(instance.to_s).to eq output }
@@ -134,7 +134,7 @@ module SocialSnippet
134
134
  '2',
135
135
  '3',
136
136
  'a',
137
- ].join("\n").freeze
137
+ ].join($/).freeze
138
138
  end
139
139
 
140
140
  it { expect(instance.to_s).to eq output }
@@ -161,7 +161,7 @@ module SocialSnippet
161
161
  'AAA',
162
162
  'BBB',
163
163
  'CCC',
164
- ].join("\n")
164
+ ].join($/)
165
165
  end
166
166
 
167
167
  it { should eq output }
@@ -19,7 +19,7 @@ module SocialSnippet::Repository::Drivers
19
19
  ' "desc": "my-desc",',
20
20
  ' "main": "my-src"',
21
21
  '}',
22
- ].join("\n")
22
+ ].join($/)
23
23
  end # prepare /path/to/repo
24
24
 
25
25
  context "load snippet.json" do
@@ -56,7 +56,7 @@ module SocialSnippet::Repository::Drivers
56
56
  ' "desc": "my-desc",',
57
57
  ' "main": "src"',
58
58
  '}',
59
- ].join("\n")
59
+ ].join($/)
60
60
  end # prepare install_path
61
61
 
62
62
  context "load snippet.json" do
@@ -88,7 +88,7 @@ module SocialSnippet::Repository
88
88
  ' "language": "C++",',
89
89
  ' "main": "src"',
90
90
  '}',
91
- ].join("\n")
91
+ ].join($/)
92
92
 
93
93
  allow(repo_manager).to receive(:find_repository).with("repo_a") do |path|
94
94
  repo = ::SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/repo_a")
@@ -137,7 +137,7 @@ module SocialSnippet::Repository
137
137
  ' "desc": "this is repo_a",',
138
138
  ' "language": "C++"',
139
139
  '}',
140
- ].join("\n")
140
+ ].join($/)
141
141
  end
142
142
 
143
143
  before do
@@ -216,7 +216,7 @@ module SocialSnippet::Repository::Drivers
216
216
  ' "desc": "this is repo_1",',
217
217
  ' "language": "Ruby"',
218
218
  '}',
219
- ].join("\n")
219
+ ].join($/)
220
220
  end
221
221
 
222
222
  context "create repo_1 instance" do
@@ -267,7 +267,7 @@ module SocialSnippet::Repository::Drivers
267
267
  ' "desc": "this is repo_1",',
268
268
  ' "language": "Ruby"',
269
269
  '}',
270
- ].join("\n")
270
+ ].join($/)
271
271
 
272
272
  # create repo_b
273
273
  FileUtils.mkdir_p "/path/to/repo_b"
@@ -279,7 +279,7 @@ module SocialSnippet::Repository::Drivers
279
279
  ' "desc": "this is repo_b",',
280
280
  ' "language": "Ruby"',
281
281
  '}',
282
- ].join("\n")
282
+ ].join($/)
283
283
 
284
284
  # create repo_3
285
285
  FileUtils.mkdir_p "/path/to/repo_3"
@@ -291,7 +291,7 @@ module SocialSnippet::Repository::Drivers
291
291
  ' "desc": "this is repo_3",',
292
292
  ' "language": "Ruby"',
293
293
  '}',
294
- ].join("\n")
294
+ ].join($/)
295
295
  end # before
296
296
 
297
297
  context "create three instances" do
data/test/core_test.rb CHANGED
@@ -70,11 +70,11 @@ describe SocialSnippet::Core do
70
70
  # snippet.json
71
71
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
72
72
  '{"name": "' + repo_name + '"}'
73
- ].join("\n")
73
+ ].join($/)
74
74
 
75
75
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/file.c", [
76
76
  '/* file.c */'
77
- ].join("\n")
77
+ ].join($/)
78
78
 
79
79
  end # prepare my-repo#thisisdu
80
80
 
@@ -86,7 +86,7 @@ describe SocialSnippet::Core do
86
86
  [
87
87
  '/* main.c */',
88
88
  '@snip<my-repo#thisisdu:file.c>',
89
- ].join("\n")
89
+ ].join($/)
90
90
  end
91
91
 
92
92
  let(:output) do
@@ -94,7 +94,7 @@ describe SocialSnippet::Core do
94
94
  '/* main.c */',
95
95
  '@snippet<my-repo#thisisdu:file.c>',
96
96
  '/* file.c */',
97
- ].join("\n")
97
+ ].join($/)
98
98
  end
99
99
 
100
100
  subject { fake_social_snippet.api.insert_snippet input }
@@ -108,7 +108,7 @@ describe SocialSnippet::Core do
108
108
  [
109
109
  '/* main.c */',
110
110
  '@snip<my-repo#notexist:file.c>',
111
- ].join("\n")
111
+ ].join($/)
112
112
  end
113
113
 
114
114
  it do
@@ -129,7 +129,7 @@ describe SocialSnippet::Core do
129
129
  [
130
130
  '/* @snip<my-repo#1:func.c> */',
131
131
  'main',
132
- ].join("\n")
132
+ ].join($/)
133
133
  end
134
134
 
135
135
  context "release 1.0.0" do
@@ -146,11 +146,11 @@ describe SocialSnippet::Core do
146
146
  # snippet.json
147
147
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
148
148
  '{"name": "' + repo_name + '"}'
149
- ].join("\n")
149
+ ].join($/)
150
150
 
151
151
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
152
152
  'func: 1.0.0',
153
- ].join("\n")
153
+ ].join($/)
154
154
  end # prepare my-repo#1.0.0
155
155
 
156
156
  before { find_repo_mock }
@@ -160,7 +160,7 @@ describe SocialSnippet::Core do
160
160
  '/* @snippet<my-repo#1.0.0:func.c> */',
161
161
  'func: 1.0.0',
162
162
  'main',
163
- ].join("\n").freeze
163
+ ].join($/).freeze
164
164
  end
165
165
 
166
166
  context "release 1.0.1" do
@@ -177,11 +177,11 @@ describe SocialSnippet::Core do
177
177
  # snippet.json
178
178
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
179
179
  '{"name": "' + repo_name + '"}'
180
- ].join("\n")
180
+ ].join($/)
181
181
 
182
182
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
183
183
  'func: 1.0.1',
184
- ].join("\n")
184
+ ].join($/)
185
185
  end # prepare my-repo#1.0.1
186
186
 
187
187
  before { find_repo_mock }
@@ -191,7 +191,7 @@ describe SocialSnippet::Core do
191
191
  '/* @snippet<my-repo#1.0.1:func.c> */',
192
192
  'func: 1.0.1',
193
193
  'main',
194
- ].join("\n").freeze
194
+ ].join($/).freeze
195
195
  end
196
196
 
197
197
  context "release 1.1.0" do
@@ -208,11 +208,11 @@ describe SocialSnippet::Core do
208
208
  # snippet.json
209
209
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
210
210
  '{"name": "' + repo_name + '"}'
211
- ].join("\n")
211
+ ].join($/)
212
212
 
213
213
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
214
214
  'func: 1.1.0',
215
- ].join("\n")
215
+ ].join($/)
216
216
  end # prepare my-repo#1.1.0
217
217
 
218
218
  before { find_repo_mock }
@@ -222,7 +222,7 @@ describe SocialSnippet::Core do
222
222
  '/* @snippet<my-repo#1.1.0:func.c> */',
223
223
  'func: 1.1.0',
224
224
  'main',
225
- ].join("\n").freeze
225
+ ].join($/).freeze
226
226
  end
227
227
 
228
228
  context "release 9.9.9" do
@@ -239,11 +239,11 @@ describe SocialSnippet::Core do
239
239
  # snippet.json
240
240
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
241
241
  '{"name": "' + repo_name + '"}'
242
- ].join("\n")
242
+ ].join($/)
243
243
 
244
244
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
245
245
  'func: 9.9.9',
246
- ].join("\n")
246
+ ].join($/)
247
247
  end # prepare my-repo#9.9.9
248
248
 
249
249
  before { find_repo_mock }
@@ -253,7 +253,7 @@ describe SocialSnippet::Core do
253
253
  '/* @snippet<my-repo#1.1.0:func.c> */',
254
254
  'func: 1.1.0',
255
255
  'main',
256
- ].join("\n").freeze
256
+ ].join($/).freeze
257
257
  end
258
258
 
259
259
  end # release 9.9.9
@@ -289,26 +289,26 @@ describe SocialSnippet::Core do
289
289
  # snippet.json
290
290
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
291
291
  '{"name": "' + repo_name + '", "main": "src"}'
292
- ].join("\n")
292
+ ].join($/)
293
293
 
294
294
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/file_1", [
295
295
  '@snip<subdir_a/file_2>',
296
296
  'file_1',
297
- ].join("\n")
297
+ ].join($/)
298
298
 
299
299
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_a/file_2", [
300
300
  '@snip<../subdir_b/file_3>',
301
301
  'file_2',
302
- ].join("\n")
302
+ ].join($/)
303
303
 
304
304
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_b/file_3", [
305
305
  '@snip<../subdir_c/file_4>',
306
306
  'file_3',
307
- ].join("\n")
307
+ ].join($/)
308
308
 
309
309
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_c/file_4", [
310
310
  'file_4',
311
- ].join("\n")
311
+ ].join($/)
312
312
  end # prepare my-repo#1.2.3
313
313
 
314
314
  before { find_repo_mock }
@@ -319,7 +319,7 @@ describe SocialSnippet::Core do
319
319
  [
320
320
  '@snip <my-repo:file_1>',
321
321
  'main',
322
- ].join("\n").freeze
322
+ ].join($/).freeze
323
323
  end
324
324
 
325
325
  let(:output) do
@@ -333,7 +333,7 @@ describe SocialSnippet::Core do
333
333
  '@snippet <my-repo#1.2.3:file_1>',
334
334
  'file_1',
335
335
  'main',
336
- ].join("\n").freeze
336
+ ].join($/).freeze
337
337
  end
338
338
 
339
339
  subject { fake_social_snippet.api.insert_snippet input }
@@ -358,12 +358,12 @@ describe SocialSnippet::Core do
358
358
  # snippet.json
359
359
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
360
360
  '{"name": "' + repo_name + '"}'
361
- ].join("\n")
361
+ ].join($/)
362
362
 
363
363
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1", [
364
364
  '@snip<1>',
365
365
  '1',
366
- ].join("\n")
366
+ ].join($/)
367
367
  end # prepare directly#3.2.1
368
368
 
369
369
  before do
@@ -379,12 +379,12 @@ describe SocialSnippet::Core do
379
379
  # snippet.json
380
380
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
381
381
  '{"name": "' + repo_name + '"}'
382
- ].join("\n")
382
+ ].join($/)
383
383
 
384
384
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop", [
385
385
  '@snip<loop-2:loop>',
386
386
  'loop-1',
387
- ].join("\n")
387
+ ].join($/)
388
388
  end # prepare loop-1#1.1.1
389
389
 
390
390
  before do
@@ -400,12 +400,12 @@ describe SocialSnippet::Core do
400
400
  # snippet.json
401
401
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
402
402
  '{"name": "' + repo_name + '"}'
403
- ].join("\n")
403
+ ].join($/)
404
404
 
405
405
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop", [
406
406
  '@snip<loop-3:loop>',
407
407
  'loop-2',
408
- ].join("\n")
408
+ ].join($/)
409
409
  end # prepare loop-2#1.1.1
410
410
 
411
411
  before do
@@ -421,13 +421,13 @@ describe SocialSnippet::Core do
421
421
  # snippet.json
422
422
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
423
423
  '{"name": "' + repo_name + '"}'
424
- ].join("\n")
424
+ ].join($/)
425
425
 
426
426
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop", [
427
427
  '@snip<loop-1:loop>',
428
428
  '@snip<non-loop-4:non-loop>',
429
429
  'loop-3',
430
- ].join("\n")
430
+ ].join($/)
431
431
  end # prepare loop-3#1.1.1
432
432
 
433
433
  before do
@@ -443,11 +443,11 @@ describe SocialSnippet::Core do
443
443
  # snippet.json
444
444
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
445
445
  '{"name": "' + repo_name + '"}'
446
- ].join("\n")
446
+ ].join($/)
447
447
 
448
448
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/non-loop", [
449
449
  'non-loop-4',
450
- ].join("\n")
450
+ ].join($/)
451
451
  end # prepare non-loop-4#1.1.1
452
452
 
453
453
  before { find_repo_mock }
@@ -460,7 +460,7 @@ describe SocialSnippet::Core do
460
460
  [
461
461
  '@snip<loop-1:loop>',
462
462
  'main',
463
- ].join("\n")
463
+ ].join($/)
464
464
  end
465
465
 
466
466
  let(:output) do
@@ -474,7 +474,7 @@ describe SocialSnippet::Core do
474
474
  '@snippet<loop-1#1.1.1:loop>',
475
475
  'loop-1',
476
476
  'main',
477
- ].join("\n")
477
+ ].join($/)
478
478
  end
479
479
 
480
480
  subject { fake_social_snippet.api.insert_snippet input }
@@ -491,14 +491,14 @@ describe SocialSnippet::Core do
491
491
  let(:input) do
492
492
  [
493
493
  '@snip<directly:1>',
494
- ].join("\n").freeze
494
+ ].join($/).freeze
495
495
  end
496
496
 
497
497
  let(:output) do
498
498
  [
499
499
  '@snippet<directly#3.2.1:1>',
500
500
  '1',
501
- ].join("\n")
501
+ ].join($/)
502
502
  end
503
503
 
504
504
  subject { fake_social_snippet.api.insert_snippet input }
@@ -525,12 +525,12 @@ describe SocialSnippet::Core do
525
525
  # snippet.json
526
526
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
527
527
  '{"name": "' + repo_name + '"}'
528
- ].join("\n")
528
+ ].join($/)
529
529
 
530
530
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1", [
531
531
  '@snip<my-repo-2#0:2>',
532
532
  'my-repo-1:1',
533
- ].join("\n")
533
+ ].join($/)
534
534
  end # prepare my-repo-1
535
535
 
536
536
  before do
@@ -546,12 +546,12 @@ describe SocialSnippet::Core do
546
546
  # snippet.json
547
547
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
548
548
  '{"name": "' + repo_name + '"}'
549
- ].join("\n")
549
+ ].join($/)
550
550
 
551
551
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2", [
552
552
  '@snip<my-repo-3:path/to/3>',
553
553
  'my-repo-2:2',
554
- ].join("\n")
554
+ ].join($/)
555
555
  end # prepare my-repo-2#0.0.1
556
556
 
557
557
  before do
@@ -567,11 +567,11 @@ describe SocialSnippet::Core do
567
567
  # snippet.json
568
568
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
569
569
  '{"name": "' + repo_name + '"}'
570
- ].join("\n")
570
+ ].join($/)
571
571
 
572
572
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2", [
573
573
  'miss!!',
574
- ].join("\n")
574
+ ].join($/)
575
575
  end # prepare my-repo-2#1.2.3
576
576
 
577
577
  before do
@@ -589,12 +589,12 @@ describe SocialSnippet::Core do
589
589
  # snippet.json
590
590
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
591
591
  '{"name": "' + repo_name + '"}'
592
- ].join("\n")
592
+ ].join($/)
593
593
 
594
594
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/path/to/3", [
595
595
  '@snip<my-repo-4:path/to/4>',
596
596
  'my-repo-3:path/to/3',
597
- ].join("\n")
597
+ ].join($/)
598
598
  end # prepare my-repo-3#1.2.3
599
599
 
600
600
  before do
@@ -614,12 +614,12 @@ describe SocialSnippet::Core do
614
614
  # snippet.json
615
615
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
616
616
  '{"name": "' + repo_name + '", "main": "sources"}'
617
- ].join("\n")
617
+ ].join($/)
618
618
 
619
619
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/4", [
620
620
  '@snip<my-repo-5:path/to/5>',
621
621
  'my-repo-4:sources/path/to/4',
622
- ].join("\n")
622
+ ].join($/)
623
623
  end # prepare my-repo-4#1.2.3
624
624
 
625
625
  before do
@@ -639,12 +639,12 @@ describe SocialSnippet::Core do
639
639
  # snippet.json
640
640
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
641
641
  '{"name": "' + repo_name + '", "main": "sources"}'
642
- ].join("\n")
642
+ ].join($/)
643
643
 
644
644
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/5", [
645
645
  '@snip<my-repo-6:path/to/6>',
646
646
  'my-repo-5:sources/path/to/5',
647
- ].join("\n")
647
+ ].join($/)
648
648
  end # prepare my-repo-5#100.200.300
649
649
 
650
650
  before do
@@ -664,12 +664,12 @@ describe SocialSnippet::Core do
664
664
  # snippet.json
665
665
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
666
666
  '{"name": "' + repo_name + '", "main": "sources"}'
667
- ].join("\n")
667
+ ].join($/)
668
668
 
669
669
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/5", [
670
670
  'miss!!',
671
671
  'my-repo-5:5',
672
- ].join("\n")
672
+ ].join($/)
673
673
  end # prepare my-repo-5#99.999.999
674
674
 
675
675
  before do
@@ -686,12 +686,12 @@ describe SocialSnippet::Core do
686
686
  # snippet.json
687
687
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
688
688
  '{"name": "' + repo_name + '", "main": "sources"}'
689
- ].join("\n")
689
+ ].join($/)
690
690
 
691
691
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/sources/path/to/6", [
692
692
  '@snip<my-repo-7:path/to/7>',
693
693
  'my-repo-6:sources/path/to/6',
694
- ].join("\n")
694
+ ].join($/)
695
695
  end # prepare my-repo-6
696
696
 
697
697
  before do
@@ -711,12 +711,12 @@ describe SocialSnippet::Core do
711
711
  # snippet.json
712
712
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
713
713
  '{"name": "' + repo_name + '", "main": "sources"}'
714
- ].join("\n")
714
+ ].join($/)
715
715
 
716
716
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/7", [
717
717
  'end',
718
718
  'my-repo-7:sources/path/to/7',
719
- ].join("\n")
719
+ ].join($/)
720
720
  end # prepare my-repo-7#1.2.3
721
721
 
722
722
  before { find_repo_mock }
@@ -726,7 +726,7 @@ describe SocialSnippet::Core do
726
726
  let(:input) do
727
727
  [
728
728
  '/* @snip <my-repo-1:1> */',
729
- ].join("\n").freeze
729
+ ].join($/).freeze
730
730
  end
731
731
 
732
732
  let(:output) do
@@ -746,7 +746,7 @@ describe SocialSnippet::Core do
746
746
  'my-repo-2:2',
747
747
  '/* @snippet <my-repo-1#0.0.1:1> */',
748
748
  'my-repo-1:1',
749
- ].join("\n").freeze
749
+ ].join($/).freeze
750
750
  end
751
751
 
752
752
  subject { fake_social_snippet.api.insert_snippet input }
@@ -779,7 +779,7 @@ describe SocialSnippet::Core do
779
779
  # snippet.json
780
780
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
781
781
  '{"name": "' + repo_name + '"}'
782
- ].join("\n")
782
+ ].join($/)
783
783
 
784
784
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1", [
785
785
  '@snip<5>',
@@ -787,7 +787,7 @@ describe SocialSnippet::Core do
787
787
  '@snip<3>',
788
788
  '@snip<2>',
789
789
  '1',
790
- ].join("\n")
790
+ ].join($/)
791
791
 
792
792
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2", [
793
793
  '@snip<9>',
@@ -795,35 +795,35 @@ describe SocialSnippet::Core do
795
795
  '@snip<7>',
796
796
  '@snip<6>',
797
797
  '2',
798
- ].join("\n")
798
+ ].join($/)
799
799
 
800
800
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/3", [
801
801
  '3',
802
- ].join("\n")
802
+ ].join($/)
803
803
 
804
804
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/4", [
805
805
  '4',
806
- ].join("\n")
806
+ ].join($/)
807
807
 
808
808
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/5", [
809
809
  '5',
810
- ].join("\n")
810
+ ].join($/)
811
811
 
812
812
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/6", [
813
813
  '6',
814
- ].join("\n")
814
+ ].join($/)
815
815
 
816
816
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/7", [
817
817
  '7',
818
- ].join("\n")
818
+ ].join($/)
819
819
 
820
820
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/8", [
821
821
  '8',
822
- ].join("\n")
822
+ ].join($/)
823
823
 
824
824
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/9", [
825
825
  '9',
826
- ].join("\n")
826
+ ].join($/)
827
827
  end
828
828
 
829
829
  before { find_repo_mock }
@@ -832,7 +832,7 @@ describe SocialSnippet::Core do
832
832
  [
833
833
  '@snip<my-repo:1>',
834
834
  'main',
835
- ].join("\n").freeze
835
+ ].join($/).freeze
836
836
  end
837
837
 
838
838
  let(:output) do
@@ -856,7 +856,7 @@ describe SocialSnippet::Core do
856
856
  '@snippet<my-repo#0.0.1:1>',
857
857
  '1',
858
858
  'main',
859
- ].join("\n")
859
+ ].join($/)
860
860
  end
861
861
 
862
862
  subject { fake_social_snippet.api.insert_snippet input }
@@ -881,18 +881,18 @@ describe SocialSnippet::Core do
881
881
  # snippet.json
882
882
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
883
883
  '{"name": "' + repo_name + '", "main": "src"}',
884
- ].join("\n")
884
+ ].join($/)
885
885
 
886
886
  # src/1.rb
887
887
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
888
888
  '# @snip</2.rb>',
889
889
  'OK',
890
- ].join("\n")
890
+ ].join($/)
891
891
 
892
892
  # src/2.rb
893
893
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
894
894
  '0.0.3',
895
- ].join("\n")
895
+ ].join($/)
896
896
 
897
897
  end # prepare my-repo#0.0.3
898
898
 
@@ -911,7 +911,7 @@ describe SocialSnippet::Core do
911
911
  # snippet.json
912
912
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
913
913
  '{"name": "' + repo_name + '", "main": "src"}',
914
- ].join("\n")
914
+ ].join($/)
915
915
 
916
916
  # src/1.rb
917
917
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
@@ -919,12 +919,12 @@ describe SocialSnippet::Core do
919
919
  'def func_1',
920
920
  ' return 2 * func_2()',
921
921
  'end',
922
- ].join("\n")
922
+ ].join($/)
923
923
 
924
924
  # src/2.rb
925
925
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
926
926
  'ERROR_CASE',
927
- ].join("\n")
927
+ ].join($/)
928
928
 
929
929
  end # prepare my-repo#0.0.2
930
930
 
@@ -943,7 +943,7 @@ describe SocialSnippet::Core do
943
943
  # snippet.json
944
944
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
945
945
  '{"name": "' + repo_name + '", "main": "src"}',
946
- ].join("\n")
946
+ ].join($/)
947
947
 
948
948
  # src/1.rb
949
949
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
@@ -951,12 +951,12 @@ describe SocialSnippet::Core do
951
951
  'def func_1',
952
952
  ' return 2 * func_2()',
953
953
  'end',
954
- ].join("\n")
954
+ ].join($/)
955
955
 
956
956
  # src/2.rb
957
957
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
958
958
  'ERROR_CASE',
959
- ].join("\n")
959
+ ].join($/)
960
960
 
961
961
  end # prepare my-repo#0.0.1
962
962
 
@@ -975,7 +975,7 @@ describe SocialSnippet::Core do
975
975
  # snippet.json
976
976
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
977
977
  '{"name": "' + repo_name + '", "main": "src"}',
978
- ].join("\n")
978
+ ].join($/)
979
979
 
980
980
  # src/1.rb
981
981
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
@@ -983,12 +983,12 @@ describe SocialSnippet::Core do
983
983
  'def func_1',
984
984
  ' return 2 * func_2()',
985
985
  'end',
986
- ].join("\n")
986
+ ].join($/)
987
987
 
988
988
  # src/2.rb
989
989
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
990
990
  'THIS_IS_OK',
991
- ].join("\n")
991
+ ].join($/)
992
992
  end # prepare my-repo#1.0.0
993
993
 
994
994
  before do
@@ -1005,12 +1005,12 @@ describe SocialSnippet::Core do
1005
1005
  # snippet.json
1006
1006
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
1007
1007
  '{"name": "' + repo_name + '", "main": "src"}',
1008
- ].join("\n")
1008
+ ].join($/)
1009
1009
 
1010
1010
  # src/1.rb
1011
1011
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
1012
1012
  'OLD VERSION',
1013
- ].join("\n")
1013
+ ].join($/)
1014
1014
  end # prepare new-my-repo#0.0.1
1015
1015
 
1016
1016
  before do
@@ -1029,7 +1029,7 @@ describe SocialSnippet::Core do
1029
1029
  # snippet.json
1030
1030
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
1031
1031
  '{"name": "' + repo_name + '", "main": "src"}',
1032
- ].join("\n")
1032
+ ].join($/)
1033
1033
 
1034
1034
  # src/1.rb
1035
1035
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
@@ -1037,17 +1037,17 @@ describe SocialSnippet::Core do
1037
1037
  '# @snip </2.rb>',
1038
1038
  '# @snip <3.rb>',
1039
1039
  'GOOD VERSION',
1040
- ].join("\n")
1040
+ ].join($/)
1041
1041
 
1042
1042
  # src/2.rb
1043
1043
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
1044
1044
  'OK: 2.rb',
1045
- ].join("\n")
1045
+ ].join($/)
1046
1046
 
1047
1047
  # src/3.rb
1048
1048
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/3.rb", [
1049
1049
  'OK: 3.rb',
1050
- ].join("\n")
1050
+ ].join($/)
1051
1051
  end # prepare new-my-repo#0.0.2
1052
1052
 
1053
1053
  before do
@@ -1059,7 +1059,7 @@ describe SocialSnippet::Core do
1059
1059
  let(:input) do
1060
1060
  [
1061
1061
  '@snip<my-repo:1.rb>',
1062
- ].join("\n")
1062
+ ].join($/)
1063
1063
  end
1064
1064
 
1065
1065
  let(:output) do
@@ -1070,7 +1070,7 @@ describe SocialSnippet::Core do
1070
1070
  'def func_1',
1071
1071
  ' return 2 * func_2()',
1072
1072
  'end',
1073
- ].join("\n")
1073
+ ].join($/)
1074
1074
  end
1075
1075
 
1076
1076
  subject { fake_social_snippet.api.insert_snippet input }
@@ -1083,7 +1083,7 @@ describe SocialSnippet::Core do
1083
1083
  let(:input) do
1084
1084
  [
1085
1085
  '@snip<my-repo#1:1.rb>',
1086
- ].join("\n")
1086
+ ].join($/)
1087
1087
  end
1088
1088
 
1089
1089
  let(:output) do
@@ -1094,7 +1094,7 @@ describe SocialSnippet::Core do
1094
1094
  'def func_1',
1095
1095
  ' return 2 * func_2()',
1096
1096
  'end',
1097
- ].join("\n")
1097
+ ].join($/)
1098
1098
  end
1099
1099
 
1100
1100
  subject { fake_social_snippet.api.insert_snippet input }
@@ -1108,7 +1108,7 @@ describe SocialSnippet::Core do
1108
1108
  [
1109
1109
  '@snip<my-repo#1:1.rb>',
1110
1110
  '@snip<my-repo#0:1.rb>',
1111
- ].join("\n")
1111
+ ].join($/)
1112
1112
  end
1113
1113
 
1114
1114
  let(:output) do
@@ -1123,7 +1123,7 @@ describe SocialSnippet::Core do
1123
1123
  '0.0.3',
1124
1124
  '@snippet<my-repo#0.0.3:1.rb>',
1125
1125
  'OK',
1126
- ].join("\n")
1126
+ ].join($/)
1127
1127
  end
1128
1128
 
1129
1129
  subject { fake_social_snippet.api.insert_snippet input }
@@ -1136,7 +1136,7 @@ describe SocialSnippet::Core do
1136
1136
  let(:input) do
1137
1137
  [
1138
1138
  '# @snip <new-my-repo:1.rb>',
1139
- ].join("\n")
1139
+ ].join($/)
1140
1140
  end
1141
1141
 
1142
1142
  let(:output) do
@@ -1151,7 +1151,7 @@ describe SocialSnippet::Core do
1151
1151
  'OK: 3.rb',
1152
1152
  '# @snippet <new-my-repo#0.0.2:1.rb>',
1153
1153
  'GOOD VERSION',
1154
- ].join("\n")
1154
+ ].join($/)
1155
1155
  end
1156
1156
 
1157
1157
  subject { fake_social_snippet.api.insert_snippet input }
@@ -1178,7 +1178,7 @@ describe SocialSnippet::Core do
1178
1178
  # snippet.json
1179
1179
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
1180
1180
  '{"name": "' + repo_name + '", "main": "src"}',
1181
- ].join("\n")
1181
+ ].join($/)
1182
1182
 
1183
1183
  # src/1.rb
1184
1184
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
@@ -1186,14 +1186,14 @@ describe SocialSnippet::Core do
1186
1186
  'def func_1',
1187
1187
  ' return 2 * func_2()',
1188
1188
  'end',
1189
- ].join("\n")
1189
+ ].join($/)
1190
1190
 
1191
1191
  # src/2.rb
1192
1192
  File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
1193
1193
  'def func_2',
1194
1194
  ' return 42',
1195
1195
  'end',
1196
- ].join("\n")
1196
+ ].join($/)
1197
1197
 
1198
1198
  end # prepare my-repo#0.0.3
1199
1199
 
@@ -1202,7 +1202,7 @@ describe SocialSnippet::Core do
1202
1202
  let(:input) do
1203
1203
  [
1204
1204
  '#@snip <my-repo:1.rb>',
1205
- ].join("\n")
1205
+ ].join($/)
1206
1206
  end
1207
1207
 
1208
1208
  let(:output) do
@@ -1215,7 +1215,7 @@ describe SocialSnippet::Core do
1215
1215
  'def func_1',
1216
1216
  ' return 2 * func_2()',
1217
1217
  'end',
1218
- ].join("\n")
1218
+ ].join($/)
1219
1219
  end
1220
1220
 
1221
1221
  subject { fake_social_snippet.api.insert_snippet input }
@@ -1240,7 +1240,7 @@ describe SocialSnippet::Core do
1240
1240
  # snippet.json
1241
1241
  File.write "#{repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
1242
1242
  '{"name": "' + repo_name + '", "main": "src"}',
1243
- ].join("\n")
1243
+ ].join($/)
1244
1244
 
1245
1245
  # src/1.rb
1246
1246
  File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
@@ -1248,14 +1248,14 @@ describe SocialSnippet::Core do
1248
1248
  'def func_1',
1249
1249
  ' return 2 * func_2()',
1250
1250
  'end',
1251
- ].join("\n")
1251
+ ].join($/)
1252
1252
 
1253
1253
  # src/2.rb
1254
1254
  File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
1255
1255
  'def func_2',
1256
1256
  ' return 42',
1257
1257
  'end',
1258
- ].join("\n")
1258
+ ].join($/)
1259
1259
 
1260
1260
  allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name, ref_name) do
1261
1261
  repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}/#{ref_name}")
@@ -1286,7 +1286,7 @@ describe SocialSnippet::Core do
1286
1286
  # snippet.json
1287
1287
  File.write "#{repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
1288
1288
  '{"name": "' + repo_name + '", "main": "src"}',
1289
- ].join("\n")
1289
+ ].join($/)
1290
1290
 
1291
1291
  # src/1.rb
1292
1292
  File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
@@ -1294,14 +1294,14 @@ describe SocialSnippet::Core do
1294
1294
  'def func_1',
1295
1295
  ' return 2 * func_2()',
1296
1296
  'end',
1297
- ].join("\n")
1297
+ ].join($/)
1298
1298
 
1299
1299
  # src/2.rb
1300
1300
  File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
1301
1301
  'def func_2',
1302
1302
  ' return 10000 + 42',
1303
1303
  'end',
1304
- ].join("\n")
1304
+ ].join($/)
1305
1305
 
1306
1306
  allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name, ref_name) do
1307
1307
  repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}/#{ref_name}")
@@ -1323,7 +1323,7 @@ describe SocialSnippet::Core do
1323
1323
  '# main.rb',
1324
1324
  '# @snip <my-repo#0.0.1:1.rb>',
1325
1325
  'puts func_1',
1326
- ].join("\n")
1326
+ ].join($/)
1327
1327
  end
1328
1328
 
1329
1329
  let(:output) do
@@ -1338,7 +1338,7 @@ describe SocialSnippet::Core do
1338
1338
  ' return 2 * func_2()',
1339
1339
  'end',
1340
1340
  'puts func_1',
1341
- ].join("\n")
1341
+ ].join($/)
1342
1342
  end
1343
1343
 
1344
1344
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1353,7 +1353,7 @@ describe SocialSnippet::Core do
1353
1353
  '# main.rb',
1354
1354
  '# @snip <my-repo#0.0.2:1.rb>',
1355
1355
  'puts func_1',
1356
- ].join("\n")
1356
+ ].join($/)
1357
1357
  end
1358
1358
 
1359
1359
  let(:output) do
@@ -1368,7 +1368,7 @@ describe SocialSnippet::Core do
1368
1368
  ' return 2 * func_2()',
1369
1369
  'end',
1370
1370
  'puts func_1',
1371
- ].join("\n")
1371
+ ].join($/)
1372
1372
  end
1373
1373
 
1374
1374
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1383,7 +1383,7 @@ describe SocialSnippet::Core do
1383
1383
  '# main.rb',
1384
1384
  '# @snip <my-repo#0.0.2:1.rb>',
1385
1385
  '# @snip <my-repo#0.0.1:1.rb>',
1386
- ].join("\n")
1386
+ ].join($/)
1387
1387
  end
1388
1388
 
1389
1389
  let(:output) do
@@ -1405,7 +1405,7 @@ describe SocialSnippet::Core do
1405
1405
  'def func_1',
1406
1406
  ' return 2 * func_2()',
1407
1407
  'end',
1408
- ].join("\n")
1408
+ ].join($/)
1409
1409
  end
1410
1410
 
1411
1411
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1431,7 +1431,7 @@ describe SocialSnippet::Core do
1431
1431
  # snippet.json
1432
1432
  File.write "#{repo_path}/#{repo_name}/snippet.json", [
1433
1433
  '{"name": "' + repo_name + '", "main": "src"}',
1434
- ].join("\n")
1434
+ ].join($/)
1435
1435
 
1436
1436
  # src/1.rb
1437
1437
  File.write "#{repo_path}/#{repo_name}/src/1.rb", [
@@ -1439,14 +1439,14 @@ describe SocialSnippet::Core do
1439
1439
  'def func_1',
1440
1440
  ' return 2 * func_2()',
1441
1441
  'end',
1442
- ].join("\n")
1442
+ ].join($/)
1443
1443
 
1444
1444
  # src/2.rb
1445
1445
  File.write "#{repo_path}/#{repo_name}/src/2.rb", [
1446
1446
  'def func_2',
1447
1447
  ' return 42',
1448
1448
  'end',
1449
- ].join("\n")
1449
+ ].join($/)
1450
1450
 
1451
1451
  repo_config = Proc.new do |path|
1452
1452
  repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
@@ -1467,7 +1467,7 @@ describe SocialSnippet::Core do
1467
1467
  '# main.rb',
1468
1468
  '# @snip <my-repo:1.rb>',
1469
1469
  'puts func_1',
1470
- ].join("\n")
1470
+ ].join($/)
1471
1471
  end
1472
1472
 
1473
1473
  let(:output) do
@@ -1482,7 +1482,7 @@ describe SocialSnippet::Core do
1482
1482
  ' return 2 * func_2()',
1483
1483
  'end',
1484
1484
  'puts func_1',
1485
- ].join("\n")
1485
+ ].join($/)
1486
1486
  end
1487
1487
 
1488
1488
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1507,23 +1507,23 @@ describe SocialSnippet::Core do
1507
1507
  # snippet.json
1508
1508
  File.write "#{repo_path}/#{repo_name}/snippet.json", [
1509
1509
  '{"name": "' + repo_name + '"}',
1510
- ].join("\n")
1510
+ ].join($/)
1511
1511
 
1512
1512
  # a.rb
1513
1513
  File.write "#{repo_path}/#{repo_name}/a.rb", [
1514
1514
  '# @snip <./a/1.rb>',
1515
1515
  '# @snip <./a/2.rb>',
1516
- ].join("\n")
1516
+ ].join($/)
1517
1517
 
1518
1518
  # a/1.rb
1519
1519
  File.write "#{repo_path}/#{repo_name}/a/1.rb", [
1520
1520
  'puts "1"',
1521
- ].join("\n")
1521
+ ].join($/)
1522
1522
 
1523
1523
  # a/2.rb
1524
1524
  File.write "#{repo_path}/#{repo_name}/a/2.rb", [
1525
1525
  'puts "2"',
1526
- ].join("\n")
1526
+ ].join($/)
1527
1527
 
1528
1528
  repo_config = Proc.new do |path|
1529
1529
  repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
@@ -1541,7 +1541,7 @@ describe SocialSnippet::Core do
1541
1541
  let(:input) do
1542
1542
  [
1543
1543
  "# @snip<my-repo:a.rb>"
1544
- ].join("\n")
1544
+ ].join($/)
1545
1545
  end
1546
1546
 
1547
1547
  let(:output) do
@@ -1551,7 +1551,7 @@ describe SocialSnippet::Core do
1551
1551
  '# @snippet<my-repo#' + short_commit_id + ':a/2.rb>',
1552
1552
  'puts "2"',
1553
1553
  '# @snippet<my-repo#' + short_commit_id + ':a.rb>',
1554
- ].join("\n")
1554
+ ].join($/)
1555
1555
  end
1556
1556
 
1557
1557
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1576,14 +1576,14 @@ describe SocialSnippet::Core do
1576
1576
  # snippet.json
1577
1577
  File.write "#{repo_path}/#{repo_name}/snippet.json", [
1578
1578
  '{"name": "' + repo_name + '"}',
1579
- ].join("\n")
1579
+ ].join($/)
1580
1580
 
1581
1581
  # parent
1582
1582
  File.write "#{repo_path}/#{repo_name}/parent", [
1583
1583
  '@snip<child_1>',
1584
1584
  '@snip<child_2>',
1585
1585
  '@snip<child_3>',
1586
- ].join("\n")
1586
+ ].join($/)
1587
1587
 
1588
1588
  repo_config = Proc.new do |path|
1589
1589
  repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
@@ -1601,7 +1601,7 @@ describe SocialSnippet::Core do
1601
1601
  let(:input) do
1602
1602
  [
1603
1603
  '@snip <repo-a:parent>',
1604
- ].join("\n")
1604
+ ].join($/)
1605
1605
  end
1606
1606
 
1607
1607
  let(:output) do
@@ -1610,7 +1610,7 @@ describe SocialSnippet::Core do
1610
1610
  '@snippet <repo-a#' + short_commit_id + ':child_2>',
1611
1611
  '@snippet <repo-a#' + short_commit_id + ':child_3>',
1612
1612
  '@snippet <repo-a#' + short_commit_id + ':parent>',
1613
- ].join("\n")
1613
+ ].join($/)
1614
1614
  end
1615
1615
 
1616
1616
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1635,7 +1635,7 @@ describe SocialSnippet::Core do
1635
1635
  # snippet.json
1636
1636
  File.write "#{repo_path}/#{repo_name}/snippet.json", [
1637
1637
  '{"name": "' + repo_name + '"}',
1638
- ].join("\n")
1638
+ ].join($/)
1639
1639
 
1640
1640
  # parent
1641
1641
  File.write "#{repo_path}/#{repo_name}/parent", [
@@ -1646,7 +1646,7 @@ describe SocialSnippet::Core do
1646
1646
  '@snip<child_1>',
1647
1647
  '@snip<child_2>',
1648
1648
  '@snip<child_3>',
1649
- ].join("\n")
1649
+ ].join($/)
1650
1650
 
1651
1651
  repo_config = Proc.new do |path|
1652
1652
  repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
@@ -1667,7 +1667,7 @@ describe SocialSnippet::Core do
1667
1667
  '@snip<my_repo:child_3>',
1668
1668
  '@snip<my_repo:child_2>',
1669
1669
  '@snip<my_repo:child_1>',
1670
- ].join("\n")
1670
+ ].join($/)
1671
1671
  end
1672
1672
 
1673
1673
  let(:output) do
@@ -1676,7 +1676,7 @@ describe SocialSnippet::Core do
1676
1676
  '@snippet <my_repo#' + short_commit_id + ':child_2>',
1677
1677
  '@snippet <my_repo#' + short_commit_id + ':child_3>',
1678
1678
  '@snippet <my_repo#' + short_commit_id + ':parent>',
1679
- ].join("\n")
1679
+ ].join($/)
1680
1680
  end
1681
1681
 
1682
1682
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1706,23 +1706,23 @@ describe SocialSnippet::Core do
1706
1706
  ' "name": "' + repo_name + '",',
1707
1707
  ' "main": "src"',
1708
1708
  '}',
1709
- ].join("\n")
1709
+ ].join($/)
1710
1710
 
1711
1711
  # src/1
1712
1712
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/1", [
1713
1713
  '@snip<2>',
1714
1714
  '@snip<3>',
1715
- ].join("\n")
1715
+ ].join($/)
1716
1716
 
1717
1717
  # src/2
1718
1718
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/2", [
1719
1719
  '2',
1720
- ].join("\n")
1720
+ ].join($/)
1721
1721
 
1722
1722
  # src/3
1723
1723
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/3", [
1724
1724
  '3',
1725
- ].join("\n")
1725
+ ].join($/)
1726
1726
  end # prepare for my-repo
1727
1727
 
1728
1728
  before do
@@ -1745,24 +1745,24 @@ describe SocialSnippet::Core do
1745
1745
  ' "name": "' + repo_name + '",',
1746
1746
  ' "main": "src"',
1747
1747
  '}',
1748
- ].join("\n")
1748
+ ].join($/)
1749
1749
 
1750
1750
  # src/1
1751
1751
  File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/1", [
1752
1752
  '@snip<2>',
1753
1753
  '@snip<3>',
1754
1754
  '0.0.1: 1',
1755
- ].join("\n")
1755
+ ].join($/)
1756
1756
 
1757
1757
  # src/2
1758
1758
  File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/2", [
1759
1759
  '0.0.1: 2',
1760
- ].join("\n")
1760
+ ].join($/)
1761
1761
 
1762
1762
  # src/3
1763
1763
  File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/3", [
1764
1764
  '0.0.1: 3',
1765
- ].join("\n")
1765
+ ].join($/)
1766
1766
  end # prepare has-version#0.0.1
1767
1767
 
1768
1768
  before do
@@ -1785,24 +1785,24 @@ describe SocialSnippet::Core do
1785
1785
  ' "name": "' + repo_name + '",',
1786
1786
  ' "main": "src"',
1787
1787
  '}',
1788
- ].join("\n")
1788
+ ].join($/)
1789
1789
 
1790
1790
  # src/1
1791
1791
  File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/1", [
1792
1792
  '@snip<2>',
1793
1793
  '@snip<3>',
1794
1794
  '1.2.3: 1',
1795
- ].join("\n")
1795
+ ].join($/)
1796
1796
 
1797
1797
  # src/2
1798
1798
  File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/2", [
1799
1799
  '1.2.3: 2',
1800
- ].join("\n")
1800
+ ].join($/)
1801
1801
 
1802
1802
  # src/3
1803
1803
  File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/3", [
1804
1804
  '1.2.3: 3',
1805
- ].join("\n")
1805
+ ].join($/)
1806
1806
  end # prepare has-version#1.2.3
1807
1807
 
1808
1808
  before do
@@ -1817,7 +1817,7 @@ describe SocialSnippet::Core do
1817
1817
  [
1818
1818
  '@snip<has-version#0:1>',
1819
1819
  '@snip<has-version#1:1>',
1820
- ].join("\n").freeze
1820
+ ].join($/).freeze
1821
1821
  end
1822
1822
 
1823
1823
  let(:output) do
@@ -1834,7 +1834,7 @@ describe SocialSnippet::Core do
1834
1834
  '1.2.3: 3',
1835
1835
  '@snippet<has-version#1.2.3:1>',
1836
1836
  '1.2.3: 1',
1837
- ].join("\n").freeze
1837
+ ].join($/).freeze
1838
1838
  end
1839
1839
 
1840
1840
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1849,7 +1849,7 @@ describe SocialSnippet::Core do
1849
1849
  '@snippet<has-version#0.0.1:1>',
1850
1850
  '@snip<has-version#0:1>',
1851
1851
  '@snip<has-version#1:1>',
1852
- ].join("\n").freeze
1852
+ ].join($/).freeze
1853
1853
  end
1854
1854
 
1855
1855
  let(:output) do
@@ -1861,7 +1861,7 @@ describe SocialSnippet::Core do
1861
1861
  '1.2.3: 3',
1862
1862
  '@snippet<has-version#1.2.3:1>',
1863
1863
  '1.2.3: 1',
1864
- ].join("\n").freeze
1864
+ ].join($/).freeze
1865
1865
  end
1866
1866
 
1867
1867
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1877,7 +1877,7 @@ describe SocialSnippet::Core do
1877
1877
  '@snip<has-version#0:1>',
1878
1878
  '@snip<my-repo:1>',
1879
1879
  '@snip<has-version:1>',
1880
- ].join("\n").freeze
1880
+ ].join($/).freeze
1881
1881
  end
1882
1882
 
1883
1883
  let(:output) do
@@ -1894,7 +1894,7 @@ describe SocialSnippet::Core do
1894
1894
  '1.2.3: 3',
1895
1895
  '@snippet<has-version#1.2.3:1>',
1896
1896
  '1.2.3: 1',
1897
- ].join("\n").freeze
1897
+ ].join($/).freeze
1898
1898
  end
1899
1899
 
1900
1900
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1913,7 +1913,7 @@ describe SocialSnippet::Core do
1913
1913
  '',
1914
1914
  '@snip<my-repo:1>',
1915
1915
  '@snip<my-repo:2>',
1916
- ].join("\n")
1916
+ ].join($/)
1917
1917
  end
1918
1918
 
1919
1919
  let(:output) do
@@ -1924,7 +1924,7 @@ describe SocialSnippet::Core do
1924
1924
  '@snippet<my-repo#' + short_commit_id + ':2>',
1925
1925
  '2',
1926
1926
  '@snippet<my-repo#' + short_commit_id + ':1>',
1927
- ].join("\n")
1927
+ ].join($/)
1928
1928
  end
1929
1929
 
1930
1930
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1939,7 +1939,7 @@ describe SocialSnippet::Core do
1939
1939
  '@snip<my-repo:1>',
1940
1940
  '@snip<my-repo:2>',
1941
1941
  '@snip<my-repo:3>',
1942
- ].join("\n")
1942
+ ].join($/)
1943
1943
  end
1944
1944
 
1945
1945
  let(:output) do
@@ -1949,7 +1949,7 @@ describe SocialSnippet::Core do
1949
1949
  '@snippet<my-repo#' + short_commit_id + ':3>',
1950
1950
  '3',
1951
1951
  '@snippet<my-repo#' + short_commit_id + ':1>',
1952
- ].join("\n")
1952
+ ].join($/)
1953
1953
  end
1954
1954
 
1955
1955
  subject { fake_social_snippet.api.insert_snippet(input) }
@@ -1977,14 +1977,14 @@ describe SocialSnippet::Core do
1977
1977
  ' "name": "' + repo_name + '",',
1978
1978
  ' "main": "src"',
1979
1979
  '}',
1980
- ].join("\n")
1980
+ ].join($/)
1981
1981
 
1982
1982
  # src/add_func.cpp
1983
1983
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/add_func.cpp", [
1984
1984
  'int add_func( int a, int b ) {',
1985
1985
  ' return a + b;',
1986
1986
  '}',
1987
- ].join("\n")
1987
+ ].join($/)
1988
1988
  end # prepare for my_lib repo
1989
1989
 
1990
1990
  before do
@@ -1999,7 +1999,7 @@ describe SocialSnippet::Core do
1999
1999
  # snippet.json
2000
2000
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
2001
2001
  '{"name": "' + repo_name + '"}',
2002
- ].join("\n")
2002
+ ].join($/)
2003
2003
 
2004
2004
  # use_add_func.cpp
2005
2005
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/use_add_func.cpp", [
@@ -2007,7 +2007,7 @@ describe SocialSnippet::Core do
2007
2007
  'int my_repo_a_use_add_func( int a, int b ) {',
2008
2008
  ' return add_func(a, b);',
2009
2009
  '}',
2010
- ].join("\n")
2010
+ ].join($/)
2011
2011
  end # prepare for my_repo_a repo
2012
2012
 
2013
2013
  before do
@@ -2022,7 +2022,7 @@ describe SocialSnippet::Core do
2022
2022
  # snippet.json
2023
2023
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
2024
2024
  '{"name": "' + repo_name + '"}',
2025
- ].join("\n")
2025
+ ].join($/)
2026
2026
 
2027
2027
  # use_add_func.cpp
2028
2028
  File.write "#{tmp_repo_path_no_ver}/#{repo_name}/use_add_func.cpp", [
@@ -2030,7 +2030,7 @@ describe SocialSnippet::Core do
2030
2030
  'int my_repo_b_use_add_func( int a, int b ) {',
2031
2031
  ' return add_func(a, b);',
2032
2032
  '}',
2033
- ].join("\n")
2033
+ ].join($/)
2034
2034
  end # prepare for my_repo_b repo
2035
2035
 
2036
2036
  before { find_repo_mock }
@@ -2048,7 +2048,7 @@ describe SocialSnippet::Core do
2048
2048
  ' std::cout << my_repo_a_use_add_func(a, b) << " == " << my_repo_a_use_add_func(a, b) << std::endl;',
2049
2049
  ' return 0;',
2050
2050
  '}',
2051
- ].join("\n")
2051
+ ].join($/)
2052
2052
  end
2053
2053
 
2054
2054
  let(:output) do
@@ -2074,7 +2074,7 @@ describe SocialSnippet::Core do
2074
2074
  ' std::cout << my_repo_a_use_add_func(a, b) << " == " << my_repo_a_use_add_func(a, b) << std::endl;',
2075
2075
  ' return 0;',
2076
2076
  '}',
2077
- ].join("\n")
2077
+ ].join($/)
2078
2078
  end
2079
2079
 
2080
2080
  context "call insert_snippet" do