tweetgithub 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3fdca7366c3566ac6f7c7d1976ee2e70ef0f8d22
4
+ data.tar.gz: 5d9332836ed4a123ba77a3d4f5ef67482b4c2518
5
+ SHA512:
6
+ metadata.gz: 0412f7813d031e96361f6699e6934eef1af5b1ccd3e81cc29b79c608cc59c7d2eb67e5c24f6f74d7ec07a56013648e68c8d93c9e064d73133b0f0a599017908a
7
+ data.tar.gz: 1ff6a79129f30c7b52f20ae95bc49865c1169b734f41802cf472d35f23848afb4b7f383df6b45c4de49206d991a4885332f8ae6a52e6b8eb31b3263c784fd5f7
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at j.little@miami.edu. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tweetgithub.gemspec
4
+ gemspec
@@ -0,0 +1,47 @@
1
+ # Tweetgithub
2
+
3
+ This is a Ruby Gem that creats a post in a Jekyll based Git site and posts a tweet at the same time.
4
+
5
+ To use it, you'll need to create a YAML file with your basic setup information and Twitter API credentials:
6
+
7
+
8
+ consumer_key: ""
9
+ consumer_secret: ""
10
+ access_token: ""
11
+ access_token_secret: ""
12
+ author: ""
13
+ posts_dir: "/Somewhere/repos/repo/_posts/"
14
+
15
+ Programmatically:
16
+
17
+ ```ruby
18
+ tw = Tweetgithub::Tweetgithub.new("/Users/someone/Desktop/tweet-github/twitter_secrets.yml")
19
+ tw.tweet('Post text')
20
+ ```
21
+
22
+ From the command-line:
23
+
24
+ ```bash
25
+ tweetgithub /Path/to/Yaml/ "Tweet text"
26
+ ```
27
+
28
+ This will create a post in the Jekyll site then add, commit, and push the post, while also pushing it to Twitter.
29
+
30
+ ## Installation
31
+
32
+ Add this line to your application's Gemfile:
33
+
34
+ ```ruby
35
+ gem 'tweetgithub'
36
+ ```
37
+
38
+ And then execute:
39
+
40
+ $ bundle
41
+
42
+ Or install it yourself as:
43
+
44
+ $ gem install tweetgithub
45
+
46
+
47
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tweetgithub"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -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
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'tweetgithub'
3
+
4
+ ttg = Tweetgithub::Tweetgithub.new(ARGV[0])
5
+ ttg.tweet(ARGV[1])
@@ -0,0 +1,6 @@
1
+ require "tweetgithub/version"
2
+ require "tweetgithub/tweetgithub"
3
+ require 'yaml'
4
+ require 'twitter'
5
+ module Tweetgithub
6
+ end
@@ -0,0 +1,55 @@
1
+ module Tweetgithub
2
+ class Tweetgithub
3
+ attr_accessor :client
4
+ attr_accessor :posts_dir
5
+ attr_accessor :config
6
+
7
+ def initialize(conf)
8
+ @conf = YAML.load_file(conf)
9
+
10
+ @client = Twitter::REST::Client.new do |config|
11
+ config.consumer_key = @conf['consumer_key']
12
+ config.consumer_secret = @conf['consumer_secret']
13
+ config.access_token = @conf['access_token']
14
+ config.access_token_secret = @conf['access_token_secret']
15
+ end
16
+
17
+ @posts_dir = @conf['posts_dir']
18
+ end
19
+
20
+ def tweet(text)
21
+ File.open("#{@posts_dir}/#{get_date}-#{clean_title(text)}.md",'w') { |file| file.write(post_layout(text,text,text)) }
22
+
23
+
24
+ p `cd #{posts_dir} && git add .`
25
+ p `cd #{posts_dir} && git commit -m 'adding post'`
26
+ p `cd #{posts_dir} && git push`
27
+
28
+ @client.update(text)
29
+ end
30
+
31
+ def get_date
32
+ time = Time.new
33
+ time.strftime('%Y-%m-%d')
34
+ end
35
+
36
+ def post_layout(title, description, body)
37
+ <<END_HEREDOC
38
+ ---
39
+ layout: post
40
+ title: "#{title}"
41
+ author: "#{@conf['author']}"
42
+ description: "#{body}"
43
+ ---
44
+
45
+ #{body}
46
+ END_HEREDOC
47
+ end
48
+
49
+ def clean_title(text)
50
+ text.gsub(' ','-').gsub(':','-').gsub('/','-').gsub('.','-').gsub('?','_').gsub('&','_')
51
+ end
52
+
53
+ end
54
+ end
55
+
@@ -0,0 +1,3 @@
1
+ module Tweetgithub
2
+ VERSION = "0.1.0"
3
+ end
@@ -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 'tweetgithub/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tweetgithub"
8
+ spec.version = Tweetgithub::VERSION
9
+ spec.authors = ["James Little"]
10
+ spec.email = ["jamie@jamielittle.org"]
11
+
12
+ spec.summary = "A command line tool for posting to a Jekyll based GitHub site and twitter at the same time"
13
+ spec.description = "A command line tool for posting to a Jekyll based GitHub site and twitter at the same time"
14
+ spec.homepage = "http://github.com/little9/tweetgithub"
15
+
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_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "minitest", "~> 5.0"
25
+ spec.add_runtime_dependency "twitter"
26
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tweetgithub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Little
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: twitter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A command line tool for posting to a Jekyll based GitHub site and twitter
70
+ at the same time
71
+ email:
72
+ - jamie@jamielittle.org
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - bin/tweetgithub
86
+ - lib/tweetgithub.rb
87
+ - lib/tweetgithub/tweetgithub.rb
88
+ - lib/tweetgithub/version.rb
89
+ - tweetgithub.gemspec
90
+ homepage: http://github.com/little9/tweetgithub
91
+ licenses: []
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.5.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: A command line tool for posting to a Jekyll based GitHub site and twitter
113
+ at the same time
114
+ test_files: []