twee 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,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5d114ec04e8872fb3964be3043fe9d173a8b7870a0ba2d0751b7971c5d111ff4
4
+ data.tar.gz: 38adc2daac0d4ce9d36f3aa383e5e2a9d00aace51135d4c5a72dc26f2d7e437c
5
+ SHA512:
6
+ metadata.gz: 2b78ca88778622820ab8e74ffd245c365c35b3ab536d9a4240f622e956785afc2f0be5f323df82ea806f0a9a4bab455056fba50fe2e5c3950697d3953d193f3c
7
+ data.tar.gz: a5473666d1442f8495fe46295d0a3a1f4f200ae84f2dea507e320ac2a8184294a56caff666910906d2b94dac63802bee872f58c2752aec77828f4f03f81e8b73
@@ -0,0 +1,14 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ bundler-cache: true
13
+ - name: Run the default task
14
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.0
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Style/StringLiteralsInInterpolation:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Layout/LineLength:
14
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-08-25
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in twee.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop"
13
+ gem "rubocop-rake"
14
+ gem "rubocop-rspec"
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ twee (0.1.0)
5
+ oauth
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ diff-lcs (1.4.4)
12
+ oauth (0.5.6)
13
+ parallel (1.20.1)
14
+ parser (3.0.2.0)
15
+ ast (~> 2.4.1)
16
+ rainbow (3.0.0)
17
+ rake (13.0.6)
18
+ regexp_parser (2.1.1)
19
+ rexml (3.2.5)
20
+ rspec (3.10.0)
21
+ rspec-core (~> 3.10.0)
22
+ rspec-expectations (~> 3.10.0)
23
+ rspec-mocks (~> 3.10.0)
24
+ rspec-core (3.10.1)
25
+ rspec-support (~> 3.10.0)
26
+ rspec-expectations (3.10.1)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.10.0)
29
+ rspec-mocks (3.10.2)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.10.0)
32
+ rspec-support (3.10.2)
33
+ rubocop (1.19.1)
34
+ parallel (~> 1.10)
35
+ parser (>= 3.0.0.0)
36
+ rainbow (>= 2.2.2, < 4.0)
37
+ regexp_parser (>= 1.8, < 3.0)
38
+ rexml
39
+ rubocop-ast (>= 1.9.1, < 2.0)
40
+ ruby-progressbar (~> 1.7)
41
+ unicode-display_width (>= 1.4.0, < 3.0)
42
+ rubocop-ast (1.11.0)
43
+ parser (>= 3.0.1.1)
44
+ rubocop-rake (0.6.0)
45
+ rubocop (~> 1.0)
46
+ rubocop-rspec (2.6.0)
47
+ rubocop (~> 1.19)
48
+ ruby-progressbar (1.11.0)
49
+ unicode-display_width (2.0.0)
50
+
51
+ PLATFORMS
52
+ arm64-darwin-20
53
+ arm64-darwin-21
54
+ x86_64-linux
55
+
56
+ DEPENDENCIES
57
+ rake (~> 13.0)
58
+ rspec (~> 3.0)
59
+ rubocop
60
+ rubocop-rake
61
+ rubocop-rspec
62
+ twee!
63
+
64
+ BUNDLED WITH
65
+ 2.2.32
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 okonomi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Twee
2
+
3
+ Simple tweet tool.
4
+
5
+ ## Installation
6
+
7
+ Install from rubygems.org:
8
+
9
+ ```
10
+ $ gem install twee
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Setup
16
+
17
+ First, run `twee` command with no arguments. Display authorize URL. Access that URL and copy shown PIN code and paste it.
18
+
19
+ ```
20
+ $ twee
21
+ Please access this URL : https://twitter.com/oauth/authorize?oauth_token=xxxxxxxxxxxxxxxx
22
+ Please enter the PIN code :
23
+ ```
24
+
25
+ Save configuration to `~/.twee.yml`.
26
+
27
+ ### Tweet
28
+
29
+ ```
30
+ $ twee message
31
+ ```
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "twee"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/twee ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "oauth"
5
+ require "uri"
6
+ require "json"
7
+ require "yaml/store"
8
+
9
+ config_path = File.expand_path("~/.twee.yml")
10
+ config = if File.exist?(config_path)
11
+ YAML.load_file(config_path)
12
+ else
13
+ {
14
+ "consumer_key" => "hNh4xlW32H9X6Z7GEoStyUJiL",
15
+ "consumer_secret" => "OAwfI08IJ8s94Xpczw4EzYrrrwd6xvOUC8lYbpuwgPlgQYwAay"
16
+ }
17
+ end
18
+
19
+ oauth = OAuth::Consumer.new(
20
+ config["consumer_key"],
21
+ config["consumer_secret"],
22
+ site: "https://twitter.com"
23
+ # debug_output: true,
24
+ )
25
+
26
+ if config["access_token"] && config["access_token_secret"]
27
+ hash = { oauth_token: config["access_token"], oauth_token_secret: config["access_token_secret"] }
28
+ access_token = OAuth::AccessToken.from_hash(oauth, hash)
29
+ else
30
+ request_token = oauth.get_request_token
31
+
32
+ puts "Please access this URL : #{request_token.authorize_url}"
33
+ print "Please enter the PIN code : "
34
+ pin_code = $stdin.gets.to_i
35
+
36
+ access_token = request_token.get_access_token(
37
+ oauth_verifier: pin_code
38
+ )
39
+ config["access_token"] = access_token.token
40
+ config["access_token_secret"] = access_token.secret
41
+
42
+ store = YAML::Store.new config_path
43
+ store.transaction do
44
+ store["consumer_key"] = config["consumer_key"]
45
+ store["consumer_secret"] = config["consumer_secret"]
46
+ store["access_token"] = config["access_token"]
47
+ store["access_token_secret"] = config["access_token_secret"]
48
+ end
49
+ end
50
+
51
+ message = ARGV[0]
52
+
53
+ unless message.nil? || message.empty?
54
+ res = access_token.post("https://api.twitter.com/1.1/statuses/update.json?status=#{URI.encode_www_form_component(message)}")
55
+ puts res.code
56
+ # pp JSON.parse(res.body)
57
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Twee
4
+ VERSION = "0.1.0"
5
+ end
data/lib/twee.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "twee/version"
4
+
5
+ module Twee
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
data/twee.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/twee/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "twee"
7
+ spec.version = Twee::VERSION
8
+ spec.authors = ["okonomi"]
9
+ spec.email = ["okonomi@oknm.jp"]
10
+
11
+ spec.summary = "simple tweet tool"
12
+ spec.description = "simple tweet tool"
13
+ spec.homepage = "https://github.com/okonomi/twee"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.0.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/okonomi/twee"
19
+ spec.metadata["changelog_uri"] = "https://github.com/okonomi/twee/blob/master/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Uncomment to register a new dependency of your gem
31
+ spec.add_dependency "oauth"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twee
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - okonomi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth
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
+ description: simple tweet tool
28
+ email:
29
+ - okonomi@oknm.jp
30
+ executables:
31
+ - twee
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".github/workflows/main.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".rubocop.yml"
39
+ - ".ruby-version"
40
+ - CHANGELOG.md
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - bin/console
47
+ - bin/setup
48
+ - exe/twee
49
+ - lib/twee.rb
50
+ - lib/twee/version.rb
51
+ - twee.gemspec
52
+ homepage: https://github.com/okonomi/twee
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ homepage_uri: https://github.com/okonomi/twee
57
+ source_code_uri: https://github.com/okonomi/twee
58
+ changelog_uri: https://github.com/okonomi/twee/blob/master/CHANGELOG.md
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 3.0.0
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.2.32
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: simple tweet tool
78
+ test_files: []