twsh 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e127e033d14eb425e9e2267f5869ed50d177b33
4
- data.tar.gz: 12d7627fd8af3490e8a8f438528f15c4abbc824e
3
+ metadata.gz: 0a29ededbff4ada059bea417998a60d5a988ca68
4
+ data.tar.gz: 7df414d3c68181d690b3ed223c29b28c90e94976
5
5
  SHA512:
6
- metadata.gz: 4a7a0c41448262a7929f025b038511811e86d1e168a0af0cc5f8c883ac4ea875f8e687c2c4a9444b6cad787b6758a77e7a87df13893207c8d863c15a2c8b574c
7
- data.tar.gz: 715a284939f4e550dd0cb50685328ccb7a2f5a7fc97fcf1d0ee2f9351d68c44bf4801e54a7b9939844877b4130d4780b4d806798c4b2b9ff90be11de821f37e0
6
+ metadata.gz: 1757b0181af79d5cb4af1dc0bea19b07a1529d3cd8d85677b6a2c0533abfddb7cb54a0a5bebb83e8855aec7bf9b7e16aecf812769d9c4649fa05cbffe2afd543
7
+ data.tar.gz: 0a9c524d99e7f3611554360c56abae23fa82e2f0b6580b9483d4e4eb47fc99508ff9887875b0990362f3b0273ef0828113e774741ffdc317e48a39c0059e3a03
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in twsh.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in twsh.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 myun2
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 CHANGED
@@ -1,3 +1,15 @@
1
- # Twitter-sh
2
-
3
- Twitter command line shell.
1
+ # Twsh
2
+
3
+ Twitter command line shell.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ gem install twsh
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ $ twsh
15
+ ```
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'twsh'
4
+ Twsh.new
@@ -1,24 +1,24 @@
1
- require 'twitter_oauth'
2
-
3
- module Myun2
4
- class Twitter
5
- class Authenticate
6
- attr_reader :client, :authorize_url, :access_token
7
-
8
- def initialize(params)
9
- @client = TwitterOAuth::Client.new(params)
10
- end
11
-
12
- def request_authorize_url
13
- @token = client.authentication_request_token(oauth_callback: 'oob')
14
- @authorize_url = @token.authorize_url
15
- end
16
-
17
- def authorize(pin_code)
18
- @access_token = client.authorize(
19
- @token.token, @token.secret, oauth_verifier: pin_code)
20
- end
21
- end
22
- end
23
- end
24
-
1
+ require 'twitter_oauth'
2
+
3
+ module Myun2
4
+ class Twitter
5
+ class Authenticate
6
+ attr_reader :client, :authorize_url, :access_token
7
+
8
+ def initialize(params)
9
+ @client = TwitterOAuth::Client.new(params)
10
+ end
11
+
12
+ def request_authorize_url
13
+ @token = client.authentication_request_token(oauth_callback: 'oob')
14
+ @authorize_url = @token.authorize_url
15
+ end
16
+
17
+ def authorize(pin_code)
18
+ @access_token = client.authorize(
19
+ @token.token, @token.secret, oauth_verifier: pin_code)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -1,2 +1,2 @@
1
- require 'myun2/twitter_shell/version'
2
- require 'myun2/twitter_shell/shell'
1
+ require 'myun2/twitter_shell/version'
2
+ require 'myun2/twitter_shell/shell'
@@ -1,33 +1,35 @@
1
- require 'myun2/twitter/authenticate'
2
-
3
- module Myun2
4
- class TwitterShell
5
- class Authorize
6
- attr_reader :pin, :access_token
7
-
8
- def initialize
9
- puts "* Requesting Authorize URL ..."
10
- auth_url = request_authorize_url
11
- puts " Please access and please input PIN code."
12
- puts auth_url
13
- print "PIN> "
14
- read_pin && authorize
15
- end
16
-
17
- def request_authorize_url
18
- @auth = Myun2::Twitter::Authenticate.new(
19
- consumer_key: TWITTER_CONSUMER_KEY,
20
- consumer_secret: TWITTER_CONSUMER_SECRET)
21
- @auth.request_authorize_url
22
- end
23
-
24
- def read_pin
25
- @pin = gets.chomp
26
- end
27
-
28
- def authorize
29
- @access_token = @auth.authorize(@pin)
30
- end
31
- end
32
- end
33
- end
1
+ require 'myun2/twitter/authenticate'
2
+
3
+ module Myun2
4
+ class TwitterShell
5
+ class Authorize
6
+ attr_reader :pin, :access_token
7
+
8
+ def initialize
9
+ puts "* Requesting authorization URL ..."
10
+ auth_url = request_authorize_url
11
+ puts " " + auth_url
12
+ puts "* Please access to above URL in your browser."
13
+ puts " And permit application 'Myun2 Twitter Shell (Twsh)."
14
+ puts " And enter shown PIN code to under."
15
+ print "PIN> "
16
+ read_pin && authorize
17
+ end
18
+
19
+ def request_authorize_url
20
+ @auth = Myun2::Twitter::Authenticate.new(
21
+ consumer_key: TWITTER_CONSUMER_KEY,
22
+ consumer_secret: TWITTER_CONSUMER_SECRET)
23
+ @auth.request_authorize_url
24
+ end
25
+
26
+ def read_pin
27
+ @pin = gets.chomp
28
+ end
29
+
30
+ def authorize
31
+ @access_token = @auth.authorize(@pin)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,17 +1,17 @@
1
- require 'twitter_oauth'
2
- require 'myun2/twitter_shell/consumer_key'
3
-
4
- module Myun2
5
- class TwitterShell
6
- class Client < TwitterOAuth::Client
7
- def initialize(params)
8
- super(
9
- consumer_key: Myun2::TwitterShell::TWITTER_CONSUMER_KEY,
10
- consumer_secret: Myun2::TwitterShell::TWITTER_CONSUMER_SECRET,
11
- token: params[:access_token],
12
- secret: params[:access_token_secret],
13
- )
14
- end
15
- end
16
- end
17
- end
1
+ require 'twitter_oauth'
2
+ require 'myun2/twitter_shell/consumer_key'
3
+
4
+ module Myun2
5
+ class TwitterShell
6
+ class Client < TwitterOAuth::Client
7
+ def initialize(params)
8
+ super(
9
+ consumer_key: Myun2::TwitterShell::TWITTER_CONSUMER_KEY,
10
+ consumer_secret: Myun2::TwitterShell::TWITTER_CONSUMER_SECRET,
11
+ token: params[:access_token],
12
+ secret: params[:access_token_secret],
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,6 +1,6 @@
1
- module Myun2
2
- class TwitterShell
3
- TWITTER_CONSUMER_KEY = 'UcYO0YhTahKinn2wtYjNK564f'
4
- TWITTER_CONSUMER_SECRET = 'GOXY9ViHxqsTBqiZAL9Sp8wbJbRIoEB4ciclB80gi2nQ1qAvGn'
5
- end
6
- end
1
+ module Myun2
2
+ class TwitterShell
3
+ TWITTER_CONSUMER_KEY = 'UcYO0YhTahKinn2wtYjNK564f'
4
+ TWITTER_CONSUMER_SECRET = 'GOXY9ViHxqsTBqiZAL9Sp8wbJbRIoEB4ciclB80gi2nQ1qAvGn'
5
+ end
6
+ end
@@ -1,21 +1,21 @@
1
- require 'myun2/twitter_shell/authorize'
2
-
3
- module Myun2
4
- class TwitterShell
5
- class Login
6
- def initialize(*params)
7
- new_login
8
- end
9
-
10
- private
11
- def new_login
12
- access_token = Authorize.new.access_token
13
- profile = Profile.new(
14
- access_token: access_token.token,
15
- access_token_secret: access_token.secret,
16
- )
17
- profile.save
18
- end
19
- end
20
- end
21
- end
1
+ require 'myun2/twitter_shell/authorize'
2
+
3
+ module Myun2
4
+ class TwitterShell
5
+ class Login
6
+ def initialize(*params)
7
+ new_login
8
+ end
9
+
10
+ private
11
+ def new_login
12
+ access_token = Authorize.new.access_token
13
+ profile = Profile.new(
14
+ access_token: access_token.token,
15
+ access_token_secret: access_token.secret,
16
+ )
17
+ profile.save
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,27 +1,27 @@
1
- require 'twitter'
2
-
3
- module Myun2
4
- class TwitterShell
5
- class Ls
6
- attr_reader :client
7
-
8
- def initialize(client, *params)
9
- @client = client
10
- format(home_timeline).each do |tweet| puts tweet end
11
- end
12
-
13
- def home_timeline
14
- client.home_timeline
15
- end
16
-
17
- def format(timeline)
18
- timeline.map do |t|
19
- u = t["user"]
20
- user_name = u["name"]
21
- text = t["text"]
22
- "<#{user_name}>: #{text[0..30]}"
23
- end
24
- end
25
- end
26
- end
27
- end
1
+ require 'twitter'
2
+
3
+ module Myun2
4
+ class TwitterShell
5
+ class Ls
6
+ attr_reader :client
7
+
8
+ def initialize(client, *params)
9
+ @client = client
10
+ format(home_timeline).each do |tweet| puts tweet end
11
+ end
12
+
13
+ def home_timeline
14
+ client.home_timeline
15
+ end
16
+
17
+ def format(timeline)
18
+ timeline.map do |t|
19
+ u = t["user"]
20
+ user_name = u["name"]
21
+ text = t["text"]
22
+ "<#{user_name}>: #{text[0..30]}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,50 +1,50 @@
1
- module Myun2
2
- class TwitterShell
3
- class Profile
4
- attr_reader :data
5
-
6
- class Loader
7
- def self.load(path)
8
- return unless File.exist?(path)
9
- r = {}
10
- open(path).each do |line|
11
- key, value = line.chomp.split "="
12
- r[key.to_sym] = value
13
- end
14
- r
15
- end
16
- end
17
-
18
- def initialize(params = {})
19
- @data = params
20
- end
21
-
22
- def save
23
- Dir.mkdir profile_root_dir unless File.exist?(profile_root_dir)
24
-
25
- open(profile_path, "w") do |f|
26
- @data.each do |key,value|
27
- f.puts key.to_s + "=" + value.to_s
28
- end
29
- end
30
- end
31
-
32
- def self.load(path = nil)
33
- return unless data = Loader.load(path || default_profile_path)
34
- new(data)
35
- end
36
-
37
- def self.profile_root_dir
38
- File.expand_path('~/.twsh')
39
- end
40
-
41
- def self.default_profile_path
42
- File.join(profile_root_dir, 'profile')
43
- end
44
-
45
- def profile_path
46
- @profile_path ||= Profile.default_profile_path
47
- end
48
- end
49
- end
50
- end
1
+ module Myun2
2
+ class TwitterShell
3
+ class Profile
4
+ attr_reader :data
5
+
6
+ class Loader
7
+ def self.load(path)
8
+ return unless File.exist?(path)
9
+ r = {}
10
+ open(path).each do |line|
11
+ key, value = line.chomp.split "="
12
+ r[key.to_sym] = value
13
+ end
14
+ r
15
+ end
16
+ end
17
+
18
+ def initialize(params = {})
19
+ @data = params
20
+ end
21
+
22
+ def save
23
+ Dir.mkdir Profile.root_dir unless File.exist?(Profile.root_dir)
24
+
25
+ open(profile_path, "w") do |f|
26
+ @data.each do |key,value|
27
+ f.puts key.to_s + "=" + value.to_s
28
+ end
29
+ end
30
+ end
31
+
32
+ def self.load(path = nil)
33
+ return unless data = Loader.load(path || default_profile_path)
34
+ new(data)
35
+ end
36
+
37
+ def self.root_dir
38
+ File.expand_path('~/.twsh')
39
+ end
40
+
41
+ def self.default_profile_path
42
+ File.join(root_dir, 'profile')
43
+ end
44
+
45
+ def profile_path
46
+ @profile_path ||= Profile.default_profile_path
47
+ end
48
+ end
49
+ end
50
+ end
@@ -1,33 +1,34 @@
1
- require 'shell_base'
2
- require 'myun2/twitter_shell/profile'
3
- require 'myun2/twitter_shell/client'
4
- require 'myun2/twitter_shell/ls'
5
-
6
- module Myun2
7
- class TwitterShell
8
- class Shell < ShellBase
9
- attr_reader :client
10
-
11
- def initialize(*params)
12
- if @profile = Profile.load
13
- @client = Client.new(@profile.data)
14
- else
15
- puts "Please first login"
16
- end
17
- super
18
- end
19
-
20
- def ls(*params)
21
- Ls.new(client, *params)
22
- end
23
-
24
- def prompt
25
- "twsh:$ "
26
- end
27
-
28
- def login(*params)
29
- Login.new(*params)
30
- end
31
- end
32
- end
33
- end
1
+ require 'shell_base'
2
+ require 'myun2/twitter_shell/profile'
3
+ require 'myun2/twitter_shell/client'
4
+ require 'myun2/twitter_shell/login'
5
+ require 'myun2/twitter_shell/ls'
6
+
7
+ module Myun2
8
+ class TwitterShell
9
+ class Shell < ShellBase
10
+ attr_reader :client
11
+
12
+ def initialize(*params)
13
+ if @profile = Profile.load
14
+ @client = Client.new(@profile.data)
15
+ else
16
+ puts "Please first login"
17
+ end
18
+ super
19
+ end
20
+
21
+ def ls(*params)
22
+ Ls.new(client, *params)
23
+ end
24
+
25
+ def prompt
26
+ "twsh:$ "
27
+ end
28
+
29
+ def login(*params)
30
+ Login.new(*params)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
- module Myun2
2
- class TwitterShell
3
- VERSION = "0.1.0"
4
- end
5
- end
1
+ module Myun2
2
+ class TwitterShell
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -1,27 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'myun2/twitter_shell/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "twsh"
8
- spec.version = Myun2::TwitterShell::VERSION
9
- spec.authors = ["myun2"]
10
- spec.email = ["myun2@nwhite.info"]
11
-
12
- spec.summary = "Twitter command line shell."
13
- spec.description = "Twitter command line shell."
14
- spec.homepage = "https://github.com/myun2/twitter-sh"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
21
-
22
- spec.add_dependency "twitter", "~> 5.14.0"
23
- spec.add_dependency "twitter_oauth", "~> 0.4.0"
24
- spec.add_dependency "shell-base", "~> 0.2.1"
25
- spec.add_development_dependency "bundler", "~> 1.9"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'myun2/twitter_shell/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "twsh"
8
+ spec.version = Myun2::TwitterShell::VERSION
9
+ spec.authors = ["myun2"]
10
+ spec.email = ["myun2@nwhite.info"]
11
+
12
+ spec.summary = "Twitter command line shell."
13
+ spec.description = "Twitter command line shell."
14
+ spec.homepage = "https://github.com/myun2/twitter-sh"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "twitter", "~> 5.14.0"
23
+ spec.add_dependency "twitter_oauth", "~> 0.4.0"
24
+ spec.add_dependency "shell-base", "~> 0.2.1"
25
+ spec.add_development_dependency "bundler", "~> 1.9"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
metadata CHANGED
@@ -1,94 +1,98 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twsh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - myun2
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: twitter
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 5.14.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.14.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: twitter_oauth
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.4.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: shell-base
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.2.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.2.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.9'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.9'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '10.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
83
  description: Twitter command line shell.
84
84
  email:
85
85
  - myun2@nwhite.info
86
- executables: []
86
+ executables:
87
+ - twsh
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
90
91
  - Gemfile
92
+ - LICENSE.txt
91
93
  - README.md
94
+ - Rakefile
95
+ - bin/twsh
92
96
  - lib/myun2/twitter/authenticate.rb
93
97
  - lib/myun2/twitter_shell.rb
94
98
  - lib/myun2/twitter_shell/authorize.rb
@@ -111,17 +115,17 @@ require_paths:
111
115
  - lib
112
116
  required_ruby_version: !ruby/object:Gem::Requirement
113
117
  requirements:
114
- - - ">="
118
+ - - '>='
115
119
  - !ruby/object:Gem::Version
116
120
  version: '0'
117
121
  required_rubygems_version: !ruby/object:Gem::Requirement
118
122
  requirements:
119
- - - ">="
123
+ - - '>='
120
124
  - !ruby/object:Gem::Version
121
125
  version: '0'
122
126
  requirements: []
123
127
  rubyforge_project:
124
- rubygems_version: 2.4.5
128
+ rubygems_version: 2.2.2
125
129
  signing_key:
126
130
  specification_version: 4
127
131
  summary: Twitter command line shell.