lib/embulk/input/jira.rb in embulk-input-jira-0.0.5 vs lib/embulk/input/jira.rb in embulk-input-jira-0.0.6

- old
+ new

@@ -10,25 +10,25 @@ Plugin.register_input("jira", self) def self.transaction(config, &control) task = { - "username" => config.param("username", :string), - "password" => config.param("password", :string), - "uri" => config.param("uri", :string), - "jql" => config.param("jql", :string), + username: config.param(:username, :string), + password: config.param(:password, :string), + uri: config.param(:uri, :string), + jql: config.param(:jql, :string), } attributes = {} - columns = config.param("columns", :array).map do |column| + columns = config.param(:columns, :array).map do |column| name = column["name"] type = column["type"].to_sym attributes[name] = type Column.new(nil, name, type, column["format"]) end - task["attributes"] = attributes + task[:attributes] = attributes resume(task, columns, 1, &control) end def self.resume(task, columns, count, &control) @@ -37,26 +37,24 @@ next_config_diff = {} return next_config_diff end def self.guess(config) - # TODO: api_version should be 2 (the latest version) - # auth_type should be specified from config. (The future task) + username = config.param(:username, :string) + password = config.param(:password, :string) + uri = config.param(:uri, :string) + jql = config.param(:jql, :string) - username = config.param("username", :string) - password = config.param("password", :string) - uri = config.param("uri", :string) - api_version = "latest" - auth_type = "basic" - jql = config.param("jql", :string) - jira = JiraApi::Client.setup do |jira_config| + # TODO: api_version should be 2 (the latest version) + # auth_type should be specified from config. (The future task) + jira_config.username = username jira_config.password = password jira_config.uri = uri - jira_config.api_version = api_version - jira_config.auth_type = auth_type + jira_config.api_version = "latest" + jira_config.auth_type = "basic" end # TODO: we use 0..10 issues to guess config? records = jira.search_issues(jql, max_results: GUESS_RECORDS_COUNT).map do |issue| issue.to_record @@ -70,18 +68,18 @@ return guessed_config end def init - @attributes = task["attributes"] + @attributes = task[:attributes] @jira = JiraApi::Client.setup do |config| - config.username = task["username"] - config.password = task["password"] - config.uri = task["uri"] + config.username = task[:username] + config.password = task[:password] + config.uri = task[:uri] config.api_version = "latest" - config.auth_type = :basic + config.auth_type = "basic" end - @jql = task["jql"] + @jql = task[:jql] end def run return preview if preview? options = {}