lionel_richie 0.1.5.1 → 0.2.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 +9 -9
- data/.gitignore +1 -0
- data/CHANGELOG.md +12 -0
- data/README.md +25 -20
- data/bin/lionel +1 -27
- data/examples/Lionelfile.kanban.rb +41 -0
- data/lib/lionel.rb +11 -0
- data/lib/lionel/cli.rb +7 -3
- data/lib/lionel/configuration.rb +2 -1
- data/lib/lionel/export.rb +45 -46
- data/lib/lionel/export_builder.rb +35 -0
- data/lib/lionel/google_authentication.rb +1 -1
- data/lib/lionel/proxy_action.rb +3 -1
- data/lib/lionel/proxy_card.rb +5 -2
- data/lib/lionel/proxy_worksheet.rb +4 -2
- data/lib/lionel/version.rb +1 -1
- data/lionel_richie.gemspec +1 -0
- data/spec/lib/lionel/export_builder_spec.rb +27 -0
- data/spec/lib/lionel/export_spec.rb +0 -1
- data/spec/lib/lionel_spec.rb +23 -0
- metadata +24 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            !binary "U0hBMQ==":
         | 
| 3 3 | 
             
              metadata.gz: !binary |-
         | 
| 4 | 
            -
                 | 
| 4 | 
            +
                NGIyMjk4ZjAwYjc0ZTFhZjU3ZGY1NWY3ZWE5OTcxM2QzZmVlYjIwZg==
         | 
| 5 5 | 
             
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                 | 
| 7 | 
            -
             | 
| 6 | 
            +
                Mjk0YTljYjNkZDVlNDZlMTMzYTc3MWMyMWE4Nzc4MjNkOGJhOTk0Mg==
         | 
| 7 | 
            +
            SHA512:
         | 
| 8 8 | 
             
              metadata.gz: !binary |-
         | 
| 9 | 
            -
                 | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 9 | 
            +
                MTg3NmM5ZDMyM2FhOWExNjYxNjEwODY1ZWQzMDQzNDA0ZWQxMzA1Y2M3MWE5
         | 
| 10 | 
            +
                MzMyYzUyYWE0YTFmNGY3MDQyZGE5ZmQyNTZlMjYzZmNjM2JhYjQ4ZWEyM2U4
         | 
| 11 | 
            +
                NWMwNDU2MmVlYzQ1OWVkMTczNzY5NjBiYjIwODE0NTUwZDA3NTE=
         | 
| 12 12 | 
             
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                 | 
| 14 | 
            -
                 | 
| 15 | 
            -
                 | 
| 13 | 
            +
                ZWNlMDk4YWQyOTZjZTQ1ODc1NzU0YTA4NjBhMDNhYTRjZmYxMjc3MmEzMjMw
         | 
| 14 | 
            +
                ODRjYWE0MjJiMTEwZWQzNjI2MTk1YTM2MzQwNzk5MDM1YTY0YWU3YjgwZTU0
         | 
| 15 | 
            +
                NzQ0MzlmNWE4YTc0MDhkZTE2MzkyNmRhMDdkN2FhODBmNTMxNzM=
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,10 +1,12 @@ | |
| 1 1 | 
             
            # LionelRichie
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            [](https://codeclimate.com/github/rossta/lionel_richie)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            LionelRichie is a script for exporting Trello data to Google Docs.
         | 
| 4 6 |  | 
| 5 7 | 
             
            This gem is in its very early stages so its probably not useful to you yet.
         | 
| 6 8 |  | 
| 7 | 
            -
            
         | 
| 8 10 |  | 
| 9 11 | 
             
            ## Installation
         | 
| 10 12 |  | 
| @@ -42,58 +44,61 @@ You'll then be directed to authorize the application and retrieve your google to | |
| 42 44 |  | 
| 43 45 | 
             
            You should now be ready to run the export:
         | 
| 44 46 |  | 
| 45 | 
            -
                $ lionel export | 
| 46 | 
            -
                $ lionel export --print | 
| 47 | 
            +
                $ lionel export                         # uploads to your google doc
         | 
| 48 | 
            +
                $ lionel export --print                 # prints the output without uploading
         | 
| 49 | 
            +
                $ lionel export -c ./path/to/Lionelfile # uploads export configured by given Lionelfile
         | 
| 47 50 |  | 
| 48 51 | 
             
            When running this command for the first time, you'll be asked to enter your trello board id and google doc id, which you can grab from the respective URLs of those resources.
         | 
| 49 52 |  | 
| 50 53 | 
             
            Run `lionel` to see a list of the available commands and options.
         | 
| 51 54 |  | 
| 52 | 
            -
            ## Crafting the Export | 
| 55 | 
            +
            ## Crafting the Export
         | 
| 53 56 |  | 
| 54 | 
            -
             | 
| 57 | 
            +
            The export can be configured using the export DSL. Export methods take the form of a Google doc column, e.g. 'A', 'BC', etc. To set the value on a column, pass a value or a block. The block is rendered in the context of each `Card` object populated with data from Trello.
         | 
| 55 58 |  | 
| 59 | 
            +
            ```ruby
         | 
| 60 | 
            +
            # Lionelfile
         | 
| 56 61 | 
             
            LionelRichie.export do
         | 
| 57 62 | 
             
              # Card Id
         | 
| 58 | 
            -
               | 
| 63 | 
            +
              B { id }
         | 
| 59 64 |  | 
| 60 65 | 
             
              # Card Link
         | 
| 61 | 
            -
               | 
| 66 | 
            +
              C { link }
         | 
| 62 67 |  | 
| 63 68 | 
             
              # Ready date
         | 
| 64 | 
            -
               | 
| 65 | 
            -
                ready_action =  | 
| 66 | 
            -
                  (a.create? && a.board_id == trello_board_id) || a.moved_to?("Ready")
         | 
| 69 | 
            +
              D do |export|
         | 
| 70 | 
            +
                ready_action = first_action do |a|
         | 
| 71 | 
            +
                  (a.create? && a.board_id == export.trello_board_id) || a.moved_to?("Ready")
         | 
| 67 72 | 
             
                end
         | 
| 68 73 | 
             
                format_date(ready_action.date) if ready_action
         | 
| 69 74 | 
             
              end
         | 
| 70 75 |  | 
| 71 76 | 
             
              # In Progress date
         | 
| 72 | 
            -
               | 
| 77 | 
            +
              E { date_moved_to("In Progress") }
         | 
| 73 78 |  | 
| 74 79 | 
             
              # Code Review date
         | 
| 75 | 
            -
               | 
| 80 | 
            +
              F { date_moved_to("Code Review") }
         | 
| 76 81 |  | 
| 77 82 | 
             
              # Review date
         | 
| 78 | 
            -
               | 
| 83 | 
            +
              G { date_moved_to("Review") }
         | 
| 79 84 |  | 
| 80 85 | 
             
              # Deploy date
         | 
| 81 | 
            -
               | 
| 86 | 
            +
              H { date_moved_to("Deploy") }
         | 
| 82 87 |  | 
| 83 88 | 
             
              # Completed date
         | 
| 84 | 
            -
               | 
| 89 | 
            +
              I { date_moved_to("Completed") }
         | 
| 85 90 |  | 
| 86 91 | 
             
              # Type
         | 
| 87 | 
            -
               | 
| 92 | 
            +
              J { type }
         | 
| 88 93 |  | 
| 89 94 | 
             
              # Project
         | 
| 90 | 
            -
               | 
| 95 | 
            +
              K { project }
         | 
| 91 96 |  | 
| 92 97 | 
             
              # Estimate
         | 
| 93 | 
            -
               | 
| 98 | 
            +
              L { estimate }
         | 
| 94 99 |  | 
| 95 100 | 
             
              # Due Date
         | 
| 96 | 
            -
               | 
| 101 | 
            +
              M { due_date }
         | 
| 97 102 | 
             
            end
         | 
| 98 103 | 
             
            ```
         | 
| 99 104 |  | 
    
        data/bin/lionel
    CHANGED
    
    | @@ -19,30 +19,4 @@ def pute(*args) | |
| 19 19 | 
             
              $stderr.puts(*args)
         | 
| 20 20 | 
             
            end
         | 
| 21 21 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
              Lionel::CLI.start(ARGV)
         | 
| 24 | 
            -
             | 
| 25 | 
            -
            rescue GoogleDrive::Error, GoogleDrive::AuthenticationError => e
         | 
| 26 | 
            -
              @attempts ||= 0
         | 
| 27 | 
            -
              @attempts += 1
         | 
| 28 | 
            -
              Lionel::GoogleAuthentication.new.refresh
         | 
| 29 | 
            -
              if @attempts < 2
         | 
| 30 | 
            -
                retry
         | 
| 31 | 
            -
              else
         | 
| 32 | 
            -
                puts e.class
         | 
| 33 | 
            -
                puts "-" * e.class.name.size
         | 
| 34 | 
            -
                pute e.message
         | 
| 35 | 
            -
                puts "Unable to access Google Drive"
         | 
| 36 | 
            -
                puts "run 'lionel authorize google'"
         | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
            rescue Trello::Error, Trello::InvalidAccessToken => e
         | 
| 40 | 
            -
              puts "Unable to access Trello"
         | 
| 41 | 
            -
              puts "run 'lionel authorize trello'"
         | 
| 42 | 
            -
             | 
| 43 | 
            -
            rescue StandardError => e
         | 
| 44 | 
            -
              puts e.class
         | 
| 45 | 
            -
              puts "-" * e.class.name.size
         | 
| 46 | 
            -
              pute e.message
         | 
| 47 | 
            -
              raise e
         | 
| 48 | 
            -
            end
         | 
| 22 | 
            +
            Lionel::CLI.start(ARGV)
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            Lionel.export do
         | 
| 2 | 
            +
              B { id }
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              # Card link
         | 
| 5 | 
            +
              C { link(name.gsub(/^\[.*\]\s*/, "")) }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              # Ready date
         | 
| 8 | 
            +
              D do |export|
         | 
| 9 | 
            +
                ready_action = first_action do |a|
         | 
| 10 | 
            +
                  (a.create? && a.board_id == export.trello_board_id) || a.moved_to?("Ready")
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
                format_date(ready_action.date) if ready_action
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              # In Progress date
         | 
| 16 | 
            +
              E { date_moved_to("In Progress") }
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              # Code Review date
         | 
| 19 | 
            +
              F { date_moved_to("Code Review") }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              # Review date
         | 
| 22 | 
            +
              G { date_moved_to("Review") }
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              # Deploy date
         | 
| 25 | 
            +
              H { date_moved_to("Deploy") }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              # Completed date
         | 
| 28 | 
            +
              I { date_moved_to("Completed") }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              # Type
         | 
| 31 | 
            +
              J { type }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              # Project
         | 
| 34 | 
            +
              K { project }
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              # Estimate
         | 
| 37 | 
            +
              L { estimate }
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              # Due Date
         | 
| 40 | 
            +
              M { due_date }
         | 
| 41 | 
            +
            end
         | 
    
        data/lib/lionel.rb
    CHANGED
    
    | @@ -4,11 +4,13 @@ require 'google_drive' | |
| 4 4 | 
             
            require 'launchy'
         | 
| 5 5 | 
             
            require 'thor'
         | 
| 6 6 | 
             
            require 'logger'
         | 
| 7 | 
            +
            require 'forwardable'
         | 
| 7 8 | 
             
            require 'lionel/version'
         | 
| 8 9 | 
             
            require 'lionel/cli'
         | 
| 9 10 | 
             
            require 'lionel/configuration'
         | 
| 10 11 | 
             
            require 'lionel/configurable'
         | 
| 11 12 | 
             
            require 'lionel/export'
         | 
| 13 | 
            +
            require 'lionel/export_builder'
         | 
| 12 14 | 
             
            require 'lionel/proxy_action'
         | 
| 13 15 | 
             
            require 'lionel/proxy_card'
         | 
| 14 16 | 
             
            require 'lionel/proxy_worksheet'
         | 
| @@ -16,6 +18,10 @@ require 'lionel/trello_authentication' | |
| 16 18 | 
             
            require 'lionel/google_authentication'
         | 
| 17 19 |  | 
| 18 20 | 
             
            module Lionel
         | 
| 21 | 
            +
              Error = Class.new(StandardError)
         | 
| 22 | 
            +
              ColumnNameError = Class.new(Error)
         | 
| 23 | 
            +
              MissingBuilderError = Class.new(Error)
         | 
| 24 | 
            +
             | 
| 19 25 | 
             
              extend self
         | 
| 20 26 | 
             
              attr_accessor :logger
         | 
| 21 27 |  | 
| @@ -25,6 +31,11 @@ module Lionel | |
| 25 31 | 
             
                end
         | 
| 26 32 | 
             
                @logger = logger
         | 
| 27 33 | 
             
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def export(&block)
         | 
| 36 | 
            +
                Export.builder = ExportBuilder.build(&block)
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 28 39 | 
             
            end
         | 
| 29 40 |  | 
| 30 41 | 
             
            Lionel.logger = Logger.new(STDOUT)
         | 
    
        data/lib/lionel/cli.rb
    CHANGED
    
    | @@ -41,9 +41,13 @@ module Lionel | |
| 41 41 | 
             
                method_option "print", :aliases => "-p", :type => :boolean, :default => false, :desc => "Print results instead of saving them to Google Docs."
         | 
| 42 42 | 
             
                method_option "trello-board-id", :aliases => "-t", :type => :string, :default => nil, :desc => "Specify the source Trello board id."
         | 
| 43 43 | 
             
                method_option "google-doc-id", :aliases => "-g", :type => :string, :default => nil, :desc => "Specify the target Google doc id."
         | 
| 44 | 
            -
                method_option "save", :aliases => "- | 
| 44 | 
            +
                method_option "save", :aliases => "-s", :type => :string, :default => true, :desc => "Save the command line ids as the default configuration."
         | 
| 45 45 | 
             
                method_option "filter", :aliases => "-f", :type => :string, :default => 'open-lists', :desc => "Possible values: open-cards, open-lists."
         | 
| 46 | 
            +
                method_option "configuration", :aliases => "-c", :type => :string, :default => nil, :desc => "Path to Lionelfile configuration"
         | 
| 46 47 | 
             
                def export
         | 
| 48 | 
            +
                  lionel_file = options['configuration'] || './Lionelfile'
         | 
| 49 | 
            +
                  eval(File.read(lionel_file)) if File.exists?(lionel_file)
         | 
| 50 | 
            +
             | 
| 47 51 | 
             
                  export = Lionel::Export.new(options)
         | 
| 48 52 |  | 
| 49 53 | 
             
                  if options['google-doc-id']
         | 
| @@ -69,10 +73,10 @@ module Lionel | |
| 69 73 | 
             
                    if @google_attempts < 2
         | 
| 70 74 | 
             
                      retry
         | 
| 71 75 | 
             
                    else
         | 
| 72 | 
            -
                      invoke :authorize, ['google']
         | 
| 76 | 
            +
                      invoke :authorize, ['google'], {}
         | 
| 73 77 | 
             
                    end
         | 
| 74 78 | 
             
                  rescue Trello::Error, Trello::InvalidAccessToken
         | 
| 75 | 
            -
                    invoke :authorize, ['trello']
         | 
| 79 | 
            +
                    invoke :authorize, ['trello'], {}
         | 
| 76 80 | 
             
                  end
         | 
| 77 81 |  | 
| 78 82 | 
             
                  welcome = "Trello? Is it me you're looking for?"
         | 
    
        data/lib/lionel/configuration.rb
    CHANGED
    
    | @@ -4,6 +4,7 @@ require 'ostruct' | |
| 4 4 | 
             
            module Lionel
         | 
| 5 5 | 
             
              class Configuration
         | 
| 6 6 | 
             
                include Singleton
         | 
| 7 | 
            +
                extend Forwardable
         | 
| 7 8 | 
             
                attr_reader :path, :data
         | 
| 8 9 |  | 
| 9 10 | 
             
                FILE_NAME = '.lionelrc'
         | 
| @@ -15,7 +16,7 @@ module Lionel | |
| 15 16 | 
             
                ]
         | 
| 16 17 |  | 
| 17 18 | 
             
                def self.config_accessor(*args)
         | 
| 18 | 
            -
                   | 
| 19 | 
            +
                  def_delegators :data, *args
         | 
| 19 20 |  | 
| 20 21 | 
             
                  args.each do |accessor|
         | 
| 21 22 | 
             
                    define_method("#{accessor}=") do |value|
         | 
    
        data/lib/lionel/export.rb
    CHANGED
    
    | @@ -6,6 +6,14 @@ module Lionel | |
| 6 6 |  | 
| 7 7 | 
             
                config_accessor :google_doc_id, :trello_board_id
         | 
| 8 8 |  | 
| 9 | 
            +
                def self.builder=(builder)
         | 
| 10 | 
            +
                  @builder = builder
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def self.builder
         | 
| 14 | 
            +
                  @builder || ExportBuilder.default
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 9 17 | 
             
                def initialize(options = {})
         | 
| 10 18 | 
             
                  @options = options
         | 
| 11 19 | 
             
                end
         | 
| @@ -48,24 +56,28 @@ module Lionel | |
| 48 56 | 
             
                  download
         | 
| 49 57 |  | 
| 50 58 | 
             
                  if options['print']
         | 
| 51 | 
            -
                     | 
| 59 | 
            +
                    Lionel.logger.info "DRY RUN..."
         | 
| 60 | 
            +
                    Lionel.logger.info "Results were not uploaded to Google Drive"
         | 
| 52 61 | 
             
                  else
         | 
| 62 | 
            +
                    Lionel.logger.info "Uploading..."
         | 
| 53 63 | 
             
                    upload
         | 
| 64 | 
            +
                    Lionel.logger.info "Done!"
         | 
| 54 65 | 
             
                  end
         | 
| 55 66 | 
             
                end
         | 
| 56 67 |  | 
| 57 68 | 
             
                def download
         | 
| 69 | 
            +
                  raise_missing_builder_error unless builder
         | 
| 70 | 
            +
             | 
| 58 71 | 
             
                  Lionel.logger.info "Exporting trello board '#{board.name}' (#{trello_board_id}) to " + "google doc '#{spreadsheet.title}' (#{google_doc_id})"
         | 
| 59 72 |  | 
| 60 73 | 
             
                  card_map.each do |row, card|
         | 
| 61 74 | 
             
                    begin
         | 
| 62 | 
            -
                      Timeout.timeout(5)  | 
| 63 | 
            -
                         | 
| 64 | 
            -
             | 
| 65 | 
            -
                        sync_columns(card).each do |col, value|
         | 
| 75 | 
            +
                      Timeout.timeout(5) do
         | 
| 76 | 
            +
                        row_data = card_columns(card).map do |col, value|
         | 
| 66 77 | 
             
                          worksheet[col,row] = value
         | 
| 67 | 
            -
                        end
         | 
| 68 | 
            -
             | 
| 78 | 
            +
                        end.join(" | ")
         | 
| 79 | 
            +
                        Lionel.logger.info "row[#{row}]: " + row_data
         | 
| 80 | 
            +
                      end
         | 
| 69 81 | 
             
                    rescue Timeout::Error, Trello::Error => e
         | 
| 70 82 | 
             
                      Lionel.logger.warn e.inspect
         | 
| 71 83 | 
             
                      Lionel.logger.warn card.inspect
         | 
| @@ -85,48 +97,22 @@ module Lionel | |
| 85 97 | 
             
                  worksheet.rows
         | 
| 86 98 | 
             
                end
         | 
| 87 99 |  | 
| 88 | 
            -
                def  | 
| 89 | 
            -
                   | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
                    # Card link
         | 
| 93 | 
            -
                    columns["C"] = card.link(card.name.gsub(/^\[.*\]\s*/, ""))
         | 
| 100 | 
            +
                def builder
         | 
| 101 | 
            +
                  self.class.builder
         | 
| 102 | 
            +
                end
         | 
| 94 103 |  | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 104 | 
            +
                def card_columns(card)
         | 
| 105 | 
            +
                  card_column_rows[card.id] ||= {}.tap do |columns|
         | 
| 106 | 
            +
                    builder.columns.each do |col_name, block|
         | 
| 107 | 
            +
                      columns[col_name] = card.instance_exec(self, &block)
         | 
| 98 108 | 
             
                    end
         | 
| 99 | 
            -
                    columns["D"] = card.format_date(ready_action.date) if ready_action
         | 
| 100 | 
            -
             | 
| 101 | 
            -
                    # In Progress date
         | 
| 102 | 
            -
                    columns["E"] = card.date_moved_to("In Progress")
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                    # Code Review date
         | 
| 105 | 
            -
                    columns["F"] = card.date_moved_to("Code Review")
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                    # Review date
         | 
| 108 | 
            -
                    columns["G"] = card.date_moved_to("Review")
         | 
| 109 | 
            -
             | 
| 110 | 
            -
                    # Deploy date
         | 
| 111 | 
            -
                    columns["H"] = card.date_moved_to("Deploy")
         | 
| 112 | 
            -
             | 
| 113 | 
            -
                    # Completed date
         | 
| 114 | 
            -
                    columns["I"] = card.date_moved_to("Completed")
         | 
| 115 | 
            -
             | 
| 116 | 
            -
                    # Type
         | 
| 117 | 
            -
                    columns["J"] = card.type
         | 
| 118 | 
            -
             | 
| 119 | 
            -
                    # Project
         | 
| 120 | 
            -
                    columns["K"] = card.project
         | 
| 121 | 
            -
             | 
| 122 | 
            -
                    # Estimate
         | 
| 123 | 
            -
                    columns["L"] = card.estimate
         | 
| 124 | 
            -
             | 
| 125 | 
            -
                    # Due Date
         | 
| 126 | 
            -
                    columns["M"] = card.due_date
         | 
| 127 109 | 
             
                  end
         | 
| 128 110 | 
             
                end
         | 
| 129 111 |  | 
| 112 | 
            +
                def card_column_rows
         | 
| 113 | 
            +
                  @card_column_rows ||= {}
         | 
| 114 | 
            +
                end
         | 
| 115 | 
            +
             | 
| 130 116 | 
             
                def authenticate
         | 
| 131 117 | 
             
                  return if @authenticated
         | 
| 132 118 | 
             
                  authenticate_trello
         | 
| @@ -166,6 +152,19 @@ module Lionel | |
| 166 152 | 
             
                  end
         | 
| 167 153 | 
             
                end
         | 
| 168 154 |  | 
| 155 | 
            +
                def raise_missing_builder_error
         | 
| 156 | 
            +
                  message = <<-ERROR.gsub(/^ {6}/, '')
         | 
| 157 | 
            +
                    The export is not configured. Example:
         | 
| 158 | 
            +
             | 
| 159 | 
            +
                    Lionel.export do
         | 
| 160 | 
            +
                      A { id }
         | 
| 161 | 
            +
                      B { name }
         | 
| 162 | 
            +
                      C { url }
         | 
| 163 | 
            +
                    end
         | 
| 164 | 
            +
                  ERROR
         | 
| 165 | 
            +
                  raise MissingBuilderError.new(message)
         | 
| 166 | 
            +
                end
         | 
| 167 | 
            +
             | 
| 169 168 | 
             
                class CardMap
         | 
| 170 169 | 
             
                  include Enumerable
         | 
| 171 170 |  | 
| @@ -186,10 +185,9 @@ module Lionel | |
| 186 185 | 
             
                  private
         | 
| 187 186 |  | 
| 188 187 | 
             
                  def populate_rows
         | 
| 189 | 
            -
                    Lionel.logger.info "Using CardMap!!!!"
         | 
| 190 188 | 
             
                    {}.tap do |card_rows|
         | 
| 191 189 |  | 
| 192 | 
            -
                      start_row = 2
         | 
| 190 | 
            +
                      start_row = 2 # Currently assumes a header column
         | 
| 193 191 | 
             
                      rows = worksheet.size
         | 
| 194 192 |  | 
| 195 193 | 
             
                      # Find existing rows for current cards
         | 
| @@ -210,5 +208,6 @@ module Lionel | |
| 210 208 | 
             
                    end
         | 
| 211 209 | 
             
                  end
         | 
| 212 210 | 
             
                end
         | 
| 211 | 
            +
             | 
| 213 212 | 
             
              end
         | 
| 214 213 | 
             
            end
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            module Lionel
         | 
| 2 | 
            +
              class ExportBuilder
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                def self.build(&block)
         | 
| 5 | 
            +
                  new.configure(&block)
         | 
| 6 | 
            +
                end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                def self.default
         | 
| 9 | 
            +
                  build do
         | 
| 10 | 
            +
                    A { id }
         | 
| 11 | 
            +
                    B { name }
         | 
| 12 | 
            +
                    C { url }
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def configure(&block)
         | 
| 17 | 
            +
                  instance_eval(&block)
         | 
| 18 | 
            +
                  self
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def columns
         | 
| 22 | 
            +
                  @columns ||= {}
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                def method_missing(sym, *args, &block)
         | 
| 26 | 
            +
                  column_name = sym.to_s.upcase
         | 
| 27 | 
            +
                  if column_name =~ /\A[A-Z]+\z/
         | 
| 28 | 
            +
                    columns[sym.to_s.upcase] = block_given? ? block : lambda { args.first }
         | 
| 29 | 
            +
                  else
         | 
| 30 | 
            +
                    raise ColumnNameError.new("Method '#{sym}' does not represent a valid Google Spreadsheet column name")
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
| @@ -25,7 +25,7 @@ module Lionel | |
| 25 25 | 
             
                  return false unless refresh_token
         | 
| 26 26 |  | 
| 27 27 | 
             
                  current_token = OAuth2::AccessToken.from_hash(client,
         | 
| 28 | 
            -
                      {:refresh_token => refresh_token, :expires_at =>  | 
| 28 | 
            +
                      {:refresh_token => refresh_token, :expires_at => 604800}) # 1 week
         | 
| 29 29 | 
             
                  @access_token = current_token.refresh! # returns new access_token
         | 
| 30 30 | 
             
                end
         | 
| 31 31 |  | 
    
        data/lib/lionel/proxy_action.rb
    CHANGED
    
    
    
        data/lib/lionel/proxy_card.rb
    CHANGED
    
    | @@ -1,7 +1,10 @@ | |
| 1 1 | 
             
            module Lionel
         | 
| 2 2 | 
             
              class ProxyCard
         | 
| 3 | 
            +
                extend Forwardable
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
                attr_reader :card
         | 
| 4 | 
            -
             | 
| 6 | 
            +
             | 
| 7 | 
            +
                def_delegators :card, :id, :url, :name, :due
         | 
| 5 8 |  | 
| 6 9 | 
             
                def initialize(card)
         | 
| 7 10 | 
             
                  @card = card
         | 
| @@ -51,7 +54,7 @@ module Lionel | |
| 51 54 | 
             
                end
         | 
| 52 55 |  | 
| 53 56 | 
             
                def estimate
         | 
| 54 | 
            -
                  match = card.name.match(/\[(?<estimate>\w)\]/)
         | 
| 57 | 
            +
                  match = card.name.match(/\[(?<estimate>\w+)\]/)
         | 
| 55 58 | 
             
                  return "" unless match
         | 
| 56 59 | 
             
                  match[:estimate]
         | 
| 57 60 | 
             
                end
         | 
    
        data/lib/lionel/version.rb
    CHANGED
    
    
    
        data/lionel_richie.gemspec
    CHANGED
    
    | @@ -25,6 +25,7 @@ Gem::Specification.new do |spec| | |
| 25 25 | 
             
              spec.add_dependency "google_drive"
         | 
| 26 26 | 
             
              spec.add_dependency "yajl-ruby"
         | 
| 27 27 | 
             
              spec.add_dependency "thor"
         | 
| 28 | 
            +
              spec.add_dependency "faraday", "~> 0.8"
         | 
| 28 29 | 
             
              spec.add_dependency "launchy"
         | 
| 29 30 |  | 
| 30 31 | 
             
              spec.add_development_dependency "bundler", "~> 1.3"
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Lionel::ExportBuilder do
         | 
| 4 | 
            +
              let(:builder) { described_class.new }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              describe "configure" do
         | 
| 7 | 
            +
                it "accepts block for column" do
         | 
| 8 | 
            +
                  builder.configure do
         | 
| 9 | 
            +
                    A { "123" }
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  builder.columns["A"].call.should eq("123")
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                it "accepts hard-coded value" do
         | 
| 16 | 
            +
                  builder.configure do
         | 
| 17 | 
            +
                    A "123"
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  builder.columns["A"].call.should eq("123")
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                it "raises error if not a column name (only letters)" do
         | 
| 24 | 
            +
                  expect { builder.configure { x123 "123" } }.to raise_error(Lionel::ColumnNameError)
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Lionel do
         | 
| 4 | 
            +
              TestCard = Struct.new(:id, :name, :url)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              describe "self.export" do
         | 
| 7 | 
            +
                it "configures the export builder" do
         | 
| 8 | 
            +
                  card = TestCard.new(123, "Testing cards", "http://example.com")
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  Lionel.export do
         | 
| 11 | 
            +
                    A { id }
         | 
| 12 | 
            +
                    B { name }
         | 
| 13 | 
            +
                    C { url }
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  builder = Lionel::Export.builder
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  card.instance_eval(&builder.columns["A"]).should eq(123)
         | 
| 19 | 
            +
                  card.instance_eval(&builder.columns["B"]).should eq("Testing cards")
         | 
| 20 | 
            +
                  card.instance_eval(&builder.columns["C"]).should eq("http://example.com")
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: lionel_richie
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ross Kaffenberger
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2014-01-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: ruby-trello
         | 
| @@ -66,6 +66,20 @@ dependencies: | |
| 66 66 | 
             
                - - ! '>='
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 68 | 
             
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: faraday
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ~>
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0.8'
         | 
| 76 | 
            +
              type: :runtime
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ~>
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0.8'
         | 
| 69 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 84 | 
             
              name: launchy
         | 
| 71 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -132,17 +146,20 @@ extra_rdoc_files: [] | |
| 132 146 | 
             
            files:
         | 
| 133 147 | 
             
            - .gitignore
         | 
| 134 148 | 
             
            - .rspec
         | 
| 149 | 
            +
            - CHANGELOG.md
         | 
| 135 150 | 
             
            - Gemfile
         | 
| 136 151 | 
             
            - Guardfile
         | 
| 137 152 | 
             
            - LICENSE.txt
         | 
| 138 153 | 
             
            - README.md
         | 
| 139 154 | 
             
            - Rakefile
         | 
| 140 155 | 
             
            - bin/lionel
         | 
| 156 | 
            +
            - examples/Lionelfile.kanban.rb
         | 
| 141 157 | 
             
            - lib/lionel.rb
         | 
| 142 158 | 
             
            - lib/lionel/cli.rb
         | 
| 143 159 | 
             
            - lib/lionel/configurable.rb
         | 
| 144 160 | 
             
            - lib/lionel/configuration.rb
         | 
| 145 161 | 
             
            - lib/lionel/export.rb
         | 
| 162 | 
            +
            - lib/lionel/export_builder.rb
         | 
| 146 163 | 
             
            - lib/lionel/google_authentication.rb
         | 
| 147 164 | 
             
            - lib/lionel/proxy_action.rb
         | 
| 148 165 | 
             
            - lib/lionel/proxy_card.rb
         | 
| @@ -152,9 +169,11 @@ files: | |
| 152 169 | 
             
            - lib/lionel_richie.rb
         | 
| 153 170 | 
             
            - lionel_richie.gemspec
         | 
| 154 171 | 
             
            - script/console
         | 
| 172 | 
            +
            - spec/lib/lionel/export_builder_spec.rb
         | 
| 155 173 | 
             
            - spec/lib/lionel/export_spec.rb
         | 
| 156 174 | 
             
            - spec/lib/lionel/google_authentication_spec.rb
         | 
| 157 175 | 
             
            - spec/lib/lionel/trello_authentication_spec.rb
         | 
| 176 | 
            +
            - spec/lib/lionel_spec.rb
         | 
| 158 177 | 
             
            - spec/spec_helper.rb
         | 
| 159 178 | 
             
            homepage: ''
         | 
| 160 179 | 
             
            licenses:
         | 
| @@ -176,12 +195,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 176 195 | 
             
                  version: '0'
         | 
| 177 196 | 
             
            requirements: []
         | 
| 178 197 | 
             
            rubyforge_project: 
         | 
| 179 | 
            -
            rubygems_version: 2. | 
| 198 | 
            +
            rubygems_version: 2.1.11
         | 
| 180 199 | 
             
            signing_key: 
         | 
| 181 200 | 
             
            specification_version: 4
         | 
| 182 201 | 
             
            summary: Export Trello to Google Docs
         | 
| 183 202 | 
             
            test_files:
         | 
| 203 | 
            +
            - spec/lib/lionel/export_builder_spec.rb
         | 
| 184 204 | 
             
            - spec/lib/lionel/export_spec.rb
         | 
| 185 205 | 
             
            - spec/lib/lionel/google_authentication_spec.rb
         | 
| 186 206 | 
             
            - spec/lib/lionel/trello_authentication_spec.rb
         | 
| 207 | 
            +
            - spec/lib/lionel_spec.rb
         | 
| 187 208 | 
             
            - spec/spec_helper.rb
         |