dslable 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a0c7ba7fc41b585202d5b6c75a082bdd06ae1b6
4
+ data.tar.gz: 67427b83c8772985aa9b302b8eb2a3e1f7162cbf
5
+ SHA512:
6
+ metadata.gz: f836ca027786ba19943002237a901bdb3973591f8d0898ef62356193be24f5374063e5fda23dd60ce1cda78132f4b83e755ba96941ec6ea1475a1f3f36386947
7
+ data.tar.gz: 99cae0facc8350bc52d5bc422304b779b28304ce63f08cddaef3ef8a9189ae336fcd9198437fe4017eac845b95fdba30039e62f177b5e8787806073959a1783a
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Dslable
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/dslable.svg)](http://badge.fury.io/rb/dslable)
4
+
3
5
  Dslable is generator for simple spec gem.
4
6
 
5
7
  ## Summary
@@ -216,10 +218,11 @@ fizz_buzz_gem_core.rb
216
218
  require 'fizz_buzz_gem_dsl'
217
219
 
218
220
  module FizzBuzzGem
219
- # FizzBuzzGem Core
221
+ # FizzBuzzGem Core
220
222
  class Core
221
- FIZZ_BUZZ_GEM_FILE = "Fizzbuzzgemfile"
222
- FIZZ_BUZZ_GEM_TEMPLATE =<<-EOS
223
+ # rubocop:disable LineLength
224
+ FIZZ_BUZZ_GEM_FILE = 'Fizzbuzzgemfile'
225
+ FIZZ_BUZZ_GEM_TEMPLATE = <<-EOS
223
226
  # encoding: utf-8
224
227
 
225
228
  # is_upper_case
@@ -234,13 +237,16 @@ is_upper_case "false"
234
237
  range [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
235
238
 
236
239
  EOS
240
+ # rubocop:enable LineLength
237
241
 
238
- #== generate Fizzbuzzgemfile to current directory.
242
+ # generate Fizzbuzzgemfile to current directory.
239
243
  def init
240
- File.open(FIZZ_BUZZ_GEM_FILE, "w") {|f|f.puts FIZZ_BUZZ_GEM_TEMPLATE}
244
+ File.open(FIZZ_BUZZ_GEM_FILE, 'w') do |f|
245
+ f.puts FIZZ_BUZZ_GEM_TEMPLATE
246
+ end
241
247
  end
242
248
 
243
- #== TODO: write your gem's specific contents
249
+ # TODO: write your gem's specific contents
244
250
  def execute
245
251
  src = read_dsl
246
252
  dsl = FizzBuzzGem::Dsl.new
@@ -251,8 +257,9 @@ range [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
251
257
  end
252
258
 
253
259
  private
260
+
254
261
  def read_dsl
255
- File.open(FIZZ_BUZZ_GEM_FILE) {|f|f.read}
262
+ File.open(FIZZ_BUZZ_GEM_FILE) { |f|f.read }
256
263
  end
257
264
  end
258
265
  end
@@ -265,18 +272,21 @@ fizz_buzz_gem_dsl.rb
265
272
  require 'fizz_buzz_gem_dsl_model'
266
273
 
267
274
  module FizzBuzzGem
275
+ # Dsl
268
276
  class Dsl
269
277
  attr_accessor :fizz_buzz_gem
270
278
 
279
+ # String Define
271
280
  [:is_upper_case].each do |f|
272
281
  define_method f do |value|
273
- eval "@fizz_buzz_gem.#{f.to_s} = '#{value}'", binding
282
+ @fizz_buzz_gem.send("#{f}=", value)
274
283
  end
275
284
  end
276
285
 
286
+ # Array/Hash/Boolean Define
277
287
  [:range].each do |f|
278
288
  define_method f do |value|
279
- eval "@fizz_buzz_gem.#{f.to_s} = #{value}", binding
289
+ @fizz_buzz_gem.send("#{f}=", value)
280
290
  end
281
291
  end
282
292
 
@@ -295,19 +305,22 @@ fizz_buzz_gem_dsl_model.rb
295
305
  # encoding: utf-8
296
306
  require 'active_model'
297
307
 
308
+ # rubocop:disable LineLength
298
309
  module FizzBuzzGem
310
+ # DslModel
299
311
  class DslModel
300
312
  include ActiveModel::Model
301
313
 
302
314
  # is_upper_case
303
315
  attr_accessor :is_upper_case
304
- validates :is_upper_case, :presence => true
316
+ validates :is_upper_case, presence: true
305
317
 
306
318
  # range
307
319
  attr_accessor :range
308
320
 
309
321
  end
310
322
  end
323
+ # rubocop:enable LineLength
311
324
  ~~~
312
325
 
313
326
  bin source Template
@@ -322,8 +335,8 @@ require "thor"
322
335
  module FizzBuzzGem
323
336
  #= FizzBuzzGem CLI
324
337
  class CLI < Thor
325
- class_option :help, :type => :boolean, :aliases => '-h', :desc => 'help message.'
326
- class_option :version, :type => :boolean, :desc => 'version'
338
+ class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
339
+ class_option :version, type: :boolean, desc: 'version'
327
340
 
328
341
  desc "execute", "TODO: write your desc"
329
342
  def execute
@@ -720,8 +733,8 @@ require "thor"
720
733
  module FizzBuzzGem
721
734
  #= FizzBuzzGem CLI
722
735
  class CLI < Thor
723
- class_option :help, :type => :boolean, :aliases => '-h', :desc => 'help message.'
724
- class_option :version, :type => :boolean, :desc => 'version'
736
+ class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
737
+ class_option :version, type: :boolean, desc: 'version'
725
738
 
726
739
  desc "execute", "execute fizz buzz"
727
740
  def execute
@@ -987,6 +1000,8 @@ All Tasks Finish!!
987
1000
  * this gem uses 'tudu' command to create Workflow (tudu gem).
988
1001
 
989
1002
  ## History
1003
+ * version 0.0.6 : fix generation code.remove rubocop warnings
1004
+ * version 0.0.5 : update runtime_dependency(version up rspec_piccolo ver0.0.6 to ver0.0.8)
990
1005
  * version 0.0.4 : delete Core#init spec generation
991
1006
  * version 0.0.4 : delete Hash default brace.
992
1007
  * version 0.0.3 : add using class Boolean(true or class).
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
@@ -1,29 +1,29 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'dslable/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "dslable"
8
- spec.version = Dslable::VERSION
9
- spec.authors = ["tbpgr@tbpgr.jp"]
10
- spec.email = ["tbpgr@tbpgr.jp"]
11
- spec.description = %q{Dslable is generator for simple gem-code template.}
12
- spec.summary = %q{Dslable is generator for simple gem-code template.}
13
- spec.homepage = "https://github.com/tbpgr/dslable"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_runtime_dependency "thor", "~> 0.18.1"
22
- spec.add_runtime_dependency "activesupport", "~> 4.0.1"
23
- spec.add_runtime_dependency "rspec_piccolo", "~> 0.0.8"
24
- spec.add_runtime_dependency "bundler", "~> 1.3"
25
- spec.add_runtime_dependency "rspec", "~> 2.14.1"
26
-
27
- spec.add_development_dependency "rake"
28
- spec.add_development_dependency "simplecov", "~> 0.8.2"
29
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dslable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'dslable'
8
+ spec.version = Dslable::VERSION
9
+ spec.authors = ['tbpgr@tbpgr.jp']
10
+ spec.email = ['tbpgr@tbpgr.jp']
11
+ spec.description = %q(Dslable is generator for simple gem-code template.)
12
+ spec.summary = %q(Dslable is generator for simple gem-code template.)
13
+ spec.homepage = 'https://github.com/tbpgr/dslable'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'thor', '~> 0.18.1'
22
+ spec.add_runtime_dependency 'activesupport', '~> 4.0.1'
23
+ spec.add_runtime_dependency 'rspec_piccolo', '~> 0.0.8'
24
+ spec.add_runtime_dependency 'bundler', '~> 1.3'
25
+ spec.add_runtime_dependency 'rspec', '~> 2.14.1'
26
+
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'simplecov', '~> 0.8.2'
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Dslable
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -65,7 +65,7 @@ end
65
65
  end
66
66
 
67
67
  def generate_cli_src(cli_src)
68
- FileUtils.mkdir_p('./bin') unless File.exists?('./bin')
68
+ FileUtils.mkdir_p('./bin') unless File.exist?('./bin')
69
69
  File.open("./bin/#{@dsl._bin_name}", 'w') { |f|f.puts cli_src }
70
70
  end
71
71
  end
@@ -12,21 +12,25 @@ module Dslable::Generators::ProductCodes
12
12
  require '<%=gem_name%>_dsl'
13
13
 
14
14
  module <%=gem_name_camel%>
15
- # <%=gem_name_camel%> Core
15
+ # <%=gem_name_camel%> Core
16
16
  class Core
17
- <%=gem_name_upper%>_FILE = "<%=dsl_file_name%>"
18
- <%=gem_name_upper%>_TEMPLATE =<<-EOS
17
+ # rubocop:disable LineLength
18
+ <%=gem_name_upper%>_FILE = '<%=dsl_file_name%>'
19
+ <%=gem_name_upper%>_TEMPLATE = <<-EOS
19
20
  # encoding: utf-8
20
21
 
21
22
  <%=fields%>
22
23
  EOS
24
+ # rubocop:enable LineLength
23
25
 
24
- #== generate <%=dsl_file_name%> to current directory.
26
+ # generate <%=dsl_file_name%> to current directory.
25
27
  def init
26
- File.open(<%=gem_name_upper%>_FILE, "w") {|f|f.puts <%=gem_name_upper%>_TEMPLATE}
28
+ File.open(<%=gem_name_upper%>_FILE, 'w') do |f|
29
+ f.puts <%=gem_name_upper%>_TEMPLATE
30
+ end
27
31
  end
28
32
 
29
- #== TODO: write your gem's specific contents
33
+ # TODO: write your gem's specific contents
30
34
  def execute
31
35
  src = read_dsl
32
36
  dsl = <%=gem_name_camel%>::Dsl.new
@@ -37,8 +41,9 @@ module <%=gem_name_camel%>
37
41
  end
38
42
 
39
43
  private
44
+
40
45
  def read_dsl
41
- File.open(<%=gem_name_upper%>_FILE) {|f|f.read}
46
+ File.open(<%=gem_name_upper%>_FILE) { |f|f.read }
42
47
  end
43
48
  end
44
49
  end
@@ -11,20 +11,21 @@ module Dslable::Generators::ProductCodes
11
11
  require '<%=gem_name%>_dsl_model'
12
12
 
13
13
  module <%=gem_name_camel%>
14
+ # Dsl
14
15
  class Dsl
15
16
  attr_accessor :<%=gem_name%>
16
17
 
17
18
  # String Define
18
19
  [<%=string_fields%>].each do |f|
19
20
  define_method f do |value|
20
- eval "@<%=gem_name%>.#\{f.to_s} = '#\{value}'", binding
21
+ @<%=gem_name%>.send("\#{f}=", value)
21
22
  end
22
23
  end
23
24
 
24
25
  # Array/Hash/Boolean Define
25
26
  [<%=array_hash_fields%>].each do |f|
26
27
  define_method f do |value|
27
- eval "@<%=gem_name%>.#\{f.to_s} = #\{value}", binding
28
+ @<%=gem_name%>.send("\#{f}=", value)
28
29
  end
29
30
  end
30
31
 
@@ -10,13 +10,16 @@ module Dslable::Generators::ProductCodes
10
10
  # encoding: utf-8
11
11
  require 'active_model'
12
12
 
13
+ # rubocop:disable LineLength
13
14
  module <%=gem_name_camel%>
15
+ # DslModel
14
16
  class DslModel
15
17
  include ActiveModel::Model
16
18
 
17
19
  <%=fields%>
18
20
  end
19
21
  end
22
+ # rubocop:enable LineLength
20
23
  EOF
21
24
 
22
25
  attr_accessor :dsl
@@ -41,7 +44,7 @@ end
41
44
  field_codes = []
42
45
  field_codes << " # #{field._desc}"
43
46
  field_codes << " attr_accessor :#{field._field_name}"
44
- field_codes << " validates :#{field._field_name}, :presence => true" if field._args._required
47
+ field_codes << " validates :#{field._field_name}, presence: true" if field._args._required
45
48
  field_codes << ''
46
49
  fields << field_codes.join("\n")
47
50
  end
@@ -37,7 +37,7 @@ describe Dslable::Core do
37
37
  end
38
38
 
39
39
  def case_after(c)
40
- return unless File.exists? Dslable::Core::DSLDEFINE_FILE
40
+ return unless File.exist? Dslable::Core::DSLDEFINE_FILE
41
41
  File.delete(Dslable::Core::DSLDEFINE_FILE)
42
42
  end
43
43
  end
@@ -149,7 +149,7 @@ end
149
149
  # -- then --
150
150
  Dir.chdir('../')
151
151
  c[:expected_files].each do |expected_file|
152
- actual = File.exists? expected_file
152
+ actual = File.exist? expected_file
153
153
  expect(actual).to be_true
154
154
  end
155
155
  ensure
@@ -159,7 +159,7 @@ end
159
159
 
160
160
  def case_before(c)
161
161
  # implement each case before
162
- Dir.mkdir(OUTPUT_CORE_TMP_DIR) unless Dir.exists? OUTPUT_CORE_TMP_DIR
162
+ Dir.mkdir(OUTPUT_CORE_TMP_DIR) unless Dir.exist? OUTPUT_CORE_TMP_DIR
163
163
  Dir.chdir(OUTPUT_CORE_TMP_DIR)
164
164
  File.open(Dslable::Core::DSLDEFINE_FILE, 'w') { |f|f.puts c[:define_src] }
165
165
  end
@@ -167,7 +167,7 @@ end
167
167
  def case_after(c)
168
168
  # implement each case after
169
169
  Dir.chdir('../')
170
- FileUtils.rm_rf(OUTPUT_CORE_TMP_DIR) if Dir.exists? OUTPUT_CORE_TMP_DIR
170
+ FileUtils.rm_rf(OUTPUT_CORE_TMP_DIR) if Dir.exist? OUTPUT_CORE_TMP_DIR
171
171
  end
172
172
  end
173
173
  end
@@ -29,7 +29,7 @@ describe Dslable::Generators::GemTemplate do
29
29
  gem_template.generate
30
30
 
31
31
  # -- then --
32
- actual = Dir.exists?("../#{c[:gem_name]}")
32
+ actual = Dir.exist?("../#{c[:gem_name]}")
33
33
  expect(actual).to be_true
34
34
  ensure
35
35
 
@@ -38,13 +38,13 @@ describe Dslable::Generators::GemTemplate do
38
38
  end
39
39
 
40
40
  def case_before(c)
41
- Dir.mkdir(OUTPUT_TMP_DIR) unless Dir.exists? OUTPUT_TMP_DIR
41
+ Dir.mkdir(OUTPUT_TMP_DIR) unless Dir.exist? OUTPUT_TMP_DIR
42
42
  Dir.chdir(OUTPUT_TMP_DIR)
43
43
  end
44
44
 
45
45
  def case_after(c)
46
46
  Dir.chdir('../../')
47
- FileUtils.rm_rf(OUTPUT_TMP_DIR) if Dir.exists? OUTPUT_TMP_DIR
47
+ FileUtils.rm_rf(OUTPUT_TMP_DIR) if Dir.exist? OUTPUT_TMP_DIR
48
48
  end
49
49
  end
50
50
  end
@@ -46,11 +46,11 @@ SampleGem::CLI.start(ARGV)
46
46
  gem_name: 'sample_gem',
47
47
  bin_name: 'samplegem',
48
48
  fields: [:field1, :field2, :field3, :field4, :field5, :field6],
49
- fields_descs: ['field_desc1', 'field_desc2', 'field_desc3', 'field_desc4', 'field_desc5', 'field_desc6'],
49
+ fields_descs: %w(field_desc1 field_desc2 field_desc3 field_desc4 field_desc5 field_desc6),
50
50
  args: [:args1, :args2, :args3, :args4, :args5, :args6],
51
51
  args_klass: [String, Array, Hash, String, Array, Hash],
52
52
  args_required: [true, true, true, false, false, false],
53
- args_default: ['default1', ['default1', 'default2'], { default_key: 'default_value' }, nil, nil, nil],
53
+ args_default: ['default1', %w(default1 default2), { default_key: 'default_value' }, nil, nil, nil],
54
54
  expected_file: './bin/samplegem',
55
55
  expected_contents: OUTPUT_CLI_CASE1
56
56
  },
@@ -79,7 +79,7 @@ SampleGem::CLI.start(ARGV)
79
79
 
80
80
  def case_before(c)
81
81
  # implement each case before
82
- Dir.mkdir(OUTPUT_CLI_TMP_DIR) unless Dir.exists? OUTPUT_CLI_TMP_DIR
82
+ Dir.mkdir(OUTPUT_CLI_TMP_DIR) unless Dir.exist? OUTPUT_CLI_TMP_DIR
83
83
  Dir.chdir(OUTPUT_CLI_TMP_DIR)
84
84
  Dir.mkdir 'bin'
85
85
  end
@@ -103,7 +103,7 @@ SampleGem::CLI.start(ARGV)
103
103
  def case_after(c)
104
104
  # implement each case after
105
105
  Dir.chdir('../')
106
- FileUtils.rm_rf(OUTPUT_CLI_TMP_DIR) if Dir.exists? OUTPUT_CLI_TMP_DIR
106
+ FileUtils.rm_rf(OUTPUT_CLI_TMP_DIR) if Dir.exist? OUTPUT_CLI_TMP_DIR
107
107
  end
108
108
  end
109
109
  end
@@ -12,10 +12,11 @@ describe Dslable::Generators::ProductCodes::Core do
12
12
  require 'sample_gem_dsl'
13
13
 
14
14
  module SampleGem
15
- # SampleGem Core
15
+ # SampleGem Core
16
16
  class Core
17
- SAMPLE_GEM_FILE = "Samplegemfile"
18
- SAMPLE_GEM_TEMPLATE =<<-EOS
17
+ # rubocop:disable LineLength
18
+ SAMPLE_GEM_FILE = 'Samplegemfile'
19
+ SAMPLE_GEM_TEMPLATE = <<-EOS
19
20
  # encoding: utf-8
20
21
 
21
22
  # field_desc1
@@ -55,13 +56,16 @@ field6 "your key"=>"your value"
55
56
  field7 false
56
57
 
57
58
  EOS
59
+ # rubocop:enable LineLength
58
60
 
59
- #== generate Samplegemfile to current directory.
61
+ # generate Samplegemfile to current directory.
60
62
  def init
61
- File.open(SAMPLE_GEM_FILE, "w") {|f|f.puts SAMPLE_GEM_TEMPLATE}
63
+ File.open(SAMPLE_GEM_FILE, 'w') do |f|
64
+ f.puts SAMPLE_GEM_TEMPLATE
65
+ end
62
66
  end
63
67
 
64
- #== TODO: write your gem's specific contents
68
+ # TODO: write your gem's specific contents
65
69
  def execute
66
70
  src = read_dsl
67
71
  dsl = SampleGem::Dsl.new
@@ -72,8 +76,9 @@ field7 false
72
76
  end
73
77
 
74
78
  private
79
+
75
80
  def read_dsl
76
- File.open(SAMPLE_GEM_FILE) {|f|f.read}
81
+ File.open(SAMPLE_GEM_FILE) { |f|f.read }
77
82
  end
78
83
  end
79
84
  end
@@ -84,11 +89,11 @@ end
84
89
  case_title: 'valid generate core class',
85
90
  gem_name: 'sample_gem',
86
91
  fields: [:field1, :field2, :field3, :field4, :field5, :field6, :field7],
87
- fields_descs: ['field_desc1', 'field_desc2', 'field_desc3', 'field_desc4', 'field_desc5', 'field_desc6', 'field_desc7'],
92
+ fields_descs: %w(field_desc1 field_desc2 field_desc3 field_desc4 field_desc5 field_desc6 field_desc7),
88
93
  args: [:args1, :args2, :args3, :args4, :args5, :args6, :args7],
89
94
  args_klass: [String, Array, Hash, String, Array, Hash, :Boolean],
90
95
  args_required: [true, true, true, false, false, false, true],
91
- args_default: ['default1', ['default1', 'default2'], { default_key: 'default_value' }, nil, nil, nil, false],
96
+ args_default: ['default1', %w(default1 default2), { default_key: 'default_value' }, nil, nil, nil, false],
92
97
  expected_file: './lib/sample_gem_core.rb',
93
98
  expected_contents: OUTPUT_CORE_CASE1
94
99
  },
@@ -116,7 +121,7 @@ end
116
121
  end
117
122
 
118
123
  def case_before(c)
119
- Dir.mkdir(OUTPUT_CORE_TMP_DIR) unless Dir.exists? OUTPUT_CORE_TMP_DIR
124
+ Dir.mkdir(OUTPUT_CORE_TMP_DIR) unless Dir.exist? OUTPUT_CORE_TMP_DIR
120
125
  Dir.chdir(OUTPUT_CORE_TMP_DIR)
121
126
  Dir.mkdir 'lib'
122
127
  end
@@ -138,7 +143,7 @@ end
138
143
 
139
144
  def case_after(c)
140
145
  Dir.chdir('../')
141
- FileUtils.rm_rf(OUTPUT_CORE_TMP_DIR) if Dir.exists? OUTPUT_CORE_TMP_DIR
146
+ FileUtils.rm_rf(OUTPUT_CORE_TMP_DIR) if Dir.exist? OUTPUT_CORE_TMP_DIR
142
147
  end
143
148
  end
144
149
  end
@@ -10,21 +10,23 @@ describe Dslable::Generators::ProductCodes::DslModel do
10
10
  # encoding: utf-8
11
11
  require 'active_model'
12
12
 
13
+ # rubocop:disable LineLength
13
14
  module SampleGem
15
+ # DslModel
14
16
  class DslModel
15
17
  include ActiveModel::Model
16
18
 
17
19
  # field_desc1
18
20
  attr_accessor :field1
19
- validates :field1, :presence => true
21
+ validates :field1, presence: true
20
22
 
21
23
  # field_desc2
22
24
  attr_accessor :field2
23
- validates :field2, :presence => true
25
+ validates :field2, presence: true
24
26
 
25
27
  # field_desc3
26
28
  attr_accessor :field3
27
- validates :field3, :presence => true
29
+ validates :field3, presence: true
28
30
 
29
31
  # field_desc4
30
32
  attr_accessor :field4
@@ -37,6 +39,7 @@ module SampleGem
37
39
 
38
40
  end
39
41
  end
42
+ # rubocop:enable LineLength
40
43
  EOF
41
44
 
42
45
  cases = [
@@ -45,11 +48,11 @@ end
45
48
  case_title: 'generate',
46
49
  gem_name: 'sample_gem',
47
50
  fields: [:field1, :field2, :field3, :field4, :field5, :field6],
48
- fields_descs: ['field_desc1', 'field_desc2', 'field_desc3', 'field_desc4', 'field_desc5', 'field_desc6'],
51
+ fields_descs: %w(field_desc1 field_desc2 field_desc3 field_desc4 field_desc5 field_desc6),
49
52
  args: [:args1, :args2, :args3, :args4, :args5, :args6],
50
53
  args_klass: [String, Array, Hash, String, Array, Hash],
51
54
  args_required: [true, true, true, false, false, false],
52
- args_default: ['default1', ['default1', 'default2'], { default_key: 'default_value' }, nil, nil, nil],
55
+ args_default: ['default1', %w(default1 default2), { default_key: 'default_value' }, nil, nil, nil],
53
56
  expected_file: './lib/sample_gem_dsl_model.rb',
54
57
  expected_contents: OUTPUT_DSL_MODEL_CASE1
55
58
  },
@@ -78,7 +81,7 @@ end
78
81
 
79
82
  def case_before(c)
80
83
  # implement each case before
81
- Dir.mkdir(OUTPUT_DSL_MODEL_TMP_DIR) unless Dir.exists? OUTPUT_DSL_MODEL_TMP_DIR
84
+ Dir.mkdir(OUTPUT_DSL_MODEL_TMP_DIR) unless Dir.exist? OUTPUT_DSL_MODEL_TMP_DIR
82
85
  Dir.chdir(OUTPUT_DSL_MODEL_TMP_DIR)
83
86
  Dir.mkdir 'lib'
84
87
  end
@@ -101,7 +104,7 @@ end
101
104
  def case_after(c)
102
105
  # implement each case after
103
106
  Dir.chdir('../')
104
- FileUtils.rm_rf(OUTPUT_DSL_MODEL_TMP_DIR) if Dir.exists? OUTPUT_DSL_MODEL_TMP_DIR
107
+ FileUtils.rm_rf(OUTPUT_DSL_MODEL_TMP_DIR) if Dir.exist? OUTPUT_DSL_MODEL_TMP_DIR
105
108
  end
106
109
  end
107
110
  end
@@ -13,20 +13,21 @@ describe Dslable::Generators::ProductCodes::Dsl do
13
13
  require 'sample_gem_dsl_model'
14
14
 
15
15
  module SampleGem
16
+ # Dsl
16
17
  class Dsl
17
18
  attr_accessor :sample_gem
18
19
 
19
20
  # String Define
20
21
  [:field1, :field4].each do |f|
21
22
  define_method f do |value|
22
- eval "@sample_gem.#\{f.to_s} = '#\{value}'", binding
23
+ @sample_gem.send("#\{f}=", value)
23
24
  end
24
25
  end
25
26
 
26
27
  # Array/Hash/Boolean Define
27
28
  [:field2, :field3, :field5, :field6].each do |f|
28
29
  define_method f do |value|
29
- eval "@sample_gem.#\{f.to_s} = #\{value}", binding
30
+ @sample_gem.send("#\{f}=", value)
30
31
  end
31
32
  end
32
33
 
@@ -46,11 +47,11 @@ end
46
47
  case_title: 'generate',
47
48
  gem_name: 'sample_gem',
48
49
  fields: [:field1, :field2, :field3, :field4, :field5, :field6],
49
- fields_descs: ['field_desc1', 'field_desc2', 'field_desc3', 'field_desc4', 'field_desc5', 'field_desc6'],
50
+ fields_descs: %w(field_desc1 field_desc2 field_desc3 field_desc4 field_desc5 field_desc6),
50
51
  args: [:args1, :args2, :args3, :args4, :args5, :args6],
51
52
  args_klass: [String, Array, Hash, String, Array, Hash],
52
53
  args_required: [true, true, true, false, false, false],
53
- args_default: ['default1', ['default1', 'default2'], { default_key: 'default_value' }, nil, nil, nil],
54
+ args_default: ['default1', %w(default1 default2), { default_key: 'default_value' }, nil, nil, nil],
54
55
  expected_file: './lib/sample_gem_dsl.rb',
55
56
  expected_contents: OUTPUT_DSL_CASE1
56
57
 
@@ -80,7 +81,7 @@ end
80
81
 
81
82
  def case_before(c)
82
83
  # implement each case before
83
- Dir.mkdir(OUTPUT_DSL_TMP_DIR) unless Dir.exists? OUTPUT_DSL_TMP_DIR
84
+ Dir.mkdir(OUTPUT_DSL_TMP_DIR) unless Dir.exist? OUTPUT_DSL_TMP_DIR
84
85
  Dir.chdir(OUTPUT_DSL_TMP_DIR)
85
86
  Dir.mkdir 'lib'
86
87
  end
@@ -103,7 +104,7 @@ end
103
104
  def case_after(c)
104
105
  # implement each case after
105
106
  Dir.chdir('../')
106
- FileUtils.rm_rf(OUTPUT_DSL_TMP_DIR) if Dir.exists? OUTPUT_DSL_TMP_DIR
107
+ FileUtils.rm_rf(OUTPUT_DSL_TMP_DIR) if Dir.exist? OUTPUT_DSL_TMP_DIR
107
108
  end
108
109
  end
109
110
  end
@@ -31,7 +31,7 @@ describe Dslable::Generators::RSpec::SpecTemplate do
31
31
  spec_template.generate
32
32
 
33
33
  # -- then --
34
- actual = Dir.exists?("./#{c[:spec_dir_name]}")
34
+ actual = Dir.exist?("./#{c[:spec_dir_name]}")
35
35
  expect(actual).to be_true
36
36
  ensure
37
37
  case_after c
@@ -40,14 +40,14 @@ describe Dslable::Generators::RSpec::SpecTemplate do
40
40
  end
41
41
 
42
42
  def case_before(c)
43
- Dir.mkdir(OUTPUT_SPEC_TMP_DIR) unless Dir.exists? OUTPUT_SPEC_TMP_DIR
44
- Dir.chdir(OUTPUT_SPEC_TMP_DIR)
43
+ Dir.mkdir(OUTPUT_SPEC_TMP_DIR) unless Dir.exist? OUTPUT_SPEC_TMP_DIR
44
+ Dir.chdir(OUTPUT_SPEC_TMP_DIR)
45
45
  end
46
46
 
47
- def case_after(c)
48
- Dir.chdir('../')
49
- FileUtils.rm_rf(OUTPUT_SPEC_TMP_DIR) if Dir.exists? OUTPUT_SPEC_TMP_DIR
50
- end
47
+ def case_after(c)
48
+ Dir.chdir('../')
49
+ FileUtils.rm_rf(OUTPUT_SPEC_TMP_DIR) if Dir.exist? OUTPUT_SPEC_TMP_DIR
50
+ end
51
51
  end
52
52
  end
53
53
 
@@ -32,7 +32,7 @@ describe Dslable::Generators::RSpec::Specs do
32
32
 
33
33
  # -- then --
34
34
  c[:specs].each do |spec|
35
- actual = File.exists?("./#{spec}")
35
+ actual = File.exist?("./#{spec}")
36
36
  expect(actual).to be_true
37
37
  end
38
38
  ensure
@@ -42,14 +42,14 @@ describe Dslable::Generators::RSpec::Specs do
42
42
  end
43
43
 
44
44
  def case_before(c)
45
- Dir.mkdir(OUTPUT_SPECS_TMP_DIR) unless Dir.exists? OUTPUT_SPECS_TMP_DIR
46
- Dir.chdir(OUTPUT_SPECS_TMP_DIR)
45
+ Dir.mkdir(OUTPUT_SPECS_TMP_DIR) unless Dir.exist? OUTPUT_SPECS_TMP_DIR
46
+ Dir.chdir(OUTPUT_SPECS_TMP_DIR)
47
47
  end
48
48
 
49
- def case_after(c)
50
- Dir.chdir('../')
51
- FileUtils.rm_rf(OUTPUT_SPECS_TMP_DIR) if Dir.exists? OUTPUT_SPECS_TMP_DIR
52
- end
49
+ def case_after(c)
50
+ Dir.chdir('../')
51
+ FileUtils.rm_rf(OUTPUT_SPECS_TMP_DIR) if Dir.exist? OUTPUT_SPECS_TMP_DIR
52
+ end
53
53
  end
54
54
  end
55
55
 
@@ -47,7 +47,7 @@ describe Dslable::Generators::Settings::Gemfile do
47
47
 
48
48
  def case_before(c)
49
49
  # implement each case before
50
- Dir.mkdir(OUTPUT_GEMFILE_TMP_DIR) unless Dir.exists? OUTPUT_GEMFILE_TMP_DIR
50
+ Dir.mkdir(OUTPUT_GEMFILE_TMP_DIR) unless Dir.exist? OUTPUT_GEMFILE_TMP_DIR
51
51
  Dir.chdir(OUTPUT_GEMFILE_TMP_DIR)
52
52
  end
53
53
 
@@ -70,7 +70,7 @@ describe Dslable::Generators::Settings::Gemfile do
70
70
  def case_after(c)
71
71
  # implement each case after
72
72
  Dir.chdir('../')
73
- FileUtils.rm_rf(OUTPUT_GEMFILE_TMP_DIR) if Dir.exists? OUTPUT_GEMFILE_TMP_DIR
73
+ FileUtils.rm_rf(OUTPUT_GEMFILE_TMP_DIR) if Dir.exist? OUTPUT_GEMFILE_TMP_DIR
74
74
  end
75
75
  end
76
76
  end
@@ -66,14 +66,14 @@ implement 'sample_gem_core_spec.rb'.
66
66
 
67
67
  def case_before(c)
68
68
  # implement each case before
69
- Dir.mkdir(OUTPUT_WORKFLOW_TMP_DIR) unless Dir.exists? OUTPUT_WORKFLOW_TMP_DIR
69
+ Dir.mkdir(OUTPUT_WORKFLOW_TMP_DIR) unless Dir.exist? OUTPUT_WORKFLOW_TMP_DIR
70
70
  Dir.chdir(OUTPUT_WORKFLOW_TMP_DIR)
71
71
  end
72
72
 
73
73
  def case_after(c)
74
74
  # implement each case after
75
75
  Dir.chdir('../')
76
- FileUtils.rm_rf(OUTPUT_WORKFLOW_TMP_DIR) if Dir.exists? OUTPUT_WORKFLOW_TMP_DIR
76
+ FileUtils.rm_rf(OUTPUT_WORKFLOW_TMP_DIR) if Dir.exist? OUTPUT_WORKFLOW_TMP_DIR
77
77
  end
78
78
  end
79
79
  end
metadata CHANGED
@@ -1,93 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dslable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - tbpgr@tbpgr.jp
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
- requirement: &22432068 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.18.1
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *22432068
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.18.1
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: activesupport
27
- requirement: &22430148 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ~>
31
32
  - !ruby/object:Gem::Version
32
33
  version: 4.0.1
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *22430148
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.1
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rspec_piccolo
38
- requirement: &22429272 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ~>
42
46
  - !ruby/object:Gem::Version
43
47
  version: 0.0.8
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *22429272
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.8
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: bundler
49
- requirement: &22428708 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: '1.3'
55
62
  type: :runtime
56
63
  prerelease: false
57
- version_requirements: *22428708
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rspec
60
- requirement: &22428336 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
73
  - - ~>
64
74
  - !ruby/object:Gem::Version
65
75
  version: 2.14.1
66
76
  type: :runtime
67
77
  prerelease: false
68
- version_requirements: *22428336
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.1
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
- requirement: &22428084 !ruby/object:Gem::Requirement
72
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
- - - ! '>='
87
+ - - '>='
75
88
  - !ruby/object:Gem::Version
76
89
  version: '0'
77
90
  type: :development
78
91
  prerelease: false
79
- version_requirements: *22428084
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
80
97
  - !ruby/object:Gem::Dependency
81
98
  name: simplecov
82
- requirement: &22427640 !ruby/object:Gem::Requirement
83
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
84
100
  requirements:
85
101
  - - ~>
86
102
  - !ruby/object:Gem::Version
87
103
  version: 0.8.2
88
104
  type: :development
89
105
  prerelease: false
90
- version_requirements: *22427640
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.2
91
111
  description: Dslable is generator for simple gem-code template.
92
112
  email:
93
113
  - tbpgr@tbpgr.jp
@@ -136,27 +156,26 @@ files:
136
156
  homepage: https://github.com/tbpgr/dslable
137
157
  licenses:
138
158
  - MIT
159
+ metadata: {}
139
160
  post_install_message:
140
161
  rdoc_options: []
141
162
  require_paths:
142
163
  - lib
143
164
  required_ruby_version: !ruby/object:Gem::Requirement
144
- none: false
145
165
  requirements:
146
- - - ! '>='
166
+ - - '>='
147
167
  - !ruby/object:Gem::Version
148
168
  version: '0'
149
169
  required_rubygems_version: !ruby/object:Gem::Requirement
150
- none: false
151
170
  requirements:
152
- - - ! '>='
171
+ - - '>='
153
172
  - !ruby/object:Gem::Version
154
173
  version: '0'
155
174
  requirements: []
156
175
  rubyforge_project:
157
- rubygems_version: 1.8.11
176
+ rubygems_version: 2.3.0
158
177
  signing_key:
159
- specification_version: 3
178
+ specification_version: 4
160
179
  summary: Dslable is generator for simple gem-code template.
161
180
  test_files:
162
181
  - spec/dslable_args_spec.rb
@@ -173,4 +192,3 @@ test_files:
173
192
  - spec/generators/settings/gemfile_spec.rb
174
193
  - spec/generators/workflow_spec.rb
175
194
  - spec/spec_helper.rb
176
- has_rdoc: