taubot 0.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: 454e8224b47bb3cbc9ee167dfe5434ae82217090
4
+ data.tar.gz: 74d55d0bf16baf107795d21d30f71bdcf9b8c42e
5
+ SHA512:
6
+ metadata.gz: f8d0c9d02bff116887ce6318015982c6150f83c57df203e91f338b259e0bcb6dbc950a4c5505771a0cf66afb4dae4d19e1032137d30952265d3b5d4bb2b1bf7c
7
+ data.tar.gz: 1651c3d0843c7c13a5c6729d5d1c7a84eb43a82a2b381741f4efa1e8a1cc084e9f59562c19249f6ff93a7e981573d0a203955e803f3eb9fbee8a9ae002d88397
data/.gitignore ADDED
@@ -0,0 +1,14 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in taubot.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,35 @@
1
+ Modified University of Illinois/NCSA License:
2
+
3
+ Copyright © 2015, Kento Kaneko. All rights reserved.
4
+
5
+ Developed by:
6
+
7
+ Kento Kaneko
8
+
9
+ https://github.com/kentokaneko/taubot
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
12
+ this software and associated documentation files (the “Software”), to deal with
13
+ the Software without restriction, including without limitation the rights to
14
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15
+ the Software, and to permit persons to whom the Software is furnished to do so,
16
+ subject to the following conditions:
17
+
18
+ * Redistributions of source code must retain the above copyright notice, this
19
+ list of conditions and the following disclaimers.
20
+
21
+ * Redistributions in binary form must reproduce the above copyright notice, this
22
+ list of conditions and the following disclaimers in the documentation and/or
23
+ other materials provided with the distribution.
24
+
25
+ * Neither the name "Taubot" nor the names of its contributors may be used to
26
+ endorse or promote products derived from this Software without specific prior
27
+ written permission.
28
+
29
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
35
+ SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,33 @@
1
+ # Taubot
2
+
3
+ Taubot is a bot that tweets an update to a website.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'taubot'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install taubot
20
+
21
+ ## Usage
22
+
23
+ You can find all the options by issuing:
24
+
25
+ $ taubot --help
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/taubot/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/taubot ADDED
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'nokogiri'
5
+ require 'open-uri'
6
+ require 'yaml'
7
+ require 'yaml/store'
8
+ require 'twitter'
9
+ require 'date'
10
+ require 'taubot/version'
11
+
12
+ options = {}
13
+
14
+ optparse = OptionParser.new do|opts|
15
+ opts.banner = 'Usage: taubot [options] ...'
16
+
17
+ opts.on('-s', '--station STATION', 'Use STATION as the directory') do |s|
18
+ options[:station] = s
19
+ end
20
+
21
+ opts.on('-h', '--help', 'Display the help screen') do
22
+ puts opts
23
+ exit 1
24
+ end
25
+
26
+ opts.on('-v', '--version', 'Display the version number') do
27
+ puts Taubot::VERSION
28
+ exit 1
29
+ end
30
+ end
31
+
32
+ optparse.parse!
33
+
34
+ station = Dir.pwd unless station = options[:station]
35
+
36
+ Dir.chdir(station)
37
+
38
+ unless config = Dir["config.yml"].first
39
+ puts "\nNo configuration file found\n"
40
+ exit 1
41
+ end
42
+
43
+ bits = YAML.load(open(config))
44
+
45
+ client = Twitter::REST::Client.new do |set|
46
+ set.consumer_key = bits["keys"][0]
47
+ set.consumer_secret = bits["keys"][1]
48
+ set.access_token = bits["keys"][2]
49
+ set.access_token_secret = bits["keys"][3]
50
+ end
51
+
52
+ period = bits["period"].to_f
53
+
54
+ loop do
55
+
56
+ sitemap = bits["update"][/http:\/\/.*?\//] + 'sitemap.xml'
57
+ update = bits["update"]
58
+
59
+ nodes = []
60
+
61
+ Nokogiri::HTML(open(sitemap)).xpath("//loc").each do |node|
62
+ if /\/\d{4}\/\d{2}\/\d{2}\//.match(node)
63
+ nodes.push(node.to_s.sub(/^<loc>/, "").sub(/<\/loc>$/, ""))
64
+ end
65
+ end
66
+
67
+ nodes.sort!
68
+
69
+ for node in nodes do
70
+ if node > update
71
+ title = Nokogiri::HTML(open(node)).xpath("//title").first.to_s
72
+ client.update("#{title[/(?<=>).*(?=<)/]}: #{node}")
73
+ puts update = node
74
+ end
75
+ end
76
+
77
+ secret = YAML::Store.new(config)
78
+
79
+ secret.transaction do
80
+ secret["update"] = update
81
+ end
82
+
83
+ puts "\nLast update: #{DateTime.now}\n"
84
+
85
+ sleep period
86
+
87
+ end
data/lib/taubot.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "taubot/version"
2
+
3
+ module Taubot
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Taubot
2
+ VERSION = "0.0.0"
3
+ end
data/taubot.gemspec ADDED
@@ -0,0 +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 'taubot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "taubot"
8
+ spec.version = Taubot::VERSION
9
+ spec.authors = ["Kento Kaneko"]
10
+ spec.email = ["kaneko2@illinois.edu"]
11
+ spec.summary = %q{Taubot is a bot that tweets an update to a website.}
12
+ spec.description = %q{Taubot is a bot that tweets an update to a website.}
13
+ spec.homepage = ""
14
+ spec.license = "Modified University of Illinois/NCSA"
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 = ["bin", "lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_runtime_dependency "nokogiri", ">= 1.6"
24
+ spec.add_runtime_dependency "twitter", ">= 5.3"
25
+
26
+ spec.required_ruby_version = ">= 1.9.3"
27
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taubot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kento Kaneko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-11 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: twitter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '5.3'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '5.3'
69
+ description: Taubot is a bot that tweets an update to a website.
70
+ email:
71
+ - kaneko2@illinois.edu
72
+ executables:
73
+ - taubot
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.markdown
81
+ - Rakefile
82
+ - bin/taubot
83
+ - lib/taubot.rb
84
+ - lib/taubot/version.rb
85
+ - taubot.gemspec
86
+ homepage: ''
87
+ licenses:
88
+ - Modified University of Illinois/NCSA
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - bin
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: 1.9.3
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.4.5
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Taubot is a bot that tweets an update to a website.
111
+ test_files: []