elliottcable-slack 0
Sign up to get free protection for your applications and to get access to all the features.
- data/.manifest +4 -0
- data/README.markdown +5 -0
- data/Rakefile.rb +89 -0
- data/lib/slack.rb +91 -0
- data/slack.gemspec +46 -0
- metadata +117 -0
data/.manifest
ADDED
data/README.markdown
ADDED
data/Rakefile.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
($:.unshift File.expand_path(File.join( File.dirname(__FILE__), 'lib' ))).uniq!
|
2
|
+
require 'slack'
|
3
|
+
|
4
|
+
# =======================
|
5
|
+
# = Gem packaging tasks =
|
6
|
+
# =======================
|
7
|
+
begin
|
8
|
+
require 'echoe'
|
9
|
+
|
10
|
+
task :install => :'package:install'
|
11
|
+
task :package => :'package:package'
|
12
|
+
task :manifest => :'package:manifest'
|
13
|
+
namespace :package do
|
14
|
+
Echoe.new('slack', Slack::Version) do |g|
|
15
|
+
g.project = 'speck'
|
16
|
+
g.author = ['elliottcable']
|
17
|
+
g.email = ['Slack@elliottcable.com']
|
18
|
+
g.summary = "Magic makes everybody's life a little easier, no?"
|
19
|
+
g.url = 'http://github.com/elliottcable/Slack'
|
20
|
+
g.runtime_dependencies = ['speck']
|
21
|
+
g.development_dependencies = ['echoe >= 3.0.2', 'speck', 'yard', 'maruku']
|
22
|
+
g.manifest_name = '.manifest'
|
23
|
+
g.retain_gemspec = true
|
24
|
+
g.rakefile_name = 'Rakefile.rb'
|
25
|
+
g.ignore_pattern = /^\.git\/|^meta\/|\.gemspec/
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
rescue LoadError
|
30
|
+
desc 'You need the `echoe` gem to package Slack'
|
31
|
+
task :package
|
32
|
+
end
|
33
|
+
|
34
|
+
# ===============
|
35
|
+
# = Speck tasks =
|
36
|
+
# ===============
|
37
|
+
begin
|
38
|
+
require 'speck'
|
39
|
+
|
40
|
+
task :default => :'speck:run'
|
41
|
+
task :speck => :'speck:run'
|
42
|
+
namespace :speck do
|
43
|
+
load 'speck.rake'
|
44
|
+
end
|
45
|
+
|
46
|
+
rescue LoadError
|
47
|
+
desc 'You need the `speck` gem to run specks'
|
48
|
+
task :speck
|
49
|
+
end
|
50
|
+
|
51
|
+
# =======================
|
52
|
+
# = Documentation tasks =
|
53
|
+
# =======================
|
54
|
+
begin
|
55
|
+
require 'yard'
|
56
|
+
require 'yard/rake/yardoc_task'
|
57
|
+
|
58
|
+
task :documentation => :'documentation:generate'
|
59
|
+
namespace :documentation do
|
60
|
+
YARD::Rake::YardocTask.new :generate do |t|
|
61
|
+
t.files = ['lib/**/*.rb']
|
62
|
+
t.options = ['--output-dir', File.join('meta', 'documentation'),
|
63
|
+
'--readme', 'README.markdown',
|
64
|
+
'--markup', 'markdown', '--markup-provider', 'maruku']
|
65
|
+
end
|
66
|
+
|
67
|
+
YARD::Rake::YardocTask.new :dotyardoc do |t|
|
68
|
+
t.files = ['lib/**/*.rb']
|
69
|
+
t.options = ['--no-output',
|
70
|
+
'--readme', 'README.markdown',
|
71
|
+
'--markup', 'markdown', '--markup-provider', 'maruku']
|
72
|
+
end
|
73
|
+
|
74
|
+
task :open do
|
75
|
+
system 'open ' + File.join('meta', 'documentation', 'index.html') if RUBY_PLATFORM['darwin']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
rescue LoadError
|
80
|
+
desc 'You need the `yard` and `maruku` gems to generate documentation'
|
81
|
+
task :documentation
|
82
|
+
end
|
83
|
+
|
84
|
+
desc 'Check everything over before commiting'
|
85
|
+
task :aok => [:'documentation:generate', :'documentation:open',
|
86
|
+
:'package:manifest',
|
87
|
+
:'speck:run']
|
88
|
+
|
89
|
+
task :ci => [:'documentation:generate', :'speck:run']
|
data/lib/slack.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
##
|
2
|
+
# Methods in `Slack` are provided with the purpose of making it simpler (and
|
3
|
+
# sexier!) to create `Speck::Check`s.
|
4
|
+
module Slack
|
5
|
+
Version = 0
|
6
|
+
|
7
|
+
##
|
8
|
+
# These modules (named after the Class they are intended to be mixed into)
|
9
|
+
# provide convenience methods on those classes.
|
10
|
+
module Mixins
|
11
|
+
|
12
|
+
module Object
|
13
|
+
##
|
14
|
+
# This method creates a new `Speck::Check` utilizing a passed block.
|
15
|
+
#
|
16
|
+
# It expects a block (returning `true` or `false`) to be passed. The
|
17
|
+
# block will be passed the receiver, so you can run comparators on it,
|
18
|
+
# or whatever else you like.
|
19
|
+
#
|
20
|
+
# The intention is that this method be used to quickly check that
|
21
|
+
# particular methods return values as expected. For instance, the
|
22
|
+
# following would be used to check that MyClass#initialize properly
|
23
|
+
# assigns its argument to the `thingie` attribute:
|
24
|
+
#
|
25
|
+
# MyClass.new(an_object).check {|my| my.thingie == an_object }
|
26
|
+
#
|
27
|
+
# The new `Check` instance is automatically documented with the contents
|
28
|
+
# of the line of Ruby that produced the receiver of this method.
|
29
|
+
# --
|
30
|
+
# TODO: Speck Object#check
|
31
|
+
# TODO: Remove the `->{self}` functionality, and implement Mixins::Truthy
|
32
|
+
# for TrueClass/FalseClass/NilClass
|
33
|
+
def check &check
|
34
|
+
check = ->(_){self} unless block_given?
|
35
|
+
|
36
|
+
# TODO: Should we allow specks in the root environment? Could be useful
|
37
|
+
# for quick checks…
|
38
|
+
raise Exception::NoEnvironment unless Speck.current
|
39
|
+
|
40
|
+
# TODO: Implement documenting the `Check` using a preceding comment,
|
41
|
+
# if present.
|
42
|
+
# TODO: Move this into its own methods deeper in the library, and
|
43
|
+
# clean it up.
|
44
|
+
file, line, _ = Kernel::caller.first.split(':')
|
45
|
+
source = File.open(file).readlines[line.to_i - 1]
|
46
|
+
source.strip!
|
47
|
+
source = source.partition(".check").first
|
48
|
+
# TODO: Get rid of the "(…)" around the resulting string.
|
49
|
+
# TODO: Implement multi–line source documenting.
|
50
|
+
|
51
|
+
Speck::Check.new(->(){ check[self] }, source)
|
52
|
+
.tap {|check| Speck.current.checks << check }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
::Object.send :include, Slack::Mixins::Object
|
56
|
+
|
57
|
+
module Proc
|
58
|
+
##
|
59
|
+
# This method creates a new `Speck::Check` initialized to pass if the
|
60
|
+
# receiver can be executed without `exception` being raised, or fail if
|
61
|
+
# the receiver raises `exception` when raised.
|
62
|
+
#
|
63
|
+
# The passed exception object will be `rescue`d from within the block,
|
64
|
+
# but any other exception raised by the block will not be caught.
|
65
|
+
def check_exception exception = Exception
|
66
|
+
# TODO: Should we allow specks in the root environment? Could be useful
|
67
|
+
# for quick checks…
|
68
|
+
raise Exception::NoEnvironment unless Speck.current
|
69
|
+
|
70
|
+
file, line, _ = Kernel::caller.first.split(':')
|
71
|
+
source = File.open(file).readlines[line.to_i - 1]
|
72
|
+
source.strip!
|
73
|
+
source = source.partition(".check_exception").first
|
74
|
+
# TODO: Get rid of the "->{…}" around the resulting string.
|
75
|
+
|
76
|
+
Speck::Check.new(->(){
|
77
|
+
begin
|
78
|
+
self.call
|
79
|
+
rescue exception
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
return false
|
83
|
+
}, source)
|
84
|
+
.tap {|check| Speck.current.checks << check }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
::Proc.send :include, Slack::Mixins::Proc
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
data/slack.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{slack}
|
5
|
+
s.version = "0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["elliottcable"]
|
9
|
+
s.date = %q{2009-08-04}
|
10
|
+
s.description = %q{Magic makes everybody's life a little easier, no?}
|
11
|
+
s.email = ["Slack@elliottcable.com"]
|
12
|
+
s.extra_rdoc_files = ["lib/slack.rb", "README.markdown"]
|
13
|
+
s.files = ["lib/slack.rb", "Rakefile.rb", "README.markdown", ".manifest", "slack.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/elliottcable/Slack}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Slack", "--main", "README.markdown"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{speck}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Magic makes everybody's life a little easier, no?}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_runtime_dependency(%q<speck>, [">= 0"])
|
28
|
+
s.add_development_dependency(%q<echoe>, [">= 0", "= 3.0.2"])
|
29
|
+
s.add_development_dependency(%q<speck>, [">= 0"])
|
30
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
31
|
+
s.add_development_dependency(%q<maruku>, [">= 0"])
|
32
|
+
else
|
33
|
+
s.add_dependency(%q<speck>, [">= 0"])
|
34
|
+
s.add_dependency(%q<echoe>, [">= 0", "= 3.0.2"])
|
35
|
+
s.add_dependency(%q<speck>, [">= 0"])
|
36
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
37
|
+
s.add_dependency(%q<maruku>, [">= 0"])
|
38
|
+
end
|
39
|
+
else
|
40
|
+
s.add_dependency(%q<speck>, [">= 0"])
|
41
|
+
s.add_dependency(%q<echoe>, [">= 0", "= 3.0.2"])
|
42
|
+
s.add_dependency(%q<speck>, [">= 0"])
|
43
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
44
|
+
s.add_dependency(%q<maruku>, [">= 0"])
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elliottcable-slack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- elliottcable
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-04 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: speck
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: echoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
- - "="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.0.2
|
37
|
+
version:
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: speck
|
40
|
+
type: :development
|
41
|
+
version_requirement:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: yard
|
50
|
+
type: :development
|
51
|
+
version_requirement:
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: maruku
|
60
|
+
type: :development
|
61
|
+
version_requirement:
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
description: Magic makes everybody's life a little easier, no?
|
69
|
+
email:
|
70
|
+
- Slack@elliottcable.com
|
71
|
+
executables: []
|
72
|
+
|
73
|
+
extensions: []
|
74
|
+
|
75
|
+
extra_rdoc_files:
|
76
|
+
- lib/slack.rb
|
77
|
+
- README.markdown
|
78
|
+
files:
|
79
|
+
- lib/slack.rb
|
80
|
+
- Rakefile.rb
|
81
|
+
- README.markdown
|
82
|
+
- .manifest
|
83
|
+
- slack.gemspec
|
84
|
+
has_rdoc: true
|
85
|
+
homepage: http://github.com/elliottcable/Slack
|
86
|
+
licenses:
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options:
|
89
|
+
- --line-numbers
|
90
|
+
- --inline-source
|
91
|
+
- --title
|
92
|
+
- Slack
|
93
|
+
- --main
|
94
|
+
- README.markdown
|
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
|
+
version:
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: "1.2"
|
108
|
+
version:
|
109
|
+
requirements: []
|
110
|
+
|
111
|
+
rubyforge_project: speck
|
112
|
+
rubygems_version: 1.3.5
|
113
|
+
signing_key:
|
114
|
+
specification_version: 2
|
115
|
+
summary: Magic makes everybody's life a little easier, no?
|
116
|
+
test_files: []
|
117
|
+
|