Class: Snitch::Base
- Inherits:
-
Object
- Object
- Snitch::Base
- Defined in:
- lib/snitch/base.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
Instance Method Summary collapse
-
#commit_message(which = :long) ⇒ Object
Obtains the commit message from the svnlook class.
-
#initialize(repository, revision, config_file = '/home/deploy/.snitch') ⇒ Base
constructor
Creates a new instance of snitch from a repository path and a revision.
-
#tattle ⇒ Object
Sends the commit message to all the added services.
-
#use(s, attrs) ⇒ Object
Adds a service to the services array from a string or symbol of the service name and a hash of attributes.
Constructor Details
#initialize(repository, revision, config_file = '/home/deploy/.snitch') ⇒ Base
Creates a new instance of snitch from a repository path and a revision.
Snitch::Base.new('/var/www/apps/myapp/repos', 102)
You must have a config file in order for this to work. You can optionally pass in the path to the config file. The default config_file is /home/deploy/.snitch
Snitch::Base.new('/var/www/apps/myapp/repos', 102, '/some/other/path/to/config')
12 13 14 15 16 17 18 |
# File 'lib/snitch/base.rb', line 12 def initialize(repository, revision, config_file='/home/deploy/.snitch') Config.config_file_path = config_file unless config_file.nil? @config = Config::load @svnlook_bin = SvnLook.new(repository, revision, @config[:svnlook]) @services = [] @config[:services].each { |s, attrs| use(s, attrs) } end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/snitch/base.rb', line 3 def config @config end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
3 4 5 |
# File 'lib/snitch/base.rb', line 3 def services @services end |
Instance Method Details
#commit_message(which = :long) ⇒ Object
Obtains the commit message from the svnlook class. Takes either :long
or :short
as optional parameter.
* <tt>:long</tt> is the full commit message along with a list of all changed files.
* <tt>:short</tt> is a truncated version of the commit message that is less than 140 characters for twitter.
23 24 25 |
# File 'lib/snitch/base.rb', line 23 def (which=:long) @svnlook_bin.to_s(which) end |
#tattle ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/snitch/base.rb', line 40 def tattle long = (:long) short = (:short) @services.each do |s| s.tattle(s.class. == :long ? long : short) end end |
#use(s, attrs) ⇒ Object
31 32 33 |
# File 'lib/snitch/base.rb', line 31 def use(s, attrs) @services << Service.new_from_name(s, attrs) end |