twitter_ebooks 2.1.9 → 2.2.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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTQ5NDgzZjNmM2U0ZWNhZmRiYzJiYTdlZGFkY2U3ZTNjMDllYTI5NA==
5
- data.tar.gz: !binary |-
6
- NTE1NDQ5MTI0MDk0YzlmMDlkOWQ1NTc1YTQ5M2RhNTdmZDg4MzIxOQ==
2
+ SHA1:
3
+ metadata.gz: 9a195e8ec2f93b16ea56f273a7e04e05888f4a56
4
+ data.tar.gz: 9c52e2351ab996f75a307872d0fed1625f585ebb
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZmYzZWM1NTIyZDE0YzNkYjcwZTdkZmVhNDM3MGJjNzZhMzJkNTkxNTJlNjlh
10
- MzQwMjRjZThiYzNmM2FjMDQ3OGU0Njk3MmVkYzQ3ZTVjOTczNzUxMWE4OGVi
11
- YTQ5ZmM2YTZiN2MxM2M0YjJjNWM0OTRiMGM3NDM4ZTA0YmM2Zjg=
12
- data.tar.gz: !binary |-
13
- MmQ1N2Y1YmM4ZmUwMGE4MWEwY2RhZjU2Mjc3NDdjMTZlZjkxNTk3M2EzODdl
14
- Mjk2NDg4ZTk5YjQ5YzUzNTQ1YWQ3NTc4ZDM0N2ExZDg1ZDIyZDAxNGU4M2Ew
15
- N2RhY2RkNTUyOWE1MmU3OWNlNDhjMmJjMjU1NzllZjAxMzJiYzQ=
6
+ metadata.gz: 6f3e7a031145d865fb5036643450cb2eb0f7dd1394daea638006cd2992dbeb5e470fac29403d2d8167ce0410fbffaf44e5e9dbf550f10bfcfdb75ebab325685d
7
+ data.tar.gz: b1abc3ea2a384aa9bda6765db3fc0d586c7d7498a96efc78be33e47ddcac83e8d45e7d509a2dfff45e895d49a3120c3bde26981d97607b07026c49214c248bcd
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  .*.swp
2
+ Gemfile.lock
2
3
  pkg
data/Gemfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- # twitter\_ebooks 2.1.9
1
+ # twitter\_ebooks 2.2.0
2
2
 
3
3
  Rewrite of my twitter\_ebooks code. While the original was solely a tweeting Markov generator, this framework helps you build any kind of interactive twitterbot which responds to mentions/DMs.
4
4
 
5
5
  ## Installation
6
6
 
7
+ Requires Ruby 1.9.3+
8
+
7
9
  ```bash
8
10
  gem install twitter_ebooks
9
11
  ```
data/Rakefile CHANGED
File without changes
data/bin/ebooks CHANGED
@@ -8,7 +8,12 @@ module Ebooks
8
8
  APP_PATH = Dir.pwd # XXX do some recursive thing instead
9
9
 
10
10
  def self.new(reponame)
11
- usage = "Usage: ebooks new <reponame>"
11
+ usage = <<STR
12
+ Usage: ebooks new <reponame>
13
+
14
+ Creates a new skeleton repository defining a template bot in
15
+ the current working directory specified by <reponame>.
16
+ STR
12
17
 
13
18
  if reponame.nil?
14
19
  log usage
@@ -33,10 +38,21 @@ module Ebooks
33
38
  end
34
39
 
35
40
  def self.consume(pathes)
41
+ usage = <<STR
42
+ Usage: ebooks consume <corpus_path> [corpus_path2] [...]
43
+
44
+ Processes some number of text files or json tweet corpuses
45
+ into usable models. These will be output at model/<name>.model
46
+ STR
47
+
48
+ if pathes.empty?
49
+ log usage
50
+ exit
51
+ end
52
+
36
53
  pathes.each do |path|
37
54
  filename = File.basename(path)
38
55
  shortname = filename.split('.')[0..-2].join('.')
39
- hash = Digest::MD5.hexdigest(File.read(path))
40
56
 
41
57
  outpath = File.join(APP_PATH, 'model', "#{shortname}.model")
42
58
  Model.consume(path).save(outpath)
@@ -45,6 +61,17 @@ module Ebooks
45
61
  end
46
62
 
47
63
  def self.gen(model_path, input)
64
+ usage = <<STR
65
+ Usage: ebooks gen <model_path> [input]
66
+
67
+ Make a test tweet from the processed model at <model_path>.
68
+ Will respond to input if provided.
69
+ STR
70
+ if model_path.nil?
71
+ log usage
72
+ exit
73
+ end
74
+
48
75
  model = Model.load(model_path)
49
76
  if input && !input.empty?
50
77
  puts "@cmd " + model.make_response(input, 135)
@@ -54,25 +81,71 @@ module Ebooks
54
81
  end
55
82
 
56
83
  def self.score(model_path, input)
84
+ usage = <<STR
85
+ Usage: ebooks score <model_path> <input>
86
+
87
+ Scores "interest" in some text input according to how
88
+ well unique keywords match the model.
89
+ STR
90
+ if model_path.nil? || input.nil?
91
+ log usage
92
+ exit
93
+ end
94
+
57
95
  model = Model.load(model_path)
58
96
  model.score_interest(input)
59
97
  end
60
98
 
61
99
  def self.archive(username, outpath)
100
+ usage = <<STR
101
+ Usage: ebooks archive <username> <outpath>
102
+
103
+ Downloads a json corpus of the <username>'s tweets to <outpath>.
104
+ Due to API limitations, this can only receive up to ~3000 tweets
105
+ into the past.
106
+ STR
107
+
108
+ if username.nil? || outpath.nil?
109
+ log usage
110
+ exit
111
+ end
112
+
62
113
  Archive.new(username, outpath).sync
63
114
  end
64
115
 
65
- def self.tweet(modelpath, username)
116
+ def self.tweet(modelpath, botname)
117
+ usage = <<STR
118
+ Usage: ebooks jsonify <old_corpus_path> [old_corpus_path2] [...]
119
+
120
+ Takes an old-style corpus of plain tweet text and converts it to json.
121
+ STR
122
+
123
+ if modelpath.nil? || botname.nil?
124
+ log usage
125
+ exit
126
+ end
127
+
66
128
  load File.join(APP_PATH, 'bots.rb')
67
129
  model = Model.load(modelpath)
68
130
  statement = model.make_statement
69
- log "@#{username}: #{statement}"
70
- bot = Bot.get(username)
131
+ log "@#{botname}: #{statement}"
132
+ bot = Bot.get(botname)
71
133
  bot.configure
72
134
  bot.tweet(statement)
73
135
  end
74
136
 
75
137
  def self.jsonify(paths)
138
+ usage = <<STR
139
+ Usage: ebooks jsonify <old_corpus_path> [old_corpus_path2] [...]
140
+
141
+ Takes an old-style corpus of plain tweet text and converts it to json.
142
+ STR
143
+
144
+ if paths.empty?
145
+ log usage
146
+ exit
147
+ end
148
+
76
149
  paths.each do |path|
77
150
  name = File.basename(path).split('.')[0]
78
151
  new_path = name + ".json"
@@ -100,15 +173,16 @@ module Ebooks
100
173
  end
101
174
 
102
175
  def self.command(args)
103
- usage = """Usage:
176
+ usage = <<STR
177
+ Usage:
104
178
  ebooks new <reponame>
105
- ebooks consume <corpus_path> [...]
179
+ ebooks consume <corpus_path> [corpus_path2] [...]
106
180
  ebooks gen <model_path> [input]
107
181
  ebooks score <model_path> <input>
108
182
  ebooks archive <@user> <outpath>
109
- ebooks tweet <model_path> <@bot>
110
- ebooks jsonify <old_corpus_path> [...]
111
- """
183
+ ebooks tweet <model_path> <botname>
184
+ ebooks jsonify <old_corpus_path> [old_corpus_path2] [...]
185
+ STR
112
186
 
113
187
  if args.length == 0
114
188
  log usage
data/data/adjectives.txt CHANGED
File without changes
data/data/nouns.txt CHANGED
File without changes
data/data/stopwords.txt CHANGED
File without changes
File without changes
@@ -103,7 +103,7 @@ module Ebooks
103
103
  mless = ev[:text]
104
104
  begin
105
105
  ev.attrs[:entities][:user_mentions].reverse.each do |entity|
106
- mless = mless[0...entity[:indices][0]] + mless[entity[:indices][1]...-1]
106
+ mless = mless[0...entity[:indices][0]] + mless[entity[:indices][1]+1..-1]
107
107
  end
108
108
  rescue Exception
109
109
  p ev.attrs[:entities][:user_mentions]
@@ -136,7 +136,6 @@ module Ebooks
136
136
  # Applies configurable @reply_delay range
137
137
  def reply(ev, text, opts={})
138
138
  opts = opts.clone
139
- delay = @reply_delay.to_a.sample
140
139
 
141
140
  if ev.is_a? Twitter::DirectMessage
142
141
  log "Sending DM to @#{ev[:sender][:screen_name]}: #{text}"
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,3 @@
1
1
  module Ebooks
2
- VERSION = "2.1.9"
2
+ VERSION = "2.2.0"
3
3
  end
File without changes
data/skeleton/Gemfile CHANGED
File without changes
data/skeleton/Procfile CHANGED
File without changes
data/skeleton/bots.rb CHANGED
File without changes
File without changes
File without changes
data/skeleton/run.rb CHANGED
File without changes
File without changes
data/test/keywords.rb CHANGED
File without changes
data/test/tokenize.rb CHANGED
File without changes
File without changes
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_ebooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.9
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaiden Mispy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-29 00:00:00.000000000 Z
11
+ date: 2014-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '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: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: twitter
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.5'
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: '4.5'
41
41
  - !ruby/object:Gem::Dependency
@@ -56,95 +56,95 @@ dependencies:
56
56
  name: rufus-scheduler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
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: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gingerice
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
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: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: htmlentities
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: engtagger
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: fast-stemmer
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: highscore
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: Markov chains for all your friends~
140
140
  email:
141
- - ^_^@mispy.me
141
+ - "^_^@mispy.me"
142
142
  executables:
143
143
  - ebooks
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
- - .gitignore
147
+ - ".gitignore"
148
148
  - Gemfile
149
149
  - LICENSE
150
150
  - README.md
@@ -182,17 +182,17 @@ require_paths:
182
182
  - lib
183
183
  required_ruby_version: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - ! '>='
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.2.1
195
+ rubygems_version: 2.2.2
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Markov chains for all your friends~