Permalink
Browse files

getting ready for github integration

  • Loading branch information...
wbailey committed Dec 22, 2010
1 parent 6f60c9a commit afc472f76a7f7a878cb9cd228a2536988cf7ca5a
Showing with 183 additions and 74 deletions.
  1. +10 −2 Gemfile.lock
  2. +4 −0 Rakefile
  3. +16 −0 bin/edit_json.rb
  4. +16 −0 bin/gh
  5. +16 −0 bin/github
  6. +16 −0 bin/prettify_json.rb
  7. +1 −1 kata.gemspec
  8. +2 −65 lib/kata.rb
  9. +78 −0 lib/kata/base.rb
  10. +17 −0 lib/kata/setup.rb
  11. BIN pkg/kata-0.2.0.gem
  12. +6 −5 spec/kata_spec.rb
  13. +1 −1 spec/support/matchers/kata.rb
View
@@ -9,7 +9,12 @@ GEM
columnize (0.3.2)
define_exception (0.0.3)
diff-lcs (1.1.2)
- highline (1.6.1)
+ github (0.4.5)
+ highline (~> 1.5.1)
+ json (>= 1.2.0)
+ text-format (>= 1.0.0)
+ highline (1.5.2)
+ json (1.4.6)
linecache19 (0.5.11)
ruby_core_source (>= 0.1.4)
rspec (2.2.0)
@@ -30,6 +35,9 @@ GEM
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.4)
archive-tar-minitar (>= 0.5.2)
+ text-format (1.0.0)
+ text-hyphen (~> 1.0.0)
+ text-hyphen (1.0.0)
PLATFORMS
ruby
@@ -38,6 +46,6 @@ DEPENDENCIES
autotest
autotest-growl
define_exception
- highline
+ github
rspec (>= 2)
ruby-debug19
View
@@ -1,2 +1,6 @@
require 'bundler'
Bundler::GemHelper.install_tasks
+
+task :push do
+ system "gem push pkg/kata-0.2.0.gem"
+end
View
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'edit_json.rb' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('json', 'edit_json.rb')
View
16 bin/gh
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'gh' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('github', 'gh')
View
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'github' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('github', 'github')
View
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This file was generated by Bundler.
+#
+# The application 'prettify_json.rb' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler/setup'
+
+load Gem.bin_path('json', 'prettify_json.rb')
View
@@ -2,7 +2,7 @@ require 'date'
Gem::Specification.new do |gem|
gem.name = 'kata'
- gem.version = '0.2.0'
+ gem.version = '0.3.0'
gem.date = Date.today.to_s
gem.summary = 'A code kata DSL'
View
@@ -1,66 +1,3 @@
-module Kata
- @@times = []
+require 'kata/base'
- def kata txt, lib = nil
- puts txt
- yield if block_given?
- complete
- end
-
- def requirement txt
- puts indent + txt
-
- start = Time.now
-
- yield if block_given?
-
- rsp = ask "\ncontinue (Y|n): ", 'y'
-
- puts
-
- elapsed = Time.now - start
- @@times << {:title => txt, :time => elapsed}
-
- complete false if rsp.downcase == 'n'
- end
-
- def example txt
- puts indent + '- ' + txt
- end
-
- private
-
- def ask prompt, default
- print prompt
- $stdin.gets.chomp || default
- end
-
- def complete status = true
- if @@times.size > 0
- title = status ? 'Congratulations!' : 'You completed the following:'
-
- formatter = lambda do |sec|
- use = sec.round
- [use/3600, use/60 % 60, use % 60].map {|v| v.to_s.rjust(2,'0')}.join(':')
- end
-
- puts "\n\n#{title}"
- puts @@times.inject('') {|s,p| s << "- #{p[:title][0,70].ljust(70, ' ')} #{formatter.call(p[:time]).rjust(10,' ')}\n"}
- puts '-' * 70 + ' ' * 5 + '-' * 8
- puts 'Total Time taking Kata'.ljust(70, ' ') + ' ' * 5 + formatter.call(@@times.inject(0) {|s,h| s += h[:time]})
- end
-
- exit 1 unless status
- end
-
- def ancestry
- caller.grep(/#{Regexp.escape(__FILE__)}/).map {|v| v.match(/^[^`]*`([^']*)'/)[1]}
- end
-
- def indent
- nesting = ancestry.size - 2
- ' ' * (3 * nesting)
- end
-end
-
-include Kata
+include Kata::Base
View
@@ -0,0 +1,78 @@
+module Kata
+ module Base
+ @@times = []
+
+ def kata txt, lib = nil
+ @kata_name = txt
+ puts "#{@kata_name} Kata"
+ yield if block_given?
+ complete
+ end
+
+ def context txt
+ puts indent + txt
+ yield if block_given?
+ end
+
+ def requirement txt
+ puts indent + txt
+
+ start = Time.now
+
+ yield if block_given?
+
+ rsp = ask "\ncompleted (Y|n): ", 'y'
+
+ puts
+
+ elapsed = Time.now - start
+ @@times << {:title => txt, :time => elapsed}
+
+ complete false if rsp.downcase == 'n'
+ end
+
+ def example txt
+ puts indent + '- ' + txt
+ end
+
+ def detail txt
+ puts indent + '- ' + txt
+ end
+
+ private
+
+ def ask prompt, default
+ print prompt
+ $stdin.gets.chomp || default
+ end
+
+ def complete status = true
+ if @@times.size > 0
+ title = status ? 'Congratulations!' : 'You completed the following:'
+
+ formatter = lambda do |sec|
+ use = sec.round
+ [use/3600, use/60 % 60, use % 60].map {|v| v.to_s.rjust(2,'0')}.join(':')
+ end
+
+ puts "\n\n#{title}"
+ puts @@times.inject('') {|s,p| s << "- #{p[:title][0,70].ljust(70, ' ')} #{formatter.call(p[:time]).rjust(10,' ')}\n"}
+ puts '-' * 70 + ' ' * 5 + '-' * 8
+ puts "Total Time taking #{@kata_name} kata: ".ljust(70, ' ') + ' ' * 5 + formatter.call(@@times.inject(0) {|s,h| s += h[:time]})
+ end
+
+ exit 1 unless status
+ end
+
+ def ancestry
+ caller.grep(/#{Regexp.escape(__FILE__)}/).map {|v| v.match(/^[^`]*`([^']*)'/)[1]}
+ end
+
+ def indent
+ nesting = ancestry.size - 2
+ ' ' * (3 * nesting)
+ end
+ end
+end
+
+include Kata::Base
View
@@ -0,0 +1,17 @@
+module Kata
+ module Setup
+ def build_repo(kata_name)
+ build_tree(kata_name)
+ end
+
+ def build_tree(kata_name)
+ repo = 'kata-' + Time.now.strftime('%Y-%m-%d-%H:%M')
+ %W{#{repo}/lib #{repo}/spec/support/helpers #{repo}/spec/support/matchers}.each {|path| mkdir_p path}
+ end
+
+ # FileUtils really depends on rmagick? grrr
+ def mkdir_p(path)
+ %x{mkdir -p #{path}}
+ end
+ end
+end
View
Binary file not shown.
View
@@ -4,6 +4,7 @@
describe "Kata DSL" do
before :each do
@summary = 'sample summary'
+ @display_summary = "#{@summary} Kata"
end
context "kata" do
@@ -31,7 +32,7 @@
}.should_not raise_exception
end
- output.should have_summary @summary
+ output.should have_summary @display_summary
end
it "displays the summary with block" do
@@ -42,7 +43,7 @@
}.should_not raise_exception
end
- output.should have_summary @summary
+ output.should have_summary @display_summary
end
end
@@ -81,7 +82,7 @@
}.should_not raise_exception
end
- output.should have_requirement @summary, @requirement
+ output.should have_requirement @display_summary, @requirement
end
it "displays the summary with block" do
@@ -94,7 +95,7 @@
}.should_not raise_exception
end
- output.should have_requirement @summary, @requirement
+ output.should have_requirement @display_summary, @requirement
end
end
@@ -133,7 +134,7 @@
}.should_not raise_exception
end
- output.should have_examples @summary, @requirement, @examples
+ output.should have_examples @display_summary, @requirement, @examples
end
end
end
@@ -13,6 +13,6 @@
RSpec::Matchers.define :have_examples do |summary, requirement, examples|
example_str = examples.unshift('').join("\n - ")
match do |string|
- string.split(/continue \(Y|n\)/)[0].strip == "#{summary}\n #{requirement}#{example_str}"
+ string.split(/completed \(Y|n\)/)[0].strip == "#{summary}\n #{requirement}#{example_str}"
end
end

0 comments on commit afc472f

Please sign in to comment.