lita-spendo 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/lita/handlers/spendo.rb +20 -24
- data/lita-spendo.gemspec +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e2bedaaf4a9503e10fe4eeaf27b86ad18f3f91fa
         | 
| 4 | 
            +
              data.tar.gz: 4ab535ee09e7ee7024d6cd2e8e720b9bc00075a9
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 94d54fa86def758243f2898c2aa4ced26103b5dfea46018ed72460220b425652bedda668beb48c1f2f72ee0bf9fa474638bf076ec0ca721e2677bc66c68f3567
         | 
| 7 | 
            +
              data.tar.gz: 14aba49b5bb34ec4d1c7640e5363436067dca484cf80adc9e9d365b27bfb6cd52934b257619e2c0c4da4ea31bbc75320a3fe4cffff1754d36863c3576d9bb8e6
         | 
    
        data/README.md
    CHANGED
    
    | @@ -21,13 +21,13 @@ Spendo relies on the aws-sdk gem so it requires an AWS account. The account requ | |
| 21 21 |  | 
| 22 22 | 
             
            ``` ruby
         | 
| 23 23 | 
             
            {
         | 
| 24 | 
            -
              nickname | 
| 25 | 
            -
              aws_account_id | 
| 26 | 
            -
              aws_access_key_id | 
| 27 | 
            -
              aws_secret_access_key | 
| 28 | 
            -
              aws_region | 
| 29 | 
            -
              room | 
| 30 | 
            -
              dynamodb_table | 
| 24 | 
            +
              'nickname'              => 'foo',
         | 
| 25 | 
            +
              'aws_account_id'        => ENV['AWS_ACCOUNT_ID'],
         | 
| 26 | 
            +
              'aws_access_key_id'     => ENV['AWS_ACCESS_KEY_ID'],
         | 
| 27 | 
            +
              'aws_secret_access_key' => ENV['AWS_SECRET_ACCESS_KEY'],
         | 
| 28 | 
            +
              'aws_region'            => 'us-east-1',
         | 
| 29 | 
            +
              'room'                  => 'shell', # or room JID or whatever
         | 
| 30 | 
            +
              'dynamodb_table'        => 'BillingHistory'
         | 
| 31 31 | 
             
            }
         | 
| 32 32 | 
             
            ```
         | 
| 33 33 |  | 
    
        data/lib/lita/handlers/spendo.rb
    CHANGED
    
    | @@ -7,11 +7,11 @@ module Lita | |
| 7 7 | 
             
                  attr_accessor :account, :table_name
         | 
| 8 8 |  | 
| 9 9 | 
             
                  def initialize(params={})
         | 
| 10 | 
            -
                    @aws_access_key_id     = params[ | 
| 11 | 
            -
                    @aws_secret_access_key = params[ | 
| 12 | 
            -
                    @aws_region | 
| 13 | 
            -
                    @account | 
| 14 | 
            -
                    @table_name | 
| 10 | 
            +
                    @aws_access_key_id     = params['aws_access_key_id']
         | 
| 11 | 
            +
                    @aws_secret_access_key = params['aws_secret_access_key']
         | 
| 12 | 
            +
                    @aws_region            = params['aws_region']
         | 
| 13 | 
            +
                    @account               = params['aws_account_id']
         | 
| 14 | 
            +
                    @table_name            = params['dynamodb_table']
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 |  | 
| 17 17 | 
             
                  def latest
         | 
| @@ -39,12 +39,12 @@ module Lita | |
| 39 39 | 
             
                  # account to monitor.
         | 
| 40 40 | 
             
                  # config.accounts = [
         | 
| 41 41 | 
             
                  #   {
         | 
| 42 | 
            -
                  #      | 
| 43 | 
            -
                  #      | 
| 44 | 
            -
                  #      | 
| 45 | 
            -
                  #      | 
| 46 | 
            -
                  #      | 
| 47 | 
            -
                  #      | 
| 42 | 
            +
                  #     'aws_account_id'        => 'foo',
         | 
| 43 | 
            +
                  #     'dynamodb_table'        => 'BillingHistory',
         | 
| 44 | 
            +
                  #     'room'                  => 'shell',
         | 
| 45 | 
            +
                  #     'aws_access_key_id'     => 'foo',
         | 
| 46 | 
            +
                  #     'aws_secret_access_key' => 'foo',
         | 
| 47 | 
            +
                  #     'nickname'              => 'foo'
         | 
| 48 48 | 
             
                  #   }
         | 
| 49 49 | 
             
                  # ]
         | 
| 50 50 | 
             
                  config :accounts,       type: Array
         | 
| @@ -60,8 +60,8 @@ module Lita | |
| 60 60 | 
             
                  end
         | 
| 61 61 |  | 
| 62 62 | 
             
                  def setup(account)
         | 
| 63 | 
            -
                    if account[ | 
| 64 | 
            -
                      robot.join account[ | 
| 63 | 
            +
                    if account['room']
         | 
| 64 | 
            +
                      robot.join account['room']
         | 
| 65 65 | 
             
                    end
         | 
| 66 66 |  | 
| 67 67 | 
             
                    every(config.time_between_polls) do |timer|
         | 
| @@ -79,19 +79,13 @@ module Lita | |
| 79 79 | 
             
                  end
         | 
| 80 80 |  | 
| 81 81 | 
             
                  def create_client(account)
         | 
| 82 | 
            -
                    params =  | 
| 83 | 
            -
                      aws_account_id:        account[:aws_account_id],
         | 
| 84 | 
            -
                      aws_region:            account[:aws_region],
         | 
| 85 | 
            -
                      dynamodb_table:        account[:dynamodb_table],
         | 
| 86 | 
            -
                      aws_access_key_id:     account[:aws_access_key_id],
         | 
| 87 | 
            -
                      aws_secret_access_key: account[:aws_secret_access_key]
         | 
| 88 | 
            -
                    }
         | 
| 82 | 
            +
                    params = account.dup
         | 
| 89 83 |  | 
| 90 84 | 
             
                    BillingHistory.new(params)
         | 
| 91 85 | 
             
                  end
         | 
| 92 86 |  | 
| 93 87 | 
             
                  def lookup_account(nickname)
         | 
| 94 | 
            -
                    config.accounts.select {|a| a[ | 
| 88 | 
            +
                    config.accounts.select {|a| a['nickname'] == nickname }.first
         | 
| 95 89 | 
             
                  end
         | 
| 96 90 |  | 
| 97 91 | 
             
                  def create_message(account)
         | 
| @@ -104,7 +98,7 @@ module Lita | |
| 104 98 | 
             
                    alert_level      = data['AlertLevel'].to_i
         | 
| 105 99 | 
             
                    categorized_fees = data['FeesByCategory']
         | 
| 106 100 |  | 
| 107 | 
            -
                    message = "The current fees alert threshold has been reached.\n"
         | 
| 101 | 
            +
                    message = "/code The current fees alert threshold has been reached.\n"
         | 
| 108 102 | 
             
                    message << "\nAccount: #{account[:nickname]} #{account_id}"
         | 
| 109 103 | 
             
                    message << "\nCurrent fees: $#{current_fees}"
         | 
| 110 104 | 
             
                    message << "\nExpected monthly fees: $#{expected_fees}" # TODO
         | 
| @@ -112,9 +106,11 @@ module Lita | |
| 112 106 | 
             
                    message << "\n\n Fee Category Breakdown\n\n"
         | 
| 113 107 |  | 
| 114 108 | 
             
                    categorized_fees.keys.sort.each do |k|
         | 
| 109 | 
            +
                      category = k.strip.ljust(20)
         | 
| 115 110 | 
             
                      value = categorized_fees[k].to_f
         | 
| 116 111 | 
             
                      next if value == 0.0
         | 
| 117 | 
            -
                       | 
| 112 | 
            +
                      amount = sprintf('%8.2f', value.round(2))
         | 
| 113 | 
            +
                      message << "#{category}: $#{amount}\n"
         | 
| 118 114 | 
             
                    end
         | 
| 119 115 |  | 
| 120 116 | 
             
                    url = config.base_image_url + "/#{alert_level}.jpg"
         | 
| @@ -155,7 +151,7 @@ module Lita | |
| 155 151 |  | 
| 156 152 | 
             
                    if last_data && alert_level_changed?(last_data, current_data)
         | 
| 157 153 | 
             
                      message, url = create_message account
         | 
| 158 | 
            -
                      target = Source.new(room: account[ | 
| 154 | 
            +
                      target = Source.new(room: account['room'])
         | 
| 159 155 | 
             
                      robot.send_messages(target, message, url)
         | 
| 160 156 | 
             
                    else
         | 
| 161 157 | 
             
                      log.debug "alert level unchanged"
         | 
    
        data/lita-spendo.gemspec
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: lita-spendo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.4.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Chris Chalfant
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-05- | 
| 11 | 
            +
            date: 2015-05-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: lita
         |