qiita_nekosogi_stocker 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e94924df9397dcaf284541650af30356c41cdbf0
4
+ data.tar.gz: e4bfc63f7046c4e3457a2eb0eb9f65bab0a513d2
5
+ SHA512:
6
+ metadata.gz: 81e71b16d5638dcb8cccb75f368ce210aba8d9a35e15c7def8f81b7f2264ae04ddd292333af274ba3a81a7921fb82f7890a81436a7e6034f018a32864cc9ab5c
7
+ data.tar.gz: 6e0dfd23f13ac6fdeb3d9467bfcdcfc7f458b35f95dab2db1ea14bb2930c540bd8e50b703f3d958f4a14bb856857a4b733bdc00adf1884832f1f21526e68ae1d
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .env
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in qiita_nekosogi_stocker.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 tbpgr
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Qiita::NekosogiStocker
2
+
3
+ Qiita::NekosogiStocker stocks specific user's all articles.
4
+
5
+ ## :thought_balloon: Image
6
+ ### Before
7
+ You
8
+ :man::grey_question::grey_question::page_with_curl::older_man:(:star2: author)
9
+ :grey_question::grey_question::grey_question::page_with_curl:
10
+ :grey_question::grey_question::grey_question::page_with_curl:
11
+ :grey_question::thumbsup::paperclip::page_with_curl:
12
+ :grey_question::thumbsup::paperclip::page_with_curl:
13
+ :grey_question::grey_question::grey_question::page_with_curl:
14
+
15
+ ### After
16
+
17
+ You
18
+ :notes:
19
+ :man::thumbsup::paperclip::page_with_curl::older_man:(:star2: author)
20
+ :grey_question::thumbsup::paperclip::page_with_curl:
21
+ :grey_question::thumbsup::paperclip::page_with_curl:
22
+ :grey_question::thumbsup::paperclip::page_with_curl:
23
+ :grey_question::thumbsup::paperclip::page_with_curl:
24
+ :grey_question::thumbsup::paperclip::page_with_curl:
25
+
26
+ ## :cloud::arrow_down: Installation
27
+
28
+ Add this line to your application's Gemfile:
29
+
30
+ ```ruby
31
+ gem 'qiita_nekosogi_stocker'
32
+ ```
33
+
34
+ And then execute:
35
+
36
+ $ bundle
37
+
38
+ Or install it yourself as:
39
+
40
+ $ gem install qiita_nekosogi_stocker
41
+
42
+ ## :computer: Commands
43
+ command name `nekosoqiita`
44
+
45
+ |sub command|args|memo|
46
+ |:--|:--|:--|
47
+ |help|--|show help|
48
+ |help|sub command name|show specific sub-command help|
49
+ |version|--|show version|
50
+ |stock|qiita_user_id|Stock all articles that created by user(qiita_user_id). Output format is ltsv.|
51
+
52
+ ## :scroll: Usage
53
+
54
+ ~~~bash
55
+ # 伊藤直也 さんの記事を根こそぎストックしてみます
56
+ $ nekosoqiita stock naoya@github
57
+ title: Yak shaving in Yosemite url: http://qiita.com/naoya@github/items/8793fe9227f2b144b1ff
58
+ title: Go の変数初期化に伴う条件分岐をもっと良い感じに書きたいと思ったが諦めるしかないようです url: http://qiita.com/naoya@github/items/fbfb853a910a8b3ae0fd
59
+ title: Chef で aws の t1.micro に swap を作るレシピ url: http://qiita.com/naoya@github/items/2059e3755962e907315e
60
+ title: iTerm2 で emacs で C-tab で other-window url: http://qiita.com/naoya@github/items/bfb250aa76107a036127
61
+ ~~~
62
+
63
+ ## :deciduous_tree: Env
64
+
65
+ |key|value|
66
+ |:--|:--|
67
+ |access_token|Qiita access token|
68
+
69
+ ### .env
70
+ ~~~
71
+ access_token=set_your_qiita_token
72
+ ~~~
73
+
74
+ ## :couple: Dependency
75
+
76
+ |key|value|
77
+ |:--|:--|
78
+ |qiita|qiita gem|
79
+
80
+ ## :two_women_holding_hands: Contributing :two_men_holding_hands:
81
+
82
+ 1. Fork it ( https://github.com/tbpgr/qiita_nekosogi_stocker/fork )
83
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
84
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
85
+ 4. Push to the branch (`git push origin my-new-feature`)
86
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/nekosoqiita ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'qiita_nekosogi_stocker/cli'
4
+ Qiita::NekosogiStocker::CLI.start
@@ -0,0 +1,9 @@
1
+ require "qiita_nekosogi_stocker/version"
2
+ require "qiita_nekosogi_stocker/cli"
3
+ require "qiita_nekosogi_stocker/qiita_nekosogi_stocker"
4
+
5
+ module Qiita
6
+ module NekosogiStocker
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ require 'qiita_nekosogi_stocker'
2
+ require 'thor'
3
+
4
+ module Qiita
5
+ module NekosogiStocker
6
+ class CLI < Thor
7
+ class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
8
+ class_option :version, type: :boolean, desc: 'version'
9
+ class_option :debug, type: :boolean, aliases: '-d', desc: 'debug mode'
10
+
11
+ desc 'stock [user_id]', "Stock specific user's all articles"
12
+ def stock(user_id)
13
+ setting_debug_mode
14
+ stock_ltsvs = Qiita::NekosogiStocker.stock(user_id)
15
+ puts stock_ltsvs
16
+ rescue => e
17
+ output_error_if_debug_mode(e)
18
+ exit(false)
19
+ end
20
+
21
+ desc 'version', 'version'
22
+ def version
23
+ p Qiita::NekosogiStocker::VERSION
24
+ end
25
+
26
+ private
27
+
28
+ def setting_debug_mode
29
+ $DEBUG = options[:debug]
30
+ end
31
+
32
+ def output_error_if_debug_mode(e)
33
+ return unless options[:debug]
34
+ STDERR.puts(e.backtrace)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,44 @@
1
+ require 'qiita'
2
+ require 'dotenv'
3
+
4
+ module Qiita
5
+ module NekosogiStocker
6
+ PAGE_UNIT = 100
7
+ class << self
8
+ def stock(user_id, debug_not_stock = false)
9
+ Dotenv.load
10
+ client = Qiita::Client.new(access_token: ENV['access_token'])
11
+ page = 1
12
+ ltsvs = []
13
+ loop {
14
+ response = client.list_user_items(user_id, per_page: PAGE_UNIT, page: page)
15
+ response.body.each do |item|
16
+ next if stock?(client, item['id'])
17
+ client.stock_item(item['id']) unless debug_not_stock
18
+ ltsvs = append_ltsvs(ltsvs, item)
19
+ end
20
+ page += 1
21
+ break unless response.next_page_url
22
+ }
23
+ return '' if ltsvs.size == 0
24
+ ltsvs.map { |e|"title: #{e[:title]} url: #{e[:url]}" }.join("\n")
25
+ end
26
+
27
+ private
28
+
29
+ def stock?(client, item_id)
30
+ response = client.get_item_stock(item_id)
31
+ response.status == 204
32
+ end
33
+
34
+ def append_ltsvs(ltsvs, item)
35
+ ltsv = {}
36
+ ltsv[:id] = item['id']
37
+ ltsv[:title] = item['title']
38
+ ltsv[:url] = item['url']
39
+ ltsvs << ltsv
40
+ ltsvs
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,5 @@
1
+ module Qiita
2
+ module NekosogiStocker
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qiita_nekosogi_stocker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "qiita_nekosogi_stocker"
8
+ spec.version = Qiita::NekosogiStocker::VERSION
9
+ spec.authors = ["tbpgr"]
10
+ spec.email = ["tbpgr@tbpgr.jp"]
11
+ spec.summary = %q{Qiita::NekosogiStocker stocks specific user's all articles..}
12
+ spec.description = %q{Qiita::NekosogiStocker stocks specific user's all articles..}
13
+ spec.homepage = "https://github.com/tbpgr/qiita_nekosogi_stocker"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "qiita"
22
+ spec.add_runtime_dependency "dotenv"
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qiita_nekosogi_stocker
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - tbpgr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: qiita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Qiita::NekosogiStocker stocks specific user's all articles..
70
+ email:
71
+ - tbpgr@tbpgr.jp
72
+ executables:
73
+ - nekosoqiita
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - .rspec
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/nekosoqiita
84
+ - lib/qiita_nekosogi_stocker.rb
85
+ - lib/qiita_nekosogi_stocker/cli.rb
86
+ - lib/qiita_nekosogi_stocker/qiita_nekosogi_stocker.rb
87
+ - lib/qiita_nekosogi_stocker/version.rb
88
+ - qiita_nekosogi_stocker.gemspec
89
+ homepage: https://github.com/tbpgr/qiita_nekosogi_stocker
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.3.0
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Qiita::NekosogiStocker stocks specific user's all articles..
113
+ test_files: []