Class: TasteTester::Client
- Inherits:
-
Object
- Object
- TasteTester::Client
- Includes:
- BetweenMeals::Util, Logging
- Defined in:
- lib/taste_tester/client.rb
Overview
Client side upload functionality Ties together Repo/Changeset diff logic and Server/Knife uploads
Instance Attribute Summary collapse
-
#force ⇒ Object
Returns the value of attribute force.
-
#skip_checks ⇒ Object
Returns the value of attribute skip_checks.
Instance Method Summary collapse
- #checks ⇒ Object
-
#initialize(server) ⇒ Client
constructor
A new instance of Client.
- #upload ⇒ Object
Methods included from Logging
#formatter, formatterproc=, logger, #logger, use_log_formatter=, verbosity=
Constructor Details
#initialize(server) ⇒ Client
Returns a new instance of Client.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/taste_tester/client.rb', line 32 def initialize(server) path = File.(TasteTester::Config.repo) logger.warn("Using #{path}") @server = server @knife = BetweenMeals::Knife.new( :logger => logger, :user => @server.user, :ssl => TasteTester::Config.use_ssl, :host => @server.host, :port => @server.port, :role_dir => TasteTester::Config.roles, :cookbook_dirs => TasteTester::Config.cookbooks, :databag_dir => TasteTester::Config.databags, :checksum_dir => TasteTester::Config.checksum_dir, :role_type => TasteTester::Config.role_type, ) @knife.write_user_config @repo = BetweenMeals::Repo.get( TasteTester::Config.repo_type, TasteTester::Config.repo, logger, ) unless @repo.exists? raise "Could not open repo from #{TasteTester::Config.repo}" end end |
Instance Attribute Details
#force ⇒ Object
Returns the value of attribute force.
30 31 32 |
# File 'lib/taste_tester/client.rb', line 30 def force @force end |
#skip_checks ⇒ Object
Returns the value of attribute skip_checks.
30 31 32 |
# File 'lib/taste_tester/client.rb', line 30 def skip_checks @skip_checks end |
Instance Method Details
#checks ⇒ Object
59 60 61 62 63 |
# File 'lib/taste_tester/client.rb', line 59 def checks unless @skip_checks TasteTester::Hooks.repo_checks(TasteTester::Config.dryrun, @repo) end end |
#upload ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/taste_tester/client.rb', line 65 def upload checks unless @skip_checks logger.info("Last commit: #{@repo.head_rev} " + "'#{@repo.last_msg.split("\n").first}'" + " by #{@repo.[:email]}") if @force || !@server.latest_uploaded_ref logger.info('Full upload forced') if @force unless TasteTester::Config.skip_pre_upload_hook TasteTester::Hooks.pre_upload(TasteTester::Config.dryrun, @repo, nil, @repo.head_rev) end time(logger) { full } unless TasteTester::Config.skip_post_upload_hook TasteTester::Hooks.post_upload(TasteTester::Config.dryrun, @repo, nil, @repo.head_rev) end else # Since we also upload the index, we always need to run the # diff even if the version we're on is the same as the last # revision unless TasteTester::Config.skip_pre_upload_hook TasteTester::Hooks.pre_upload(TasteTester::Config.dryrun, @repo, @server.latest_uploaded_ref, @repo.head_rev) end begin time(logger) { partial } rescue BetweenMeals::Changeset::ReferenceError logger.warn('Something changed with your repo, doing full upload') time(logger) { full } end unless TasteTester::Config.skip_post_upload_hook TasteTester::Hooks.post_upload(TasteTester::Config.dryrun, @repo, @server.latest_uploaded_ref, @repo.head_rev) end end @server.latest_uploaded_ref = @repo.head_rev end |