Refactor into classes #7

Merged
merged 10 commits into from Dec 4, 2012

2 participants

@stewart

Moved everything that made sense to me into seperate classes. Please let me know if I missed anything. Tests should still pass, but Sinatra and Rails examples will have to be updated with the new(old) config syntax:

Gitnesse.configure do |config|
  config.repository_url = "git@github.com:hybridgroup/gitnesse-demo.wiki"
end
@deadprogram deadprogram commented on an outdated diff Dec 4, 2012
lib/gitnesse/features.rb
@@ -0,0 +1,38 @@
+module Gitnesse
+ class Features
+
+ # Public: Writes a feature to disk, given the filename and the
+ # features.
+ #
+ # filename - the filename to use for the feature
+ # features - the features to write to disk
+ #
+ def self.write_feature_file(filename, features)
@deadprogram
The Hybrid Group member
deadprogram added a line comment Dec 4, 2012

Why not name this self.write_file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@deadprogram deadprogram commented on an outdated diff Dec 4, 2012
lib/gitnesse/features.rb
+ # filename - the filename to use for the feature
+ # features - the features to write to disk
+ #
+ def self.write_feature_file(filename, features)
+ File.open(filename, "w") do |file|
+ file.write(gather_features(features))
+ end
+ end
+
+ # Public: Gathers features for placing into files. Currently only supports
+ # one feature per page. Others are discarded
+ #
+ # page_features - the features
+ #
+ # Returns a string containing the
+ def self.gather_features(page_features)
@deadprogram
The Hybrid Group member
deadprogram added a line comment Dec 4, 2012

Why not name this self.gather

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@deadprogram deadprogram commented on an outdated diff Dec 4, 2012
test/lib/gitnesse/commit_info_test.rb
- describe "with a defined git username and email" do
- before do
- Gitnesse.expects(:read_git_config).with("user.name").returns("Bob Smith")
- Gitnesse.expects(:read_git_config).with("user.email").returns("bob@bobsmith.com")
- end
-
- it { method.call.must_equal({ :name => "Bob Smith",
- :email => "bob@bobsmith.com",
- :message => "Update features with Gitnesse" }) }
+ before do
+ Gitnesse::GitConfig.expects(:read).with("user.name").returns("Bob Smith")
@deadprogram
The Hybrid Group member
deadprogram added a line comment Dec 4, 2012

Change to Bob Martin ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@deadprogram
The Hybrid Group member

Nicer way to re-architect the code. +1

@deadprogram deadprogram merged commit 1d2f80e into master Dec 4, 2012

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment