Class: QiitaMatome::QiitaJsonLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/qiita_json_loader.rb

Overview

QiitaMatome::QiitaJsonLoader

Constant Summary collapse

QIITA_URL =
'https://qiita.com/api/v1/users/%s/items?page=%s&per_page=%s'
PER_PAGE =
25
PAGE_LIMIT =
100

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeQiitaJsonLoader

Returns a new instance of QiitaJsonLoader.



15
16
17
# File 'lib/qiita_json_loader.rb', line 15

def initialize
  @articles = Articles.new
end

Instance Attribute Details

#articlesObject (readonly)

Returns the value of attribute articles.



10
11
12
# File 'lib/qiita_json_loader.rb', line 10

def articles
  @articles
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'lib/qiita_json_loader.rb', line 10

def user
  @user
end

Instance Method Details

#load(user) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/qiita_json_loader.rb', line 19

def load(user)
  @user = user
  tmp_verbose = $VERBOSE
  $VERBOSE = nil
  OpenSSL::SSL.const_set('VERIFY_PEER', OpenSSL::SSL::VERIFY_NONE)
  $VERBOSE = tmp_verbose
  (1..PAGE_LIMIT).each do |page|
    before_size = @articles.size
    load_page(user, page)
    break if before_size == @articles.size
  end
end