lapidary 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", ">= 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", ">= 1.0.0"
12
+ gem "jeweler", "~> 1.8.4"
13
+ if RUBY_VERSION <= '1.8.7'
14
+ gem "rcov", ">= 0"
15
+ else
16
+ gem "simplecov", ">= 0"
17
+ gem "simplecov-rcov", ">= 0"
18
+ end
19
+ gem "ci_reporter", ">= 1.7.0"
20
+ gem "flog", ">= 3.2.0"
21
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Kenji Hara
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,78 @@
1
+ = Lapidary
2
+
3
+ Lapidary is a RubyGem project support tool.
4
+ Faset mainly supports:
5
+ * RubyGem management and release based on {Jeweler}[https://github.com/technicalpickles/jeweler]
6
+ * RubyGem scaffold generation based on {Jeweler}[https://github.com/technicalpickles/jeweler]
7
+ * Behaviour driven development with {RSpec}[https://github.com/dchelimsky/rspec]
8
+ * Continuous integration with Jenkins by providing:
9
+ * Source code analysis with {Flog}[https://github.com/seattlerb/flog]
10
+ * Code coverage analysis with {RCov}[https://github.com/relevance/rcov] ({SimpleCov}[https://github.com/colszowka/simplecov])
11
+ * CI report with {CI::Reporter}[https://github.com/nicksieger/ci_reporter]
12
+
13
+ == Supported Ruby versions and implementations
14
+ Lapidary should work identically on:
15
+
16
+ * Ruby 1.9.3
17
+ * Ruby 1.9.2
18
+ * Ruby 1.8.7
19
+
20
+ == Install
21
+
22
+ You can install lapidary by gem.
23
+ gem install lapidary
24
+
25
+ == Usage
26
+
27
+ === scaffold new RubyGem project
28
+ $ lapidary hello-gem
29
+
30
+ === run rspec
31
+ $ rake spec
32
+ This task also measure the code coverage in Ruby 1.9.2/1.9.3.
33
+
34
+ === measure the code coverage(Ruby 1.8.7)
35
+ $ rake spec:rcov
36
+
37
+ === output CI reports
38
+ $ rake ci:setup:rspec spec
39
+
40
+ === set gem version
41
+ $ rake version:write MAJOR=0 MINOR=1 PATCH=0
42
+
43
+ === increment major version
44
+ $ rake version:bump:major
45
+
46
+ === increment minor version
47
+ $ rake version:bump:minor
48
+
49
+ === increment patch version
50
+ $ rake version:bump:patch
51
+
52
+ === build gem
53
+ $ rake build
54
+
55
+ === release gem to RubyGems.org
56
+ $ rake release
57
+
58
+ === Other
59
+
60
+ Rake tasks are based on {Jeweler}[https://github.com/technicalpickles/jeweler].
61
+
62
+ You can get more information from {github.com/technicalpickles/jeweler}[https://github.com/technicalpickles/jeweler].
63
+
64
+ == Contributing to Lapidary
65
+
66
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
67
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
68
+ * Fork the project.
69
+ * Start a feature/bugfix branch.
70
+ * Commit and push until you are happy with your contribution.
71
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
72
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
73
+
74
+ == Copyright
75
+
76
+ Copyright (c) 2012 Kenji Hara. See LICENSE.txt for
77
+ further details.
78
+
data/Rakefile ADDED
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require "rake"
13
+
14
+ require "jeweler"
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "lapidary"
18
+ gem.homepage = "http://github.com/haracane/lapidary"
19
+ gem.license = "MIT"
20
+ gem.summary = "Helper for creating RubyGem project"
21
+ gem.description = "Helper for creating RubyGem project"
22
+ gem.email = "haracane@gmail.com"
23
+ gem.authors = ["Kenji Hara"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require "rspec/core"
29
+ require "rspec/core/rake_task"
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList["spec/**/*_spec.rb"]
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = "spec/**/*_spec.rb"
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require "rdoc/task"
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
44
+
45
+ rdoc.rdoc_dir = "rdoc"
46
+ rdoc.title = "lapidary #{version}"
47
+ rdoc.rdoc_files.include("README*")
48
+ rdoc.rdoc_files.include("lib/**/*.rb")
49
+ end
50
+
51
+ require "ci/reporter/rake/rspec" # use this if you're using RSpec
52
+
53
+ if RUBY_VERSION <= '1.8.7'
54
+ require "rcov"
55
+ RSpec::Core::RakeTask.new("spec:rcov") do |t|
56
+ t.rcov = true
57
+ t.rspec_opts = ["-c"]
58
+ t.rcov_opts = ["-x", "spec"]
59
+ end
60
+ else
61
+ RSpec::Core::RakeTask.new("spec:rcov") do |t|
62
+ t.rspec_opts = ["-v"]
63
+ end
64
+ end
65
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/lapidary ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "lapidary"
4
+
5
+ exit_code = Lapidary::Command::Build.run(ARGV) || 0
6
+
7
+ exit exit_code
data/lapidary.gemspec ADDED
@@ -0,0 +1,85 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "lapidary"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kenji Hara"]
12
+ s.date = "2013-01-05"
13
+ s.description = "Helper for creating RubyGem project"
14
+ s.email = "haracane@gmail.com"
15
+ s.executables = ["lapidary"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ "Gemfile",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/lapidary",
29
+ "lapidary.gemspec",
30
+ "lib/lapidary.rb",
31
+ "lib/lapidary/command/build.rb",
32
+ "lib/lapidary/templates/.document.erb",
33
+ "lib/lapidary/templates/.gitignore.erb",
34
+ "lib/lapidary/templates/.rspec.erb",
35
+ "lib/lapidary/templates/Gemfile.erb",
36
+ "lib/lapidary/templates/LICENSE.txt.erb",
37
+ "lib/lapidary/templates/README.rdoc.erb",
38
+ "lib/lapidary/templates/Rakefile.erb",
39
+ "lib/lapidary/templates/bin/project.erb",
40
+ "lib/lapidary/templates/lib/project.rb.erb",
41
+ "lib/lapidary/templates/spec/lib/project_spec.rb.erb",
42
+ "lib/lapidary/templates/spec/spec_helper.rb.erb",
43
+ "spec/bin/lapidary_spec.rb",
44
+ "spec/lib/lapidary_spec.rb",
45
+ "spec/reports/SPEC-Lapidary.xml",
46
+ "spec/reports/SPEC-bin-lapidary.xml",
47
+ "spec/spec_helper.rb"
48
+ ]
49
+ s.homepage = "http://github.com/haracane/lapidary"
50
+ s.licenses = ["MIT"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = "1.8.24"
53
+ s.summary = "Helper for creating RubyGem project"
54
+
55
+ if s.respond_to? :specification_version then
56
+ s.specification_version = 3
57
+
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
+ s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
60
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
61
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
62
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
63
+ s.add_development_dependency(%q<rcov>, [">= 0"])
64
+ s.add_development_dependency(%q<ci_reporter>, [">= 1.7.0"])
65
+ s.add_development_dependency(%q<flog>, [">= 3.2.0"])
66
+ else
67
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
68
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
69
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
70
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
71
+ s.add_dependency(%q<rcov>, [">= 0"])
72
+ s.add_dependency(%q<ci_reporter>, [">= 1.7.0"])
73
+ s.add_dependency(%q<flog>, [">= 3.2.0"])
74
+ end
75
+ else
76
+ s.add_dependency(%q<rspec>, [">= 2.8.0"])
77
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
78
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
79
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
80
+ s.add_dependency(%q<rcov>, [">= 0"])
81
+ s.add_dependency(%q<ci_reporter>, [">= 1.7.0"])
82
+ s.add_dependency(%q<flog>, [">= 3.2.0"])
83
+ end
84
+ end
85
+
@@ -0,0 +1,98 @@
1
+ module Lapidary
2
+ module Command
3
+ module Build
4
+ def self.run(argv)
5
+ @user_name = `/usr/bin/env git config --get user.name`.chomp
6
+ @user_email = `/usr/bin/env git config --get user.email`.chomp
7
+ @github_user = `/usr/bin/env git config --get github.user`.chomp
8
+
9
+ next_argv = []
10
+ while 0 < argv.length
11
+ val = argv.shift
12
+ case val
13
+ when "--test"
14
+ @user_name = "Test User"
15
+ @user_email = "test@mail.com"
16
+ @github_user = "testuser"
17
+ else
18
+ next_argv.push val
19
+ end
20
+ end
21
+
22
+ argv = next_argv
23
+
24
+ if @user_name == ""
25
+ STDERR.puts "ERROR: user.name is not set in git config"
26
+ return 1
27
+ end
28
+
29
+ if @user_email == ""
30
+ STDERR.puts "ERROR: user.email is not set in git config"
31
+ return 1
32
+ end
33
+
34
+ if @github_user == ""
35
+ STDERR.puts "ERROR: github.user is not set in git config"
36
+ return 1
37
+ end
38
+
39
+ @project_name = argv.shift
40
+ @module_name = Lapidary.to_camel_case(@project_name)
41
+
42
+ [
43
+ @project_name,
44
+ "#{@project_name}/bin",
45
+ "#{@project_name}/lib",
46
+ "#{@project_name}/spec",
47
+ "#{@project_name}/spec/lib"
48
+ ].each do |dirpath|
49
+ Dir.mkdir(dirpath) unless FileTest.exist?(dirpath)
50
+ end
51
+
52
+ all_flag = false
53
+
54
+ [
55
+ ".document",
56
+ ".gitignore",
57
+ ".rspec",
58
+ "Gemfile",
59
+ "LICENSE.txt",
60
+ "README.rdoc",
61
+ "Rakefile",
62
+ "bin/project",
63
+ "lib/project.rb",
64
+ "spec/spec_helper.rb",
65
+ "spec/lib/project_spec.rb",
66
+ ].each do |filepath|
67
+ content = ERB.new(File.read("#{Lapidary::TEMPLATES_DIR}/#{filepath}.erb")).result(binding)
68
+ dest_path = "#{@project_name}/#{filepath.gsub(/project/, @project_name)}"
69
+ exist_flag = FileTest.exist?(dest_path)
70
+ if !all_flag && exist_flag
71
+ STDOUT.print "overwrite #{dest_path}?(y/n/a): "
72
+ answer = STDIN.gets
73
+ answer.chomp!
74
+ case answer
75
+ when "y"
76
+ when "n"
77
+ next
78
+ when "a"
79
+ all_flag = true
80
+ end
81
+ end
82
+ File.open(dest_path, "w") do |f|
83
+ f.write(content)
84
+ end
85
+ if exist_flag
86
+ STDOUT.puts "overwrited #{dest_path}"
87
+ else
88
+ STDOUT.puts "created #{dest_path}"
89
+ end
90
+ end
91
+
92
+ File.chmod(0755, "#{@project_name}/bin/#{@project_name}")
93
+
94
+ return 0
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,52 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
50
+
51
+ Gemfile.lock
52
+
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", ">= 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", ">= 1.0.0"
12
+ gem "jeweler", "~> 1.8.4"
13
+ if RUBY_VERSION <= '1.8.7'
14
+ gem "rcov", ">= 0"
15
+ else
16
+ gem "simplecov", ">= 0"
17
+ gem "simplecov-rcov", ">= 0"
18
+ end
19
+ gem "ci_reporter", ">= 1.7.0"
20
+ gem "flog", ">= 3.2.0"
21
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 <%=@user_name%>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = <%=@project_name%>
2
+
3
+ <%=@project_name%> RubyGem.
4
+
5
+ == Contributing to <%=@project_name%>
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 <%=@user_name%>. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require "rake"
13
+
14
+ require "jeweler"
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "<%=@project_name%>"
18
+ gem.homepage = "http://github.com/<%=@github_user%>/<%=@project_name%>"
19
+ gem.license = "MIT"
20
+ gem.summary = "<%=@project_name%> RubyGem"
21
+ gem.description = "<%=@project_name%> RubyGem"
22
+ gem.email = "<%=@user_email%>"
23
+ gem.authors = ["<%=@user_name%>"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require "rspec/core"
29
+ require "rspec/core/rake_task"
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList["spec/**/*_spec.rb"]
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = "spec/**/*_spec.rb"
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require "rdoc/task"
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
44
+
45
+ rdoc.rdoc_dir = "rdoc"
46
+ rdoc.title = "<%=@project_name%> #{version}"
47
+ rdoc.rdoc_files.include("README*")
48
+ rdoc.rdoc_files.include("lib/**/*.rb")
49
+ end
50
+
51
+ require "ci/reporter/rake/rspec" # use this if you're using RSpec
52
+
53
+ if RUBY_VERSION <= '1.8.7'
54
+ require "rcov"
55
+ RSpec::Core::RakeTask.new("spec:rcov") do |t|
56
+ t.rcov = true
57
+ t.rspec_opts = ["-c"]
58
+ t.rcov_opts = ["-x", "spec"]
59
+ end
60
+ else
61
+ RSpec::Core::RakeTask.new("spec:rcov") do |t|
62
+ t.rspec_opts = ["-v"]
63
+ end
64
+ end
65
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "<%=@project_name%>"
4
+
5
+ exit 0
@@ -0,0 +1,28 @@
1
+ require "logger"
2
+
3
+ module <%=@module_name%>
4
+ def self.logger
5
+ if @logger.nil?
6
+ @logger = (rails_logger || default_logger)
7
+ @logger.formatter = proc { |severity, datetime, progname, msg|
8
+ datetime.strftime("[%Y-%m-%d %H:%M:%S](#{severity})#{msg}\n")
9
+ }
10
+ end
11
+ return @logger
12
+ end
13
+
14
+ def self.rails_logger
15
+ (defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
16
+ (defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
17
+ end
18
+
19
+ def self.default_logger
20
+ l = Logger.new(STDERR)
21
+ l.level = Logger::INFO
22
+ l
23
+ end
24
+
25
+ def self.logger=(logger)
26
+ @logger = logger
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ require "spec_helper"
2
+
3
+ describe <%=@module_name%> do
4
+ it "should success" do
5
+ end
6
+ end
@@ -0,0 +1,40 @@
1
+ if RUBY_VERSION <= '1.8.7'
2
+ else
3
+ require "simplecov"
4
+ require "simplecov-rcov"
5
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6
+ SimpleCov.start
7
+ end
8
+
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
11
+ require "rspec"
12
+ require "<%=@project_name%>"
13
+ require "tempfile"
14
+
15
+ # Requires supporting files with custom matchers and macros, etc,
16
+ # in ./support/ and its subdirectories.
17
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
18
+
19
+ RSpec.configure do |config|
20
+
21
+ end
22
+
23
+ module <%=@module_name%>
24
+ <%=@project_name.upcase%>_HOME = File.expand_path(File.dirname(__FILE__) + "/..")
25
+ BIN_DIR = "#{<%=@project_name.upcase%>_HOME}/bin"
26
+ LIB_DIR = "#{<%=@project_name.upcase%>_HOME}/lib"
27
+ RUBY_CMD = "/usr/bin/env ruby -I #{LIB_DIR}"
28
+ REDIRECT = {}
29
+ end
30
+
31
+ <%=@module_name%>.logger = Logger.new(STDERR)
32
+ if File.exist?('/tmp/<%=@project_name%>.debug') then
33
+ <%=@module_name%>.logger.level = Logger::DEBUG
34
+ <%=@module_name%>::REDIRECT[:stdout] = nil
35
+ <%=@module_name%>::REDIRECT[:stderr] = nil
36
+ else
37
+ <%=@module_name%>.logger.level = Logger::ERROR
38
+ <%=@module_name%>::REDIRECT[:stdout] = "> /dev/null"
39
+ <%=@module_name%>::REDIRECT[:stderr] = "2> /dev/null"
40
+ end
data/lib/lapidary.rb ADDED
@@ -0,0 +1,36 @@
1
+ require "logger"
2
+ require "erb"
3
+ require "lapidary/command/build"
4
+
5
+ module Lapidary
6
+ TEMPLATES_DIR = File.expand_path(File.join(File.dirname(__FILE__), "lapidary", "templates"))
7
+
8
+ def self.to_camel_case(str)
9
+ return str.split('_').map{|word| word.capitalize}.join
10
+ end
11
+
12
+ def self.logger
13
+ if @logger.nil?
14
+ @logger = (rails_logger || default_logger)
15
+ @logger.formatter = proc { |severity, datetime, progname, msg|
16
+ datetime.strftime("[%Y-%m-%d %H:%M:%S](#{severity})#{msg}\n")
17
+ }
18
+ end
19
+ return @logger
20
+ end
21
+
22
+ def self.rails_logger
23
+ (defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
24
+ (defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
25
+ end
26
+
27
+ def self.default_logger
28
+ l = Logger.new(STDERR)
29
+ l.level = Logger::INFO
30
+ l
31
+ end
32
+
33
+ def self.logger=(logger)
34
+ @logger = logger
35
+ end
36
+ end
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ describe "bin/lapidary" do
4
+ before :all do
5
+ @stdout_redirect = Lapidary::REDIRECT[:stdout]
6
+ @stderr_redirect = Lapidary::REDIRECT[:stderr]
7
+ end
8
+
9
+ it "should create valid gem template" do
10
+ work_dir = "/tmp/#{ENV["USER"]}"
11
+ if ! FileTest.exists?(work_dir)
12
+ Dir.mkdir(work_dir)
13
+ end
14
+ Dir.chdir(work_dir){
15
+ if FileTest.exists?("lapidary_test")
16
+ result = system("rm -rf lapidary_test")
17
+ result.should be_true
18
+ end
19
+ system("#{Lapidary::RUBY_CMD} #{Lapidary::BIN_DIR}/lapidary --test lapidary_test #{@stdout_redirect} #{@stderr_redirect}").should be_true
20
+ Dir.chdir("lapidary_test"){
21
+ result = system("rake spec spec:rcov #{@stdout_redirect} #{@stderr_redirect}")
22
+ result.should be_true
23
+
24
+ FileTest.exists?("coverage").should be_true
25
+
26
+ File::Stat.new("./bin/lapidary_test").mode.should == 0100755
27
+
28
+ system("ruby -I ./lib ./bin/lapidary_test").should be_true
29
+ }
30
+
31
+
32
+ # Dir.chdir("lapidary_test"){
33
+ # result = system("rake ci:setup:rspec spec #{@stdout_redirect} #{@stderr_redirect}")
34
+ # result.should be_true
35
+ #
36
+ # FileTest.exists?("spec/reports").should be_true
37
+ # }
38
+ }
39
+ end
40
+ end
@@ -0,0 +1,6 @@
1
+ require "spec_helper"
2
+
3
+ describe Lapidary do
4
+ it "should success" do
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite skipped="0" errors="0" tests="1" name="Lapidary" time="0.000584" failures="0">
3
+ <testcase name="Lapidary should success" time="0.000194">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite skipped="0" errors="0" tests="1" name="bin/lapidary" time="2.715619" failures="0">
3
+ <testcase name="bin/lapidary should create valid gem template" time="2.71509">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,40 @@
1
+ if RUBY_VERSION <= '1.8.7'
2
+ else
3
+ require "simplecov"
4
+ require "simplecov-rcov"
5
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
6
+ SimpleCov.start
7
+ end
8
+
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
11
+ require "rspec"
12
+ require "lapidary"
13
+ require "tempfile"
14
+
15
+ # Requires supporting files with custom matchers and macros, etc,
16
+ # in ./support/ and its subdirectories.
17
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
18
+
19
+ RSpec.configure do |config|
20
+
21
+ end
22
+
23
+ module Lapidary
24
+ LAPIDARY_HOME = File.expand_path(File.dirname(__FILE__) + "/..")
25
+ BIN_DIR = "#{LAPIDARY_HOME}/bin"
26
+ LIB_DIR = "#{LAPIDARY_HOME}/lib"
27
+ RUBY_CMD = "ruby -I #{LIB_DIR}"
28
+ REDIRECT = {}
29
+ end
30
+
31
+ Lapidary.logger = Logger.new(STDERR)
32
+ if File.exist?('/tmp/lapidary.debug') then
33
+ Lapidary.logger.level = Logger::DEBUG
34
+ Lapidary::REDIRECT[:stdout] = nil
35
+ Lapidary::REDIRECT[:stderr] = nil
36
+ else
37
+ Lapidary.logger.level = Logger::ERROR
38
+ Lapidary::REDIRECT[:stdout] = "> /dev/null"
39
+ Lapidary::REDIRECT[:stderr] = "2> /dev/null"
40
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lapidary
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Kenji Hara
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-01-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 47
28
+ segments:
29
+ - 2
30
+ - 8
31
+ - 0
32
+ version: 2.8.0
33
+ type: :development
34
+ name: rspec
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 31
44
+ segments:
45
+ - 3
46
+ - 12
47
+ version: "3.12"
48
+ type: :development
49
+ name: rdoc
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 23
59
+ segments:
60
+ - 1
61
+ - 0
62
+ - 0
63
+ version: 1.0.0
64
+ type: :development
65
+ name: bundler
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ prerelease: false
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 63
75
+ segments:
76
+ - 1
77
+ - 8
78
+ - 4
79
+ version: 1.8.4
80
+ type: :development
81
+ name: jeweler
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ prerelease: false
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ hash: 3
91
+ segments:
92
+ - 0
93
+ version: "0"
94
+ type: :development
95
+ name: rcov
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ prerelease: false
99
+ requirement: &id006 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ hash: 11
105
+ segments:
106
+ - 1
107
+ - 7
108
+ - 0
109
+ version: 1.7.0
110
+ type: :development
111
+ name: ci_reporter
112
+ version_requirements: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ prerelease: false
115
+ requirement: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 15
121
+ segments:
122
+ - 3
123
+ - 2
124
+ - 0
125
+ version: 3.2.0
126
+ type: :development
127
+ name: flog
128
+ version_requirements: *id007
129
+ description: Helper for creating RubyGem project
130
+ email: haracane@gmail.com
131
+ executables:
132
+ - lapidary
133
+ extensions: []
134
+
135
+ extra_rdoc_files:
136
+ - LICENSE.txt
137
+ - README.rdoc
138
+ files:
139
+ - .document
140
+ - .rspec
141
+ - Gemfile
142
+ - LICENSE.txt
143
+ - README.rdoc
144
+ - Rakefile
145
+ - VERSION
146
+ - bin/lapidary
147
+ - lapidary.gemspec
148
+ - lib/lapidary.rb
149
+ - lib/lapidary/command/build.rb
150
+ - lib/lapidary/templates/.document.erb
151
+ - lib/lapidary/templates/.gitignore.erb
152
+ - lib/lapidary/templates/.rspec.erb
153
+ - lib/lapidary/templates/Gemfile.erb
154
+ - lib/lapidary/templates/LICENSE.txt.erb
155
+ - lib/lapidary/templates/README.rdoc.erb
156
+ - lib/lapidary/templates/Rakefile.erb
157
+ - lib/lapidary/templates/bin/project.erb
158
+ - lib/lapidary/templates/lib/project.rb.erb
159
+ - lib/lapidary/templates/spec/lib/project_spec.rb.erb
160
+ - lib/lapidary/templates/spec/spec_helper.rb.erb
161
+ - spec/bin/lapidary_spec.rb
162
+ - spec/lib/lapidary_spec.rb
163
+ - spec/reports/SPEC-Lapidary.xml
164
+ - spec/reports/SPEC-bin-lapidary.xml
165
+ - spec/spec_helper.rb
166
+ homepage: http://github.com/haracane/lapidary
167
+ licenses:
168
+ - MIT
169
+ post_install_message:
170
+ rdoc_options: []
171
+
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ hash: 3
180
+ segments:
181
+ - 0
182
+ version: "0"
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ hash: 3
189
+ segments:
190
+ - 0
191
+ version: "0"
192
+ requirements: []
193
+
194
+ rubyforge_project:
195
+ rubygems_version: 1.8.24
196
+ signing_key:
197
+ specification_version: 3
198
+ summary: Helper for creating RubyGem project
199
+ test_files: []
200
+