boiler 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in boiler.gemspec
4
3
  gemspec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Greg Brockman
1
+ Copyright (c) 2013 Stripe
2
2
 
3
3
  MIT License
4
4
 
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
19
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
20
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
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.
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs = ['lib']
6
+ # t.warning = true
7
+ t.verbose = true
8
+ t.test_files = FileList['test/**/*.rb'].reject do |file|
9
+ file.end_with?('_lib.rb') || file.include?('/_lib/')
10
+ end
11
+ end
data/bin/boiler CHANGED
@@ -25,6 +25,15 @@ Escort::App.create do |app|
25
25
  end
26
26
  end
27
27
 
28
+ app.command(:touchup) do |command|
29
+ command.summary "Touchup the autogenerated Rakefile and gemspec"
30
+ command.description "Touchup the autogenerated Rakefile and gemspec"
31
+
32
+ command.action do |options, arguments|
33
+ Boiler::Generator::Touchup.new(options, arguments).execute
34
+ end
35
+ end
36
+
28
37
  app.action do |options, arguments|
29
38
  raise "Must provide an argument. Run -h for options."
30
39
  end
data/boiler.gemspec CHANGED
@@ -4,17 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'boiler/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "boiler"
7
+ gem.name = 'boiler'
8
8
  gem.version = Boiler::VERSION
9
- gem.authors = ["Greg Brockman"]
10
- gem.email = ["gdb@gregbrockman.com"]
11
- gem.description = "A boilerplate generator"
12
- gem.summary = "Generates boilerplate for you"
13
- gem.homepage = ""
9
+ gem.authors = ['Greg Brockman']
10
+ gem.email = ['gdb@gregbrockman.com']
11
+ gem.description = 'A boilerplate generator'
12
+ gem.summary = 'Generates boilerplate for you'
13
+ gem.homepage = ''
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
- gem.require_paths = ["lib"]
18
+ gem.require_paths = ['lib']
19
+ gem.add_development_dependency 'rake'
20
+ gem.add_development_dependency 'minitest'
21
+ gem.add_development_dependency 'mocha'
19
22
  gem.add_dependency 'escort'
23
+ gem.add_dependency 'chalk-log'
20
24
  end
@@ -1,7 +1,10 @@
1
1
  require 'fileutils'
2
+ require 'chalk-log'
2
3
 
3
4
  module Boiler::Generator
4
5
  class Base
6
+ include Chalk::Log
7
+
5
8
  def initialize(options, arguments)
6
9
  @options = options
7
10
  @arguments = arguments
@@ -14,15 +17,24 @@ module Boiler::Generator
14
17
  protected
15
18
 
16
19
  def write_file(file, contents)
20
+ log.ann('writing file', :bytes => contents.bytesize, :file => file)
17
21
  # TODO: disable O_CREAT
18
22
  File.open(file, 'w') {|f| f.print(contents)}
19
23
  end
20
24
 
25
+ def append_to_file(file, contents)
26
+ log.ann('appending to file', :bytes => contents.bytesize, :file => file)
27
+ # TODO: disable O_CREAT
28
+ File.open(file, 'a') {|f| f.print(contents)}
29
+ end
30
+
21
31
  def chmod(perms, file)
22
- FileUtils.chmod(0755, file)
32
+ log.ann('chmod', :perms => perms, :file => file)
33
+ FileUtils.chmod(perms, file)
23
34
  end
24
35
 
25
36
  def mkdir(dir)
37
+ log.ann('mkdir', :dir => dir)
26
38
  FileUtils.mkdir(dir)
27
39
  end
28
40
  end
@@ -1,5 +1,3 @@
1
- require 'fileutils'
2
-
3
1
  module Boiler::Generator
4
2
  class Suite < Base
5
3
  def execute
@@ -13,15 +11,19 @@ module Boiler::Generator
13
11
  private
14
12
 
15
13
  def relative_mkdir(subdir)
16
- path = File.join(@directory, subdir)
14
+ path = path(subdir)
17
15
  mkdir(path)
18
16
  end
19
17
 
20
18
  def relative_write_file(file, contents)
21
- path = File.join(@directory, file)
19
+ path = path(file)
22
20
  write_file(path, contents)
23
21
  end
24
22
 
23
+ def path(file)
24
+ File.join(@directory, file)
25
+ end
26
+
25
27
  def make_subdirectories
26
28
  [
27
29
  'test',
@@ -41,7 +43,7 @@ require 'bundler/setup'
41
43
 
42
44
  require 'minitest/autorun'
43
45
  require 'minitest/spec'
44
- require 'mocha'
46
+ require 'mocha/setup'
45
47
 
46
48
  module Critic
47
49
  class Test < ::MiniTest::Spec
@@ -59,7 +61,7 @@ module Critic::Unit
59
61
  module Stubs
60
62
  end
61
63
 
62
- class Test < ContextCritic::Test
64
+ class Test < Critic::Test
63
65
  include Stubs
64
66
  end
65
67
  end
@@ -105,6 +107,6 @@ module Critic::Meta
105
107
  end
106
108
  end
107
109
  EOF
108
- end
110
+ end
109
111
  end
110
112
  end
@@ -0,0 +1,69 @@
1
+ module Boiler::Generator
2
+ class Touchup < Base
3
+ def execute
4
+ raise "Must provide a base directory" unless directory = @arguments.first
5
+ @directory = directory
6
+
7
+ # Ensure that these files exist
8
+ gemspec = get_gemspec
9
+ rakefile = get_rakefile
10
+
11
+ modify_gemspec(gemspec)
12
+ modify_rakefile(rakefile)
13
+ end
14
+
15
+ private
16
+
17
+ def path(file)
18
+ File.join(@directory, file)
19
+ end
20
+
21
+ def get_gemspec
22
+ glob = path('*.gemspec')
23
+ gemspecs = Dir[glob]
24
+ if gemspecs.length == 0
25
+ raise "No gemspec found matching #{glob}!"
26
+ elsif gemspecs.length > 1
27
+ raise "Found #{gemspecs.length} gemspecs matching #{glob}!"
28
+ end
29
+ gemspecs[0]
30
+ end
31
+
32
+ def get_rakefile
33
+ path = path('Rakefile')
34
+ raise "No Rakefile found at #{path}" unless File.exists?(path)
35
+ path
36
+ end
37
+
38
+ def modify_gemspec(gemspec)
39
+ addition = " gem.add_development_dependency 'rake'\n gem.add_development_dependency 'minitest'\n gem.add_development_dependency 'mocha'"
40
+
41
+ lines = File.read(gemspec).gsub('"', "'").split("\n")
42
+ index = lines.index {|line| line =~ /gem\.require_paths/}
43
+ raise "Could not find gem.require_paths line in #{gemspec}" unless index
44
+ lines.insert(index + 1, addition)
45
+ modified = lines.join("\n")
46
+ write_file(gemspec, modified + "\n")
47
+ end
48
+
49
+ def modify_rakefile(rakefile)
50
+ contents = File.read(rakefile)
51
+ if contents == %Q{require "bundler/gem_tasks"\n}
52
+ write_file(rakefile, %Q{require 'bundler/gem_tasks'\n})
53
+ end
54
+
55
+ append_to_file(rakefile, <<EOF)
56
+ require 'rake/testtask'
57
+
58
+ Rake::TestTask.new do |t|
59
+ t.libs = ['lib']
60
+ # t.warning = true
61
+ t.verbose = true
62
+ t.test_files = FileList['test/**/*.rb'].reject do |file|
63
+ file.end_with?('_lib.rb') || file.include?('/_lib/')
64
+ end
65
+ end
66
+ EOF
67
+ end
68
+ end
69
+ end
@@ -4,3 +4,4 @@ end
4
4
  require 'boiler/generator/base'
5
5
  require 'boiler/generator/script'
6
6
  require 'boiler/generator/suite'
7
+ require 'boiler/generator/touchup'
@@ -1,3 +1,3 @@
1
1
  module Boiler
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-17 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: minitest
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: mocha
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
14
62
  - !ruby/object:Gem::Dependency
15
63
  name: escort
16
64
  requirement: !ruby/object:Gem::Requirement
@@ -27,6 +75,22 @@ dependencies:
27
75
  - - ! '>='
28
76
  - !ruby/object:Gem::Version
29
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: chalk-log
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
30
94
  description: A boilerplate generator
31
95
  email:
32
96
  - gdb@gregbrockman.com
@@ -47,6 +111,7 @@ files:
47
111
  - lib/boiler/generator/base.rb
48
112
  - lib/boiler/generator/script.rb
49
113
  - lib/boiler/generator/suite.rb
114
+ - lib/boiler/generator/touchup.rb
50
115
  - lib/boiler/version.rb
51
116
  homepage: ''
52
117
  licenses: []
@@ -60,17 +125,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
125
  - - ! '>='
61
126
  - !ruby/object:Gem::Version
62
127
  version: '0'
128
+ segments:
129
+ - 0
130
+ hash: 2480003037247181513
63
131
  required_rubygems_version: !ruby/object:Gem::Requirement
64
132
  none: false
65
133
  requirements:
66
134
  - - ! '>='
67
135
  - !ruby/object:Gem::Version
68
136
  version: '0'
137
+ segments:
138
+ - 0
139
+ hash: 2480003037247181513
69
140
  requirements: []
70
141
  rubyforge_project:
71
- rubygems_version: 1.8.23
142
+ rubygems_version: 1.8.24
72
143
  signing_key:
73
144
  specification_version: 3
74
145
  summary: Generates boilerplate for you
75
146
  test_files: []
76
- has_rdoc: