Class: CodeFumesHarvester::Harvester
- Inherits:
-
Object
- Object
- CodeFumesHarvester::Harvester
- Defined in:
- lib/codefumes_harvester/harvester.rb
Overview
Simple class responsible for creating a project on the CodeFumes website, storing project information in the CodeFumes config file, and synchronizing a repository’s commit history with CodeFumes.com.
NOTE: Technically this can be used by anything (obviously), but it was written with the intention of being used with the harvest_repo_metrics
script, and is essentially geared for that scenario.
Constant Summary collapse
- DEFAULT_PATH =
:nodoc:
'./'
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(passed_in_options = {}) ⇒ Harvester
constructor
Accepts the following options: *
:path
- the path of the repository to gather information from (Defaults to ‘./’). -
#private_key ⇒ Object
Returns the CodeFumes private key of the project that is located at the supplied path.
-
#public_key ⇒ Object
Returns the CodeFumes public key of the project that is located at the supplied path.
-
#publish_data! ⇒ Object
Creates or updates a project information on the CodeFumes site, synchronizes the repository’s commit history, and prints the results to STDOUT.
-
#short_uri ⇒ Object
Returns the CodeFumes ‘short uri’ of the project that is located at the supplied path.
Constructor Details
#initialize(passed_in_options = {}) ⇒ Harvester
Accepts the following options:
-
:path
- the path of the repository to gather information from (Defaults to ‘./’). -
:public_key
- Sets the public key of the project. This property will be read from the CodeFumes config file if on exists for the repository supplied at:path
. -
:private_key
- Sets the private key of the project. This property will be read from the CodeFumes config file if on exists for the repository supplied at:path
. -
:name
- Sets the name of the project on the CodeFumes site
24 25 26 27 28 29 30 31 |
# File 'lib/codefumes_harvester/harvester.rb', line 24 def initialize( = {}) = .dup @path = File.(.delete(:path) || DEFAULT_PATH) @repository = initialize_repository .merge!(:public_key => [:public_key] || @repository.public_key) .merge!(:private_key => [:private_key] || @repository.private_key) @project = initialize_project() end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/codefumes_harvester/harvester.rb', line 11 def path @path end |
Instance Method Details
#private_key ⇒ Object
Returns the CodeFumes private key of the project that is located at the supplied path.
63 64 65 |
# File 'lib/codefumes_harvester/harvester.rb', line 63 def private_key @project.private_key end |
#public_key ⇒ Object
Returns the CodeFumes public key of the project that is located at the supplied path.
57 58 59 |
# File 'lib/codefumes_harvester/harvester.rb', line 57 def public_key @project.public_key end |
#publish_data! ⇒ Object
Creates or updates a project information on the CodeFumes site, synchronizes the repository’s commit history, and prints the results to STDOUT.
Returns a Hash containing the keys :successful_count and :total_count if the process succeeded and updates were posted to the server with their associated values.
Returns and empty Hash if the local repository is in sync with the server and no updates were posted.
Returns false
if the process failed.
45 46 47 48 49 50 51 52 53 |
# File 'lib/codefumes_harvester/harvester.rb', line 45 def publish_data! if @project.save store_public_key_in_repository update_codefumes_config_file generate_and_save_payload || {} else false end end |
#short_uri ⇒ Object
Returns the CodeFumes ‘short uri’ of the project that is located at the supplied path. The ‘short uri’ is similar to a Tiny URL for a project.
70 71 72 |
# File 'lib/codefumes_harvester/harvester.rb', line 70 def short_uri @project.short_uri end |