dslable 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ tudu/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem "rspec", "~> 2.14.1"
5
+ gem "thor", "~> 0.18.1"
6
+ gem "simplecov", "~> 0.8.2"
7
+ gem "bundler", "~> 1.3.5"
8
+ gem "rspec_piccolo", "~> 0.0.6"
9
+ gem "activesupport", "~> 4.0.1"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 tbpgr
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,856 @@
1
+ # Dslable
2
+
3
+ Dslable is generator for simple spec gem.
4
+
5
+ ## Summary
6
+ * create gem template with DslSettingFile.
7
+ * you can get bin-executable gem.
8
+ * generated gem has 1-DslSettingFile.
9
+ * generated gem has 1-core logic class.
10
+ * generated gem has 1-dsl class.
11
+ * generated gem has 1-dsl-model class.
12
+ * generated gem has 1-core class's RSpec spec.
13
+ * generated gem has Gemfile.(already has minimum necessary gem)
14
+
15
+ ## Purpose
16
+ * to create simple spec gem easier.
17
+
18
+ ## Structure
19
+ ### Dsldefine
20
+ this is setting file.
21
+
22
+ set ...
23
+
24
+ * gem_name: your gem name. set snake case name
25
+ * bin_name: your bin name. set snake case name
26
+ * field: your dsl field.
27
+
28
+ ### generated code: lib/your_gem_name_core.rb
29
+ * main logic.
30
+ * init method generate DslSettingFile.
31
+ * execute method is main logic. you must edit additional logic manually.
32
+
33
+ ### generated code: lib/your_gem_name_dsl.rb
34
+ * this file keeps values from DslSettingFile.
35
+
36
+ ### generated code: lib/your_gem_name_dsl_model.rb
37
+ * this file define DslSettingFile's model.
38
+
39
+ ### generated code: bin/your_bin_name
40
+ * this file has command line interface logic.
41
+
42
+ ### generated code: spec/your_gem_name_core_spec.rb
43
+ * this file is RSpec spec for 'your_gem_name_core.rb'.
44
+
45
+ ## DSL List
46
+ ### Global DSL
47
+ | dsl | mean |
48
+ |:----------- |:------------ |
49
+ | gem_name |set your gem name.(snake_case)|
50
+ | bin_name |set your bin name.(snake_case)|
51
+ | field |set your field information by block|
52
+
53
+ ### Field DSL
54
+ | dsl | mean |
55
+ |:----------- |:------------ |
56
+ | desc |set your field description|
57
+
58
+ ### Args DSL
59
+ | dsl | mean |
60
+ |:----------- |:------------ |
61
+ | desc |set your args description |
62
+ | klass |set your args data type. you can choose [String, Array, Hash] |
63
+ | required |if you want to set required, use this. |
64
+ | default_value|if you want to set default value, use this. |
65
+
66
+ ## Installation
67
+
68
+ Add this line to your application's Gemfile:
69
+
70
+ gem 'dslable'
71
+
72
+ And then execute:
73
+
74
+ $ bundle
75
+
76
+ Or install it yourself as:
77
+
78
+ $ gem install dslable
79
+
80
+ ## Sample Usage
81
+ ### Sample Spec
82
+ * create FizzBuzzGem
83
+ * if you execute 'fizzbuzzgem', result is...
84
+ ~~~bash
85
+ 1 2 fizz 3 4 buzz 5 fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz
86
+ ~~~
87
+ * you can choose output 'fizz/buzz/fizzbuzz' or 'FIZZ/BUZZ/FIZZBUZZ' by setting file.
88
+ * you can set fizzbuzz range by setting file.
89
+
90
+ ### Steps: 'dslable init'. generate Dsldefine Template.
91
+ ~~~bash
92
+ $ dslable init
93
+ $ ls
94
+ Dsldefine
95
+ ~~~
96
+
97
+ Dsldefine Template Contents
98
+ ~~~ruby
99
+ # encoding: utf-8
100
+
101
+ # set your gem name. this is use in rb-filename and class-name
102
+ gem_name "TODO: set your gem_name"
103
+
104
+ # set your bin name
105
+ bin_name "TODO: set your bin_name"
106
+
107
+ # set your dsl filed
108
+ field :field_name1 do |f|
109
+ # set your field description
110
+ f.desc "field1 description"
111
+ f.args :args_name do |a|
112
+ # set your args description
113
+ a.desc "args description"
114
+ # you can use String, Array and Hash
115
+ a.klass String
116
+ # if you want not required, comment out following line
117
+ a.required
118
+ # if you comment out following line, default => nil
119
+ a.default_value "args_value2"
120
+ end
121
+ end
122
+
123
+ # field :field_name2 do |f|
124
+ # f.desc "field2 description"
125
+ # f.args :args_name do |a|
126
+ # a.desc "args description"
127
+ # a.klass String
128
+ # a.required
129
+ # a.default_value "args_value2"
130
+ # end
131
+ # end
132
+ ~~~
133
+
134
+ ### Steps: Edit Dsldefine manually.
135
+ ~~~ruby
136
+ # encoding: utf-8
137
+ gem_name "fizz_buzz_gem"
138
+
139
+ bin_name "fizzbuzzgem"
140
+
141
+ field :is_upper_case do |f|
142
+ f.desc "is_upper_case"
143
+ f.args :is_upper_case do |a|
144
+ a.desc "is_upper_case flg."
145
+ a.klass String
146
+ a.required
147
+ a.default_value "false"
148
+ end
149
+ end
150
+
151
+ field :range do |f|
152
+ f.desc "range"
153
+ f.args :range do |a|
154
+ a.desc "range."
155
+ a.klass Array
156
+ a.default_value (1..15).to_a
157
+ end
158
+ end
159
+ ~~~
160
+
161
+ ### Steps: 'dslable generate'. generate template.
162
+ ~~~bash
163
+ dslable generate
164
+ ~~~
165
+
166
+ FileTree
167
+ ~~~
168
+ fizz_buzz_gem
169
+ │ .gitignore
170
+ │ .rspec
171
+ │ fizz_buzz_gem.gemspec
172
+ │ Gemfile
173
+ │ LICENSE.txt
174
+ │ Rakefile
175
+ │ README.md
176
+
177
+ ├─.git
178
+ ├─bin
179
+ │ fizzbuzzgem
180
+
181
+ ├─lib
182
+ │ │ fizz_buzz_gem_core.rb
183
+ │ │ fizz_buzz_gem_dsl.rb
184
+ │ │ fizz_buzz_gem_dsl_model.rb
185
+ │ │
186
+ │ └─fizz_buzz_gem
187
+ │ version.rb
188
+
189
+ └─spec
190
+ fizz_buzz_gem_core_spec.rb
191
+ spec_helper.rb
192
+ ~~~
193
+
194
+ Gemfile Template
195
+ ~~~ruby
196
+ source 'https://rubygems.org'
197
+
198
+ gemspec
199
+ gem "rspec", "~> 2.14.1"
200
+ gem "thor", "~> 0.18.1"
201
+ gem "simplecov", "~> 0.8.2"
202
+ gem "activesupport", "~> 4.0.1"
203
+ gem "activemodel", "~> 4.0.2"
204
+ ~~~
205
+
206
+ core source Template
207
+ fizz_buzz_gem_core.rb
208
+ ~~~ruby
209
+ # encoding: utf-8
210
+ require 'fizz_buzz_gem_dsl'
211
+
212
+ module FizzBuzzGem
213
+ # FizzBuzzGem Core
214
+ class Core
215
+ FIZZ_BUZZ_GEM_FILE = "Fizzbuzzgemfile"
216
+ FIZZ_BUZZ_GEM_TEMPLATE =<<-EOS
217
+ # encoding: utf-8
218
+
219
+ # is_upper_case
220
+ # is_upper_case is required
221
+ # is_upper_case allow only String
222
+ # is_upper_case's default value => "false"
223
+ is_upper_case "false"
224
+
225
+ # range
226
+ # range allow only Array
227
+ # range's default value => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
228
+ range [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
229
+
230
+ EOS
231
+
232
+ #== generate Fizzbuzzgemfile to current directory.
233
+ def init
234
+ File.open(FIZZ_BUZZ_GEM_FILE, "w") {|f|f.puts FIZZ_BUZZ_GEM_TEMPLATE}
235
+ end
236
+
237
+ #== TODO: write your gem's specific contents
238
+ def execute
239
+ src = read_dsl
240
+ dsl = FizzBuzzGem::Dsl.new
241
+ dsl.instance_eval src
242
+
243
+ # TODO: implement your gem's specific logic
244
+
245
+ end
246
+
247
+ private
248
+ def read_dsl
249
+ File.open(FIZZ_BUZZ_GEM_FILE) {|f|f.read}
250
+ end
251
+ end
252
+ end
253
+ ~~~
254
+
255
+ dsl source Template
256
+ fizz_buzz_gem_dsl.rb
257
+ ~~~ruby
258
+ # encoding: utf-8
259
+ require 'fizz_buzz_gem_dsl_model'
260
+
261
+ module FizzBuzzGem
262
+ class Dsl
263
+ attr_accessor :fizz_buzz_gem
264
+
265
+ [:is_upper_case].each do |f|
266
+ define_method f do |value|
267
+ eval "@fizz_buzz_gem.#{f.to_s} = '#{value}'", binding
268
+ end
269
+ end
270
+
271
+ [:range].each do |f|
272
+ define_method f do |value|
273
+ eval "@fizz_buzz_gem.#{f.to_s} = #{value}", binding
274
+ end
275
+ end
276
+
277
+ def initialize
278
+ @fizz_buzz_gem = FizzBuzzGem::DslModel.new
279
+ @fizz_buzz_gem.is_upper_case = 'false'
280
+ @fizz_buzz_gem.range = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
281
+ end
282
+ end
283
+ end
284
+ ~~~
285
+
286
+ dsl model source Template
287
+ fizz_buzz_gem_dsl_model.rb
288
+ ~~~ruby
289
+ # encoding: utf-8
290
+ require 'active_model'
291
+
292
+ module FizzBuzzGem
293
+ class DslModel
294
+ include ActiveModel::Model
295
+
296
+ # is_upper_case
297
+ attr_accessor :is_upper_case
298
+ validates :is_upper_case, :presence => true
299
+
300
+ # range
301
+ attr_accessor :range
302
+
303
+ end
304
+ end
305
+ ~~~
306
+
307
+ bin source Template
308
+ ~~~ruby
309
+ #!/usr/bin/env ruby
310
+ # encoding: utf-8
311
+
312
+ require "fizz_buzz_gem_core"
313
+ require "fizz_buzz_gem/version"
314
+ require "thor"
315
+
316
+ module FizzBuzzGem
317
+ #= FizzBuzzGem CLI
318
+ class CLI < Thor
319
+ class_option :help, :type => :boolean, :aliases => '-h', :desc => 'help message.'
320
+ class_option :version, :type => :boolean, :desc => 'version'
321
+
322
+ desc "execute", "TODO: write your desc"
323
+ def execute
324
+ FizzBuzzGem::Core.new.execute
325
+ end
326
+
327
+ desc "init", "generate Fizzbuzzgemfile"
328
+ def init
329
+ FizzBuzzGem::Core.new.init
330
+ end
331
+
332
+ desc "version", "version"
333
+ def version
334
+ p FizzBuzzGem::VERSION
335
+ end
336
+ end
337
+ end
338
+
339
+ FizzBuzzGem::CLI.start(ARGV)
340
+ ~~~
341
+
342
+ spec source Template
343
+ ~~~ruby
344
+ # encoding: utf-8
345
+ require "spec_helper"
346
+ require "fizz_buzz_gem_core"
347
+
348
+ describe FizzBuzzGem::Core do
349
+
350
+ context :init do
351
+ cases = [
352
+ {
353
+ case_no: 1,
354
+ case_title: "case_title",
355
+ expected: "expected",
356
+
357
+ },
358
+ ]
359
+
360
+ cases.each do |c|
361
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
362
+ begin
363
+ case_before c
364
+
365
+ # -- given --
366
+ fizz_buzz_gem_core = FizzBuzzGem::Core.new
367
+
368
+ # -- when --
369
+ # TODO: implement execute code
370
+ # actual = fizz_buzz_gem_core.init
371
+
372
+ # -- then --
373
+ # TODO: implement assertion code
374
+ # ret = expect(actual).to eq(c[:expected])
375
+ ensure
376
+ case_after c
377
+
378
+ end
379
+ end
380
+
381
+ def case_before(c)
382
+ # implement each case before
383
+
384
+ end
385
+
386
+ def case_after(c)
387
+ # implement each case after
388
+ end
389
+ end
390
+ end
391
+
392
+ context :execute do
393
+ cases = [
394
+ {
395
+ case_no: 1,
396
+ case_title: "case_title",
397
+ expected: "expected",
398
+
399
+ },
400
+ ]
401
+
402
+ cases.each do |c|
403
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
404
+ begin
405
+ case_before c
406
+
407
+ # -- given --
408
+ fizz_buzz_gem_core = FizzBuzzGem::Core.new
409
+
410
+ # -- when --
411
+ # TODO: implement execute code
412
+ # actual = fizz_buzz_gem_core.execute
413
+
414
+ # -- then --
415
+ # TODO: implement assertion code
416
+ # ret = expect(actual).to eq(c[:expected])
417
+ ensure
418
+ case_after c
419
+
420
+ end
421
+ end
422
+
423
+ def case_before(c)
424
+ # implement each case before
425
+
426
+ end
427
+
428
+ def case_after(c)
429
+ # implement each case after
430
+ end
431
+ end
432
+ end
433
+
434
+ end
435
+ ~~~
436
+
437
+ ### Steps: implement 'fizz_buzz_core_spec.rb' manually. (TDD step)
438
+ ~~~ruby
439
+ # encoding: utf-8
440
+ require "spec_helper"
441
+ require "fizz_buzz_gem_core"
442
+
443
+ describe FizzBuzzGem::Core do
444
+
445
+ context :init do
446
+ cases = [
447
+ {
448
+ case_no: 1,
449
+ case_title: "output template",
450
+ expected: FizzBuzzGem::Core::FIZZ_BUZZ_GEM_TEMPLATE
451
+ },
452
+ ]
453
+
454
+ cases.each do |c|
455
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
456
+ begin
457
+ case_before c
458
+
459
+ # -- given --
460
+ fizz_buzz_core = FizzBuzzGem::Core.new
461
+
462
+ # -- when --
463
+ fizz_buzz_core.init
464
+
465
+ # -- then --
466
+ actual = File.read(FizzBuzzGem::Core::FIZZ_BUZZ_GEM_FILE)
467
+ expect(actual).to eq(c[:expected])
468
+ ensure
469
+ case_after c
470
+
471
+ end
472
+ end
473
+
474
+ def case_before(c)
475
+ # implement each case before
476
+ end
477
+
478
+ def case_after(c)
479
+ # implement each case after
480
+ FileUtils.rm_rf(FizzBuzzGem::Core::FIZZ_BUZZ_GEM_FILE) if File.exists? FizzBuzzGem::Core::FIZZ_BUZZ_GEM_FILE
481
+ end
482
+ end
483
+ end
484
+
485
+ context :execute do
486
+ FIZZBUZZGEMFILE_CASE1 =<<-EOS
487
+ # encoding: utf-8
488
+ is_upper_case "false"
489
+ EOS
490
+
491
+ FIZZBUZZGEMFILE_CASE2 =<<-EOS
492
+ # encoding: utf-8
493
+ is_upper_case "true"
494
+ range (1..16).to_a
495
+ EOS
496
+
497
+ cases = [
498
+ {
499
+ case_no: 1,
500
+ case_title: "upper false, range default",
501
+ fizzgemfile: FIZZBUZZGEMFILE_CASE1,
502
+ expected: "1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz",
503
+ },
504
+ {
505
+ case_no: 2,
506
+ case_title: "upper true, range 1..16",
507
+ fizzgemfile: FIZZBUZZGEMFILE_CASE2,
508
+ expected: "1 2 FIZZ 4 BUZZ FIZZ 7 8 FIZZ BUZZ 11 FIZZ 13 14 FIZZBUZZ 16",
509
+ },
510
+ ]
511
+
512
+ cases.each do |c|
513
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
514
+ begin
515
+ case_before c
516
+
517
+ # -- given --
518
+ fizz_buzz_gem_core = FizzBuzzGem::Core.new
519
+
520
+ # -- when --
521
+ actual = fizz_buzz_gem_core.execute
522
+
523
+ # -- then --
524
+ ret = expect(actual).to eq(c[:expected])
525
+ ensure
526
+ case_after c
527
+
528
+ end
529
+ end
530
+
531
+ def case_before(c)
532
+ # implement each case before
533
+ File.open(FizzBuzzGem::Core::FIZZ_BUZZ_GEM_FILE, "w") {|f|f.puts c[:fizzgemfile]}
534
+ end
535
+
536
+ def case_after(c)
537
+ # implement each case after
538
+ FileUtils.rm_rf(FizzBuzzGem::Core::FIZZ_BUZZ_GEM_FILE) if File.exists? FizzBuzzGem::Core::FIZZ_BUZZ_GEM_FILE
539
+ end
540
+ end
541
+ end
542
+
543
+ end
544
+ ~~~
545
+
546
+ ### Steps: execute 'rspec' and fail.
547
+ ~~~bash
548
+ $ rspec
549
+ Run options: include {:focus=>true}
550
+
551
+ All examples were filtered out; ignoring {:focus=>true}
552
+ .FF
553
+
554
+ Failures:
555
+
556
+ 1) FizzBuzzGem::Core execute |case_no=1|case_title=upper false, range default
557
+ Failure/Error: ret = expect(actual).to eq(c[:expected])
558
+
559
+ expected: "1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz"
560
+ got: "false"
561
+
562
+ (compared using ==)
563
+ # ./spec/fizz_buzz_gem_core_spec.rb:86:in `block (4 levels) in <top (required)>'
564
+
565
+ 2) FizzBuzzGem::Core execute |case_no=2|case_title=upper true, range 1..16
566
+ Failure/Error: ret = expect(actual).to eq(c[:expected])
567
+
568
+ expected: "1 2 FIZZ 4 BUZZ FIZZ 7 8 FIZZ BUZZ 11 FIZZ 13 14 FIZZBUZZ 16"
569
+ got: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
570
+
571
+ (compared using ==)
572
+ # ./spec/fizz_buzz_gem_core_spec.rb:86:in `block (4 levels) in <top (required)>'
573
+
574
+ Finished in 0.01 seconds
575
+ 3 examples, 2 failures
576
+
577
+ Failed examples:
578
+
579
+ rspec ./spec/fizz_buzz_gem_core_spec.rb:75 # FizzBuzzGem::Core execute |case_no=1|case_title=upper false, range default
580
+ rspec ./spec/fizz_buzz_gem_core_spec.rb:75 # FizzBuzzGem::Core execute |case_no=2|case_title=upper true, range 1..16
581
+
582
+ Randomized with seed 63051
583
+ ~~~
584
+
585
+ ### Steps: implement 'fizz_buzz_core.rb' manually.
586
+ ~~~ruby
587
+ # encoding: utf-8
588
+ require 'fizz_buzz_gem_dsl'
589
+
590
+ module FizzBuzzGem
591
+ # FizzBuzzGem Core
592
+ class Core
593
+ FIZZ_BUZZ_GEM_FILE = "Fizzbuzzgemfile"
594
+ FIZZ_BUZZ_GEM_TEMPLATE =<<-EOS
595
+ # encoding: utf-8
596
+
597
+ # is_upper_case
598
+ # is_upper_case is required
599
+ # is_upper_case allow only String
600
+ # is_upper_case's default value => "false"
601
+ is_upper_case "false"
602
+
603
+ # range
604
+ # range allow only Array
605
+ # range's default value => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
606
+ range [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
607
+
608
+ EOS
609
+
610
+ #== generate Fizzbuzzgemfile to current directory.
611
+ def init
612
+ File.open(FIZZ_BUZZ_GEM_FILE, "w") {|f|f.puts FIZZ_BUZZ_GEM_TEMPLATE}
613
+ end
614
+
615
+ #== TODO: write your gem's specific contents
616
+ def execute
617
+ src = read_dsl
618
+ dsl = FizzBuzzGem::Dsl.new
619
+ dsl.instance_eval src
620
+ output_fizzbuzz(dsl)
621
+ end
622
+
623
+ private
624
+ def read_dsl
625
+ File.open(FIZZ_BUZZ_GEM_FILE) {|f|f.read}
626
+ end
627
+
628
+ def output_fizzbuzz(dsl)
629
+ ret = []
630
+ dsl.fizz_buzz_gem.range.each do |i|
631
+ if i % 15 == 0
632
+ ret << 'fizzbuzz'
633
+ elsif i % 3 == 0
634
+ ret << 'fizz'
635
+ elsif i % 5 == 0
636
+ ret << 'buzz'
637
+ else
638
+ ret << i
639
+ end
640
+ end
641
+ output = ret.join(' ')
642
+ dsl.fizz_buzz_gem.is_upper_case == 'true' ? output.upcase : output
643
+ end
644
+ end
645
+ end
646
+ ~~~
647
+
648
+ ### Steps: execute rspec
649
+ ~~~bash
650
+ $rspec
651
+ Run options: include {:focus=>true}
652
+
653
+ All examples were filtered out; ignoring {:focus=>true}
654
+ ...
655
+
656
+ Finished in 0.011 seconds
657
+ 3 examples, 0 failures
658
+
659
+ Randomized with seed 29906
660
+ ~~~
661
+
662
+ ### Steps: Edit fizz_buzz_gem.gemspec manually
663
+ ~~~ruby
664
+ # coding: utf-8
665
+ lib = File.expand_path('../lib', __FILE__)
666
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
667
+ require 'fizz_buzz_gem/version'
668
+
669
+ Gem::Specification.new do |spec|
670
+ spec.name = "fizz_buzz_gem"
671
+ spec.version = FizzBuzzGem::VERSION
672
+ spec.authors = ["yourname"]
673
+ spec.email = ["your@mail.address"]
674
+ spec.description = %q{fizz buzz gem}
675
+ spec.summary = %q{fizz buzz gem}
676
+ spec.homepage = ""
677
+ spec.license = "MIT"
678
+
679
+ spec.files = `git ls-files`.split($/)
680
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
681
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
682
+ spec.require_paths = ["lib"]
683
+
684
+ spec.add_runtime_dependency "thor", "~> 0.18.1"
685
+ spec.add_runtime_dependency "activesupport", "~> 4.0.1"
686
+ spec.add_runtime_dependency "activemodel", "~> 4.0.2"
687
+
688
+ spec.add_development_dependency "bundler", "~> 1.3"
689
+ spec.add_development_dependency "rake"
690
+ spec.add_development_dependency "rspec", "~> 2.14.1"
691
+ spec.add_development_dependency "simplecov", "~> 0.8.2"
692
+ end
693
+ ~~~
694
+
695
+ ### Steps: Edit bin bin/fizzbuzzgem manually
696
+ ~~~ruby
697
+ #!/usr/bin/env ruby
698
+ # encoding: utf-8
699
+
700
+ require "fizz_buzz_gem_core"
701
+ require "fizz_buzz_gem/version"
702
+ require "thor"
703
+
704
+ module FizzBuzzGem
705
+ #= FizzBuzzGem CLI
706
+ class CLI < Thor
707
+ class_option :help, :type => :boolean, :aliases => '-h', :desc => 'help message.'
708
+ class_option :version, :type => :boolean, :desc => 'version'
709
+
710
+ desc "execute", "execute fizz buzz"
711
+ def execute
712
+ puts FizzBuzzGem::Core.new.execute
713
+ end
714
+
715
+ desc "init", "generate Fizzbuzzgemfile"
716
+ def init
717
+ FizzBuzzGem::Core.new.init
718
+ end
719
+
720
+ desc "version", "version"
721
+ def version
722
+ p FizzBuzzGem::VERSION
723
+ end
724
+ end
725
+ end
726
+
727
+ FizzBuzzGem::CLI.start(ARGV)
728
+ ~~~
729
+
730
+ ### Steps: Edit README.md manually
731
+ ~~~ruby
732
+ # FizzBuzzGem
733
+
734
+ FizzBuzzApplication summary.
735
+
736
+ ## Installation
737
+
738
+ Add this line to your application's Gemfile:
739
+
740
+ gem 'fizz_buzz_gem'
741
+
742
+ And then execute:
743
+
744
+ $ bundle
745
+
746
+ Or install it yourself as:
747
+
748
+ $ gem install fizz_buzz_gem
749
+
750
+ ## Usage
751
+
752
+ usage...
753
+
754
+ ## Contributing
755
+
756
+ 1. Fork it
757
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
758
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
759
+ 4. Push to the branch (`git push origin my-new-feature`)
760
+ 5. Create new Pull Request
761
+ ~~~
762
+
763
+ ### Steps: git add, commit
764
+ ~~~bash
765
+ $ git add -A
766
+ $ git add -u
767
+ $ git commit -m "first commit"
768
+ ~~~
769
+
770
+ ### Steps: rake install
771
+ ~~~bash
772
+ $ rake install
773
+ fizz_buzz_gem 0.0.1 built to pkg/fizz_buzz_gem-0.0.1.gem.
774
+ fizz_buzz_gem (0.0.1) installed.
775
+ ~~~
776
+
777
+ ### Steps: test use fizzbuzzgem
778
+ show help
779
+ ~~~bash
780
+ $ fizzbuzzgem
781
+ Commands:
782
+ fizzbuzzgem execute # TODO: write your desc
783
+ fizzbuzzgem help [COMMAND] # Describe available commands or one specific c...
784
+ fizzbuzzgem init # generate Fizzbuzzgemfile
785
+ fizzbuzzgem version # version
786
+
787
+ Options:
788
+ -h, [--help] # help message.
789
+ [--version] # version
790
+ ~~~
791
+
792
+ fizzbuzzgem init
793
+ ~~~bash
794
+ $ fizzbuzzgem init
795
+ $ ls
796
+ Fizzbuzzgemfile*
797
+ $ cat Fizzbuzzgemfile
798
+ # encoding: utf-8
799
+
800
+ # is_upper_case
801
+ # is_upper_case is required
802
+ # is_upper_case allow only String
803
+ # is_upper_case's default value => "false"
804
+ is_upper_case "false"
805
+
806
+ # range
807
+ # range allow only Array
808
+ # range's default value => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
809
+ range [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
810
+ ~~~
811
+
812
+ edit Fizzbuzzgemfile manually
813
+ ~~~ruby
814
+ # encoding: utf-8
815
+ is_upper_case "true"
816
+ range (1..16).to_a
817
+ ~~~
818
+
819
+ execute 'fizzbuzzgem execute'
820
+ ~~~bash
821
+ $ fizzbuzzgem execute
822
+ 1 2 FIZZ 4 BUZZ FIZZ 7 8 FIZZ BUZZ 11 FIZZ 13 14 FIZZBUZZ 16
823
+ ~~~
824
+
825
+ re-edit Fizzbuzzgemfile manually
826
+ ~~~ruby
827
+ # encoding: utf-8
828
+ is_upper_case "false"
829
+ ~~~
830
+
831
+ execute 'fizzbuzzgem execute'
832
+ ~~~bash
833
+ $ fizzbuzzgem e
834
+ 1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizzbuzz
835
+ ~~~
836
+
837
+ ### Steps: if test using is ok, release gem to RubyGems
838
+ ~~~csh
839
+ $ rake release
840
+ ~~~
841
+
842
+ ## Notes
843
+ * this gem uses 'bundle gem' command to create gem template. (bundler gem).
844
+ * this gem uses 'rspec --init' command to create RSpec template (rspec gem).
845
+ * this gem uses 'piccolo' command to create RSpec spec template (rspec_piccolo gem).
846
+
847
+ ## History
848
+ * version 0.0.1 : first release.
849
+
850
+ ## Contributing
851
+
852
+ 1. Fork it
853
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
854
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
855
+ 4. Push to the branch (`git push origin my-new-feature`)
856
+ 5. Create new Pull Request