knife-twitter 0.1.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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjBmZDQ1OGI1MTRmZGM4NjVlYTNkNGQ0OGJlMGU2Y2U4ZTA1M2YxYw==
5
+ data.tar.gz: !binary |-
6
+ NGI2NzhlYzc5ZWE1NzZiYmVjMTA5YjBkZjZkMTJmNmExNTJkM2NkZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZmE3MDk5ZTc4Mzg2MDY3M2VhODdhODg5ZGE4ZmUwY2M1MmU2ZWFlZTE4NzI2
10
+ YTE2MGQyMGUyNjdmMzYyMWFiOGYwMTQyNGJjODIyZDhiNTQyMGUzYjdmMTE2
11
+ ZDAzNWQyNmJhM2RjOWY2MmI0MmQ0MjU3MmU4ZTQ2MDkwZTNlNzQ=
12
+ data.tar.gz: !binary |-
13
+ N2YzYTNmMDViOTc3MDhlMjU2MzcxOTRlNjM3YTNiMmVkOGZlYzllODc0MzQz
14
+ NDBkYWUyMjU4MDk3YTlmZDE0Njc0ZjlmYjFhMWQ4NDEzOWE0MzY4NTNiYTlh
15
+ NTUyM2U4ZjE4NzMzMjExOGE0OGFkYmQ3MDM5ODgxMzM1ZmJlYTk=
@@ -0,0 +1,6 @@
1
+ ## Twitter
2
+ knife[:twitter_consumer_key] = 'YOUR_CONSUMER_KEY'
3
+ knife[:twitter_consumer_secret] = 'YOUR_CONSUMER_SECRET'
4
+ knife[:twitter_oauth_token] = 'YOUR_OAUTH_TOKEN'
5
+ knife[:twitter_oauth_token_secret] = 'YOUR_OAUTH_TOKEN_SECRET'
6
+
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .chef/knife.rb
19
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in knife-twitter.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 sawanoboly
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,158 @@
1
+ # Knife-Twitter
2
+
3
+ A Knife(Opscode Chef) plugin for [Twitter](http://twitter.com). You can post a tweet via knife and retrive your timeline or mentions on current terminal.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ### from Rubygems
10
+
11
+ gem 'knife-twitter'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install knife-twitter
20
+
21
+ ### from github
22
+
23
+ Drop the following line into your application's `Gemfile`.
24
+
25
+ gem 'knife-zcloudjp', :git => "git://github.com/higanworks/knife-zcloudjp.git"
26
+
27
+ And execute the `bundle` command.
28
+
29
+ $ bundle
30
+
31
+
32
+ ## Usage
33
+
34
+ ### Configration
35
+
36
+ Pass your twitter Tokens via `command line option` or `knfe.rb`. `knife.rb` takes precedence over the `command line option`.
37
+
38
+
39
+ Add the following entries to your `.chef/knife.rb`.
40
+
41
+ ```
42
+ ## Twitter
43
+ knife[:twitter_consumer_key] = 'YOUR_CONSUMER_KEY'
44
+ knife[:twitter_consumer_secret] = 'YOUR_CONSUMER_SECRET'
45
+ knife[:twitter_oauth_token] = 'YOUR_OAUTH_TOKEN'
46
+ knife[:twitter_oauth_token_secret] = 'YOUR_OAUTH_TOKEN_SECRET'
47
+ ```
48
+
49
+ Or use common command line option.
50
+
51
+ ```
52
+ -K CONSUMER_KEY, Your Twitter Consumer Key
53
+ --twitter_consumer_key
54
+ -S CONSUMER_SECRET, Your Twitter Consumer Secret
55
+ --twitter_consumer_secret
56
+ -o TOKEN, Your Twitter OAuth Token
57
+ --twitter_oauth_token
58
+ -O TOKEN_SECRET, Your Twitter OAuth Token Secret
59
+ --twitter_oauth_token_secret
60
+ ```
61
+
62
+ ## SubCommands
63
+
64
+ ** TWITTER COMMANDS **
65
+
66
+ - knife twitter version
67
+ - knife twitter post (options)
68
+ - knife twitter tl (options)
69
+
70
+
71
+ ### knife twitter version
72
+
73
+ Show plugin verson and show current Tokens.
74
+
75
+ ```
76
+ $ knife twitter version
77
+ VERSION: 0.1.0
78
+ CONSUMER_KEY: *************
79
+ CONSUMER_SECRET: **************************
80
+ TOKEN: **************************
81
+ TOKEN_SECRET:**************************
82
+ ```
83
+
84
+ ### knife twitter post (options)
85
+
86
+ Tweet via knife.
87
+
88
+ #### Option
89
+
90
+ ```
91
+ -m TWEET_MEAASAGE, Your Tweet
92
+ --twitter_message
93
+ ```
94
+
95
+
96
+ Tweet a default message.
97
+
98
+ ```
99
+ $ knife twitter post
100
+ Tweet Success! #=> Tweet with knife-twitter 0.1.0 2013-05-13 22:39:10 +0900
101
+ ```
102
+
103
+ Tweet with your message.
104
+
105
+ ```
106
+ $ knife twitter post -m 'Hello Chef!'
107
+ Tweet Success! #=> Hello Chef!
108
+ ```
109
+
110
+
111
+ ### knife twitter tl (options)
112
+
113
+ Show current timeline or mensions.
114
+
115
+ #### Option
116
+
117
+ ```
118
+ -m, --twitter_mentions enable mentions
119
+ ```
120
+
121
+ Retrieve a timeline.
122
+
123
+ ```
124
+ $ knife twitter tl
125
+ higanworks 2013-05-13 22:41:47 +0900 Hello Chef!
126
+ higanworks 2013-05-13 22:39:12 +0900 Tweet with knife-twitter 0.1.0 2013-05-13 15:39:10 +0900
127
+ higanworks 2013-05-13 21:31:48 +0900 Tweet with knife-twitter 0.0.1 2013-05-13 14:31:47 +0900
128
+ higanworks 2013-05-13 21:29:20 +0900 Tweet with knife-twitter 0.0.1 2013-05-13 14:29:19 +0900
129
+ higanworks 2013-05-13 21:28:37 +0900 Tweet with knife-twitter 0.0.1 2013-05-13 14:28:37 +0900
130
+ higanworks 2013-05-13 20:46:45 +0900 test2
131
+ higanworks 2013-05-13 13:33:23 +0900 Tweet with knife-twitter 0.0.1 2013-05-13 13:33:23 +0900
132
+ higanworks 2013-05-12 19:28:59 +0900 I'm tweeting with @gem!
133
+ DatasetStalker 2013-05-07 01:20:15 +0900 New dataset appeared. riak:13.1.0:1567edb0-b33e-11e2-a0d2-bf73e2825ffe #joyent
134
+ DatasetStalker 2013-05-04 00:21:31 +0900 New dataset appeared. nodejs:13.1.0:beb2dbd4-b26f-11e2-8ad4-935c80092aa6 #joyent
135
+ DatasetStalker 2013-05-02 05:20:09 +0900 New dataset appeared. percona:13.1.0:3882b5da-b0e8-11e2-b3a9-dbcf26c3e051 #joyent
136
+ DatasetStalker 2013-04-27 00:20:23 +0900 New dataset appeared. base64:13.1.0:9eac5c0c-a941-11e2-a7dc-57a6b041988f #joyent
137
+ DatasetStalker 2013-04-27 00:20:23 +0900 New dataset appeared. base:13.1.0:f669428c-a939-11e2-a485-b790efc0f0c1 #joyent
138
+ DatasetStalker 2013-04-25 01:20:57 +0900 New dataset appeared. centos-6:2.4.1:87c556ac-ab9d-11e2-914d-07682fcab47d #joyent
139
+ DatasetStalker 2013-04-19 04:23:49 +0900 New dataset appeared. debian-6.0.7:2.4.1:014e2254-a853-11e2-81c9-b318c31fa17a #joyent
140
+ DatasetStalker 2013-04-16 05:20:27 +0900 New dataset appeared. ubuntu-12.04:2.4.1:da144ada-a558-11e2-8762-538b60994628 #joyent
141
+ DatasetStalker 2013-04-13 02:20:10 +0900 New dataset appeared. chefserver:1.1.0:e6f10814-a38d-11e2-8138-67b96e228c1e #joyent
142
+ ```
143
+
144
+ Retrieve mentions
145
+
146
+ ```
147
+ $ knife twitter tl -m
148
+ sawanoboly 2013-01-31 00:13:03 +0900 http://t.co/n18mSGcA RT @higanworks: I'm tweeting with @gem!
149
+ ```
150
+
151
+
152
+ ## Contributing
153
+
154
+ 1. Fork it
155
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
156
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
157
+ 4. Push to the branch (`git push origin my-new-feature`)
158
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'knife-twitter'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "knife-twitter"
8
+ spec.version = Knife::Twitter::VERSION
9
+ spec.authors = ["sawanoboly"]
10
+ spec.email = ["sawanoboriyu@higanworks.com"]
11
+ spec.description = %q{knife-plugin for twitter.}
12
+ spec.summary = %q{tweet via knife(chef)}
13
+ spec.homepage = "https://github.com/higanworks/knife-twitter"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_dependency "chef"
22
+ spec.add_dependency "twitter"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,75 @@
1
+ require "knife-twitter"
2
+ require 'chef/knife'
3
+
4
+ class Chef
5
+ class Knife
6
+ module TwitterBase
7
+ def self.included(includer)
8
+ includer.class_eval do
9
+
10
+ deps do
11
+ require 'twitter'
12
+ end
13
+
14
+ option :twitter_consumer_key,
15
+ :short => "-K CONSUMER_KEY",
16
+ :long => "--twitter_consumer_key",
17
+ :description => "Your Twitter Consumer Key",
18
+ :proc => Proc.new { |key| Chef::Config[:knife][:twitter_consumer_key] = key }
19
+
20
+ option :twitter_consumer_secret,
21
+ :short => "-S CONSUMER_SECRET",
22
+ :long => "--twitter_consumer_secret",
23
+ :description => "Your Twitter Consumer Secret",
24
+ :proc => Proc.new { |key| Chef::Config[:knife][:twitter_consumer_secret] = key }
25
+
26
+ option :twitter_oauth_token,
27
+ :short => "-o TOKEN",
28
+ :long => "--twitter_oauth_token",
29
+ :description => "Your Twitter OAuth Token",
30
+ :proc => Proc.new { |key| Chef::Config[:knife][:twitter_oauth_token] = key }
31
+
32
+ option :twitter_oauth_token_secret,
33
+ :short => "-O TOKEN_SECRET",
34
+ :long => "--twitter_oauth_token_secret",
35
+ :description => "Your Twitter OAuth Token Secret",
36
+ :proc => Proc.new { |key| Chef::Config[:knife][:twitter_oauth_token_secret] = key }
37
+
38
+ end
39
+ end
40
+
41
+ def locate_config_value(key)
42
+ key = key.to_sym
43
+ Chef::Config[:knife][key] || config[key]
44
+ end
45
+
46
+ def msg_pair(label, value, color=:cyan)
47
+ if value && !value.to_s.empty?
48
+ puts "#{ui.color(label, color)}: #{value}"
49
+ end
50
+ end
51
+
52
+ def t_configure
53
+ Twitter.configure do |config|
54
+ config.consumer_key = locate_config_value(:twitter_consumer_key)
55
+ config.consumer_secret = locate_config_value(:twitter_consumer_secret)
56
+ config.oauth_token = locate_config_value(:twitter_oauth_token)
57
+ config.oauth_token_secret = locate_config_value(:twitter_oauth_token_secret)
58
+ end
59
+ end
60
+ end
61
+
62
+ class TwitterVersion < Knife
63
+ include TwitterBase
64
+ banner "knife twitter version"
65
+ def run
66
+ msg_pair("VERSION", ::Knife::Twitter::VERSION, :blue)
67
+ msg_pair("CONSUMER_KEY", locate_config_value(:twitter_consumer_key))
68
+ msg_pair("CONSUMER_SECRET", locate_config_value(:twitter_consumer_secret))
69
+ msg_pair("TOKEN", locate_config_value(:twitter_oauth_token))
70
+ msg_pair("TOKEN_SECRET", locate_config_value(:twitter_oauth_token_secret))
71
+ end
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,31 @@
1
+ require "knife-twitter"
2
+ require 'chef/knife'
3
+
4
+ class Chef
5
+ class Knife
6
+ class TwitterPost < Knife
7
+ include TwitterBase
8
+
9
+ option :twitter_message,
10
+ :short => "-m TWEET_MEAASAGE",
11
+ :long => "--twitter_message",
12
+ :description => "Your Tweet",
13
+ :proc => Proc.new { |message| Chef::Config[:knife][:twitter_message] = message },
14
+ :default => "Tweet with knife-twitter " + ::Knife::Twitter::VERSION + " " + Time.now.to_s
15
+
16
+ banner "knife twitter post (options)"
17
+ def run
18
+ t_configure
19
+ begin
20
+ Twitter.update(locate_config_value(:twitter_message))
21
+ ui.info("Tweet Success! #=> #{locate_config_value(:twitter_message)}")
22
+ rescue => e
23
+ ui.fatal("Tweet Failed! #=> #{e.class}")
24
+ ui.fatal(e.message)
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,43 @@
1
+ require "knife-twitter"
2
+ require 'chef/knife'
3
+
4
+ class Chef
5
+ class Knife
6
+ class TwitterTl < Knife
7
+ include TwitterBase
8
+
9
+ option :twitter_mentions,
10
+ :short => "-m",
11
+ :long => "--twitter_mentions",
12
+ :description => "enable mentions",
13
+ :default => false
14
+
15
+ banner "knife twitter tl (options)"
16
+ def run
17
+ t_configure
18
+ begin
19
+ if locate_config_value(:twitter_mentions)
20
+ timeline = Twitter.mentions_timeline
21
+ else
22
+ timeline = Twitter.home_timeline
23
+ end
24
+ rescue => e
25
+ ui.fatal("Retrieve Failed! #=> #{e.class}")
26
+ ui.fatal(e.message)
27
+ exit
28
+ end
29
+
30
+ tl_list = []
31
+ timeline.map do |tl|
32
+ tl_list << ui.color(tl[:user][:screen_name], :cyan)
33
+ tl_list << ui.color(tl[:created_at].to_s, :magenta)
34
+ tl_list << ui.color(tl[:text])
35
+ end
36
+
37
+ puts ui.list(tl_list, :uneven_columns_across, 3)
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ module Knife
2
+ module Twitter
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-twitter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sawanoboly
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef
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: twitter
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.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: knife-plugin for twitter.
70
+ email:
71
+ - sawanoboriyu@higanworks.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .chef/knife.rb.sample
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - knife-twitter.gemspec
83
+ - lib/chef/knife/twitter.rb
84
+ - lib/chef/knife/twitter_post.rb
85
+ - lib/chef/knife/twitter_timeline.rb
86
+ - lib/knife-twitter.rb
87
+ homepage: https://github.com/higanworks/knife-twitter
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.3
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: tweet via knife(chef)
111
+ test_files: []