boty 0.2.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9959fb9fd1218a64dc671442aef786311c03f10
4
- data.tar.gz: bad2921130ae92b79ef775529861fb4c6a204cdf
3
+ metadata.gz: 8c83ca2e3fc9c590a8a9fe3ff8e69d0b86942816
4
+ data.tar.gz: acd0044347f558d967b3ed6689307faea2214a56
5
5
  SHA512:
6
- metadata.gz: 0052d938808382105c9f4b2e242ca357a01cb7e83c5eead10f05a3225b6a021cf08c24d0de7dfe7d69b3945015f1595ff20291dbc33d41b1e93b758965023fb5
7
- data.tar.gz: 2b31a41cb5443d4693728b2a8689b321371424c7a90b84c058a721a545c2cdf17a1feb952e2404b0f302fb403bc13936e3b8f1a957e3a6d4bfc715d7318782d3
6
+ metadata.gz: 5d300819f8993701ae24c84faaa9a07076be9d0153550e492042bd336e475d630b83019e7258e002a624b88db55ee47d85476b2dc6848ef018a8f473d4435ea9
7
+ data.tar.gz: 6412d730347e2c289ef437134bfdf024d78641aa25911d3555623aec7d6965358925f017fa5871fab67d234493a0b05382b084c20cf9be7c0bac2f4f2e8d382c
@@ -2,8 +2,9 @@ language: ruby
2
2
  rvm:
3
3
  - "2.2.0"
4
4
  - "2.2.3"
5
- #matrix:
6
- # include:
7
- # - rvm: rbx
8
- # gemfile: gemfiles/Gemfile.rbx
5
+ - "2.3.0"
6
+ matrix:
7
+ include:
8
+ - rvm: rbx-2
9
+ gemfile: gemfiles/Gemfile.rbx
9
10
  script: bundle exec rspec --require=spec_helper
@@ -0,0 +1,9 @@
1
+ # Change Log
2
+
3
+ ## [Unreleased] - [1.0.0] -
4
+ ### Added
5
+ - Generator to create a new bot project from the command line.
6
+ - Script api to create custom bot commands.
7
+ - Working bot (on `bin/bot`) for integration tests and experiments.
8
+ - Documentation for the basic api.
9
+ - Rubinius support.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boty (0.2.0)
4
+ boty (1.0.0)
5
5
  eventmachine
6
6
  faraday
7
7
  faye-websocket
@@ -74,4 +74,4 @@ DEPENDENCIES
74
74
  yard
75
75
 
76
76
  BUNDLED WITH
77
- 1.10.6
77
+ 1.11.2
data/README.md CHANGED
@@ -743,15 +743,21 @@ To install this gem onto your local machine, run `bundle exec rake install`.
743
743
  ### The local ./bin/bot
744
744
 
745
745
  The project have a `./bin/bot` executable that should be the product of
746
- compiling the `template/project/bot.tt` erb file.
747
- This is an easy way to just run the bot using the same logic that a project
748
- generated by `bot new` will use to run the bot.
746
+ compiling the `template/project/bot.tt` erb file. This is an easy way to just
747
+ run the bot using the same logic that a project generated by `bot new` will use.
748
+
749
749
  It's highly recomendable that you test your changes using this approach before
750
750
  submit a `PR` or generate a new release. =)
751
751
 
752
+ #### Compiling the ./bin/bot
753
+
754
+ There is a `bot:compile` rake task that compiles the template right into the
755
+ `bin` direcotry and make it executable (with `chmod +x`).
756
+
752
757
  ### Code guidelines
753
758
 
754
- **todo: add some**
759
+ Just make sure to run `bundle exec rubocop` before submit any `PR`, good coding!
760
+ :D
755
761
 
756
762
  ## Contributing<a name="contributing" />
757
763
 
data/Rakefile CHANGED
@@ -8,3 +8,6 @@ task default: :spec
8
8
  YARD::Rake::YardocTask.new do |t|
9
9
  t.options = ["-odocs/api"]
10
10
  end
11
+
12
+ tasks_path = Dir.glob("#{File.expand_path("../lib/tasks", __FILE__)}/**/*.rake")
13
+ import tasks_path.join ","
data/bin/bot CHANGED
@@ -4,8 +4,8 @@ require "./lib/boty"
4
4
  Boty.locale = ARGV.pop || :en
5
5
 
6
6
  Boty::Logger.adapter = Boty::Logger::Multi.new([
7
- Logger.new(STDOUT),
8
- Logger.new("log/output.log", "daily")
7
+ ::Logger.new(STDOUT),
8
+ ::Logger.new("log/output.log", "daily")
9
9
  ])
10
10
 
11
11
  session = Boty::Session.new
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: "../"
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec path: "../"
4
4
 
@@ -0,0 +1,79 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ boty (0.2.0)
5
+ eventmachine
6
+ faraday
7
+ faye-websocket
8
+ i18n
9
+ thor
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ ast (2.2.0)
15
+ astrolabe (1.3.1)
16
+ parser (~> 2.2)
17
+ diff-lcs (1.2.5)
18
+ dotenv (2.0.2)
19
+ eventmachine (1.0.8)
20
+ fakefs (0.6.7)
21
+ faraday (0.9.2)
22
+ multipart-post (>= 1.2, < 3)
23
+ faye-websocket (0.10.2)
24
+ eventmachine (>= 0.12.0)
25
+ websocket-driver (>= 0.5.1)
26
+ i18n (0.7.0)
27
+ multipart-post (2.0.0)
28
+ parser (2.2.3.0)
29
+ ast (>= 1.1, < 3.0)
30
+ powerpack (0.1.1)
31
+ rainbow (2.0.0)
32
+ rake (10.4.2)
33
+ rspec (3.4.0)
34
+ rspec-core (~> 3.4.0)
35
+ rspec-expectations (~> 3.4.0)
36
+ rspec-mocks (~> 3.4.0)
37
+ rspec-core (3.4.1)
38
+ rspec-support (~> 3.4.0)
39
+ rspec-expectations (3.4.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.4.0)
42
+ rspec-mocks (3.4.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.4.0)
45
+ rspec-support (3.4.1)
46
+ rubinius-compiler (2.3.1)
47
+ rubinius-debugger (2.2.1)
48
+ rubocop (0.35.1)
49
+ astrolabe (~> 1.3)
50
+ parser (>= 2.2.3.0, < 3.0)
51
+ powerpack (~> 0.1)
52
+ rainbow (>= 1.99.1, < 3.0)
53
+ ruby-progressbar (~> 1.7)
54
+ tins (<= 1.6.0)
55
+ ruby-progressbar (1.7.5)
56
+ thor (0.19.1)
57
+ tins (1.6.0)
58
+ websocket-driver (0.6.3)
59
+ websocket-extensions (>= 0.1.0)
60
+ websocket-extensions (0.1.2)
61
+ yard (0.8.7.6)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ boty!
68
+ bundler (~> 1.10)
69
+ dotenv
70
+ fakefs
71
+ rake (~> 10.0)
72
+ rspec
73
+ rubinius-compiler
74
+ rubinius-debugger
75
+ rubocop
76
+ yard
77
+
78
+ BUNDLED WITH
79
+ 1.11.2
@@ -9,6 +9,14 @@ module Boty
9
9
 
10
10
  source_root File.expand_path("../../../template", __FILE__)
11
11
 
12
+ no_commands do
13
+ def compile(bot_name = "lib/boty")
14
+ @bot_name = "lib/boty"
15
+ template "project/bot.tt", "bin/bot"
16
+ run "chmod +x bin/bot"
17
+ end
18
+ end
19
+
12
20
  desc "new [BOT_NAME]",
13
21
  "Creates a BOT_NAME dir with your new bot structure."
14
22
  def new(bot_name)
@@ -1,3 +1,3 @@
1
1
  module Boty
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,8 @@
1
+ require "boty/cli"
2
+
3
+ namespace :bot do
4
+ desc "Compiles the template/project/bot.tt into bin/bot and chmod +x on it."
5
+ task :compile do
6
+ Boty::CLI.new.compile
7
+ end
8
+ end
@@ -10,17 +10,7 @@ module Boty
10
10
  FileUtils.chdir "tmp"
11
11
  end
12
12
 
13
- before do
14
- FileUtils.rm_rf "nice_bot" if Dir.exist? "nice_bot"
15
-
16
- allow(cli).to receive(:ask)
17
- .and_return ENV["SLACK_COMPANY"], ENV["SLACK_BOT_API_TOKEN"]
18
-
19
- allow(cli).to receive(:run)
20
- end
21
-
22
13
  after(:all) do
23
- FileUtils.rm_rf "nice_bot" if Dir.exist? "nice_bot"
24
14
  FileUtils.chdir "../"
25
15
  end
26
16
 
@@ -31,6 +21,19 @@ module Boty
31
21
  end
32
22
  end
33
23
 
24
+ before do
25
+ FileUtils.rm_rf "nice_bot" if Dir.exist? "nice_bot"
26
+
27
+ allow(cli).to receive(:ask)
28
+ .and_return ENV["SLACK_COMPANY"], ENV["SLACK_BOT_API_TOKEN"]
29
+
30
+ allow(cli).to receive(:run)
31
+ end
32
+
33
+ after(:all) do
34
+ FileUtils.rm_rf "nice_bot"
35
+ end
36
+
34
37
  it "creates a directory named after the PROJECT" do
35
38
  expect { create_nice_bot }.to create_directory "nice_bot"
36
39
  end
@@ -83,5 +86,21 @@ module Boty
83
86
  create_nice_bot
84
87
  end
85
88
  end
89
+
90
+ describe "#compile" do
91
+ before do
92
+ FileUtils.rm_rf "bin"
93
+ end
94
+
95
+ it "compiles the project/bot.tt onto bin/bot" do
96
+ expect(cli).to run "chmod +x bin/bot"
97
+
98
+ expect {
99
+ capture(:stdout) do
100
+ cli.compile
101
+ end
102
+ }.to create_file "bin/bot"
103
+ end
104
+ end
86
105
  end
87
106
  end
@@ -2,8 +2,20 @@ require "spec_helper"
2
2
 
3
3
  module Boty
4
4
  RSpec.describe "happy pathy with integration", :project, :session do
5
+ Boty::Logger.adapter = Boty::Logger::Memory.new
6
+
7
+ def bot_with_memory_logger(bot_code)
8
+ original_logger = %{Boty::Logger.adapter = Boty::Logger::Multi.new([
9
+ ::Logger.new(STDOUT),
10
+ ::Logger.new("log/output.log", "daily")
11
+ ])}
12
+ memory_logger = %{Boty::Logger.adapter = Boty::Logger::Memory.new}
13
+
14
+ bot_code.dup.tap { |code| code.sub! original_logger, memory_logger }
15
+ end
16
+
5
17
  def start_session(only_knows: nil)
6
- executable_bot = File.read "bot"
18
+ executable_bot = bot_with_memory_logger File.read("bot")
7
19
  @session = instance_eval executable_bot, "bot", 1
8
20
  return unless only_knows
9
21
 
@@ -3,11 +3,17 @@ require "./<%= bot_name %>"
3
3
 
4
4
  Boty.locale = ARGV.pop || :en
5
5
 
6
+ Boty::Logger.adapter = Boty::Logger::Multi.new([
7
+ ::Logger.new(STDOUT),
8
+ ::Logger.new("log/output.log", "daily")
9
+ ])
10
+
6
11
  session = Boty::Session.new
7
12
  session.start do
8
13
  desc name, I18n.t("template.presence", bot_name: name)
9
14
  hear(/#{name}/i) do
10
15
  next if message_from_me?
16
+ logger.debug "saying hello"
11
17
  say I18n.t "template.hello", user_name: user.name
12
18
  end
13
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Valeriano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-27 00:00:00.000000000 Z
11
+ date: 2015-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -192,6 +192,7 @@ files:
192
192
  - ".gitignore"
193
193
  - ".rubocop.yml"
194
194
  - ".travis.yml"
195
+ - CHANGELOG.md
195
196
  - CODE_OF_CONDUCT.md
196
197
  - Gemfile
197
198
  - Gemfile.lock
@@ -207,7 +208,9 @@ files:
207
208
  - docs/images/readme-02-screen-integration.png
208
209
  - docs/images/readme-03-screen-integration.png
209
210
  - exe/boty
211
+ - gemfiles/Gemfile.jruby
210
212
  - gemfiles/Gemfile.rbx
213
+ - gemfiles/Gemfile.rbx.lock
211
214
  - lib/boty.rb
212
215
  - lib/boty/action.rb
213
216
  - lib/boty/action_description.rb
@@ -233,6 +236,7 @@ files:
233
236
  - lib/boty/slack/users.rb
234
237
  - lib/boty/version.rb
235
238
  - lib/tasks/.keep
239
+ - lib/tasks/bot/compile.rake
236
240
  - locale/en.yml
237
241
  - locale/pt-br.yml
238
242
  - log/.keep
@@ -306,7 +310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
306
310
  version: '0'
307
311
  requirements: []
308
312
  rubyforge_project:
309
- rubygems_version: 2.4.5.1
313
+ rubygems_version: 2.5.1
310
314
  signing_key:
311
315
  specification_version: 4
312
316
  summary: Boty is a pretty bot specially tailored for Slack.