Class: PolarBear::CodeCollab
- Inherits:
-
Object
- Object
- PolarBear::CodeCollab
- Includes:
- Utils
- Defined in:
- lib/polarbear/codecollab.rb
Overview
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #active_reviews ⇒ Object
- #create_review(settings) ⇒ Object
- #delete_reviews(reviews) ⇒ Object
- #get_review_with_id(id) ⇒ Object
- #get_review_with_title(title) ⇒ Object
-
#initialize ⇒ Object
constructor
————————————————————————– ————————————————————————–.
- #last_review ⇒ Object
- #load_pb_options ⇒ Object
- #login(url, username, password) ⇒ Object
- #logout ⇒ Object
- #reviews_in_planning ⇒ Object
- #save_pb_options ⇒ Object
Methods included from Utils
Constructor Details
#initialize ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/polarbear/codecollab.rb', line 27 def initialize # do we have a config file? If so, load that and see if the exec path. if @polarbear_options[:ccollab_execpath].nil? p 'Searching for code collaborator executable...' @polarbear_options[:ccollab_execpath] = find_ccollab_executable end raise "Can't find code collab executable on your system" if @polarbear_options[:ccollab_execpath].nil? Utils::Executor.instance.set_codecollab_exec_path("#{@polarbear_options[:ccollab_execpath]}") @commands = {} @commands[:admin] = Command::Admin.new @commands[:config] = Command::Config.new @commands[:report] = Command::Report.new @configuration = Configuration.new(@commands[:config].load_from_local_settings) end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
21 22 23 |
# File 'lib/polarbear/codecollab.rb', line 21 def commands @commands end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
22 23 24 |
# File 'lib/polarbear/codecollab.rb', line 22 def configuration @configuration end |
Instance Method Details
#active_reviews ⇒ Object
50 51 52 53 |
# File 'lib/polarbear/codecollab.rb', line 50 def active_reviews reports_result = @commands[:report].request_active_report_for(@configuration.username) reports_result.map { |report| Review.new(report) } end |
#create_review(settings) ⇒ Object
77 78 79 80 81 |
# File 'lib/polarbear/codecollab.rb', line 77 def create_review(settings) review = PolarBear::Review.new(settings) review.create_it! review end |
#delete_reviews(reviews) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/polarbear/codecollab.rb', line 83 def delete_reviews(reviews) = PolarBear::Command::GlobalOptions.new batch = PolarBear::Command::Batch.new() reviews.each do |review| puts review.inspect batch.add_command('admin_review_cancel', {:review => "#{review.id}"}) end batch.execute end |
#get_review_with_id(id) ⇒ Object
65 66 67 68 69 |
# File 'lib/polarbear/codecollab.rb', line 65 def get_review_with_id(id) parser = Nori.new(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym }) review_hash = parser.parse(@commands[:admin].get_review_xml_info(id)) Review.new(review_hash[:reviews][:review][:general]) end |
#get_review_with_title(title) ⇒ Object
60 61 62 63 |
# File 'lib/polarbear/codecollab.rb', line 60 def get_review_with_title(title) reports_result = @commands[:report].get_review_with_title_for(@configuration.username, title) reports_result.map { |report| Review.new(report) } end |
#last_review ⇒ Object
71 72 73 74 75 |
# File 'lib/polarbear/codecollab.rb', line 71 def last_review parser = Nori.new(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym }) review_hash = parser.parse(@commands[:admin].get_review_xml_info('last')) Review.new(review_hash[:reviews][:review][:general]) end |
#load_pb_options ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/polarbear/codecollab.rb', line 103 def option_file="#{Dir.home}/.polarbear" if File.exist?(option_file) @polarbear_options = YAML.load_file(option_file) else @polarbear_options = {} end end |
#login(url, username, password) ⇒ Object
95 96 97 |
# File 'lib/polarbear/codecollab.rb', line 95 def login(url, username, password) Utils::Executor.instance.execute_command("login #{url} #{username} #{password}") end |
#logout ⇒ Object
99 100 101 |
# File 'lib/polarbear/codecollab.rb', line 99 def logout Utils::Executor.instance.execute_command('logout') end |
#reviews_in_planning ⇒ Object
55 56 57 58 |
# File 'lib/polarbear/codecollab.rb', line 55 def reviews_in_planning reports_result = @commands[:report].request_report_in_planning_for(@configuration.username) reports_result.map { |report| Review.new(report) } end |
#save_pb_options ⇒ Object
112 113 114 115 |
# File 'lib/polarbear/codecollab.rb', line 112 def option_file="#{Dir.home}/.polarbear" File.open(option_file, 'w') { |fo| fo.puts @polarbear_options.to_yaml } end |