atheme 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f15c506bebeb4f29c62aaf132ff7e65ae447aac7
4
+ data.tar.gz: edbbf9f64e68e79c9009988e160ab607ce7d525a
5
+ SHA512:
6
+ metadata.gz: a1726985fc6177a45ea570b1b31e2a3fd718fcaf13036b254485ee18826c8830babb021e561b36ff0a5293d2b1b11d641ed53aa8f9f24c32128c049afde016b8
7
+ data.tar.gz: de2c423a8baf8891b738da732bcbba266b76302ef87a7077d91c06bc8c4ea8fafafcf6c78e4184c63cf643afa69ea4abd5872ad25ec5f1794f26ef495ad134af
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ spec/config.yml
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in atheme.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 James Newton and Robert Babcock
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Atheme Ruby
2
+
3
+ A ruby way to access the [Atheme IRC Services](http://www.atheme.net) XMLRPC interface.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'atheme'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install atheme
18
+
19
+ ## Usage
20
+
21
+ ### Requirements
22
+
23
+ You need to be using [Atheme IRC Services](http://www.atheme.net) with httpd and XMLRPC enabled.
24
+
25
+ ### Configuration
26
+
27
+ ```ruby
28
+ Atheme.configure do |config|
29
+ config.url = 'http://example.com'
30
+ config.port = 9876
31
+ end
32
+ ```
33
+
34
+ ### Authentication
35
+
36
+ ```ruby
37
+ cookie = Atheme.login('nickname', 'password') # Returns an authcookie
38
+
39
+ Atheme.set_user(cookie, 'nickname', 'ip.add.re.ss') # Sets the users info for commands
40
+ ```
41
+
42
+ ### Services commands
43
+
44
+ ```ruby
45
+ Atheme::ChanServ.info '#channel'
46
+ Atheme::NickServ.set 'email', 'james@example.com'
47
+ ```
48
+
49
+ Any command can be used that the user has access to use.
50
+
51
+ Command format: `Atheme::ServiceName.command 'param', 'param', ...`
52
+
53
+ To see services supported [go here](https://github.com/zaphyous/atheme-ruby/tree/develop/lib/atheme/services).
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b feature/my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin feature/my-new-feature`)
61
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/atheme.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 'atheme/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'atheme'
8
+ spec.version = Atheme::VERSION
9
+ spec.authors = ['James Newton', 'Robert Babcock']
10
+ spec.email = ['james@Zaphyous.com', 'robert@Zaphyous.com']
11
+ spec.description = %q{A ruby wrapper around the Atheme IRC Services XMLRPC interface}
12
+ spec.summary = %q{atheme-ruby is an easy way to integrate your ruby application with the Atheme IRC Services XMLRPC interface}
13
+ spec.homepage = 'https://github.com/zaphyous/atheme'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
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 = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'guard-rspec'
25
+ spec.add_development_dependency 'pry'
26
+ spec.add_development_dependency 'rb-fsevent'
27
+ end
@@ -0,0 +1,11 @@
1
+ module Atheme::Authenticate
2
+ attr_accessor :user
3
+
4
+ def login(username, password)
5
+ call('atheme.login', username, password)
6
+ end
7
+
8
+ def logout(token, username)
9
+ call('atheme.logout', token, username)
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Atheme::Configuration
2
+ VALID_CONFIG_OPTIONS = [:url, :port].freeze
3
+
4
+ attr_accessor *VALID_CONFIG_OPTIONS
5
+
6
+ def configure
7
+ yield self
8
+ end
9
+
10
+ def options
11
+ VALID_CONFIG_OPTIONS.inject({}) do |option, key|
12
+ option.merge!(key => send(key))
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ class Atheme::ObjectifiedHash
2
+ def initialize(hash)
3
+ @data = hash.inject({}) do |data, (key, value)|
4
+ value = Atheme::ObjectifiedHash.new(value) if value.is_a? Hash
5
+
6
+ data[key.to_s] = value
7
+ data
8
+ end
9
+ end
10
+
11
+ def method_missing(key)
12
+ @data.key?(key.to_s) ? @data[key.to_s] : nil
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class Atheme::Service
2
+ def self.inherited(base)
3
+ Atheme::SERVICES << base.name.gsub('Atheme::', '')
4
+ end
5
+
6
+ def self.method_missing(method, *args, &block)
7
+ Atheme.call('atheme.command', Atheme.user.cookie, Atheme.user.username, Atheme.user.ip, self.name.gsub('Atheme::', ''), method, *args)
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::ALIS < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::ChanServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::GameServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::Global < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::GroupServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::HelpServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::HostServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::InfoServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::MemoServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::NickServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::OperServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::RPGServ < Atheme::Service
2
+ end
@@ -0,0 +1,2 @@
1
+ class Atheme::StatServ < Atheme::Service
2
+ end
@@ -0,0 +1,3 @@
1
+ module Atheme
2
+ VERSION = '0.0.1'
3
+ end
data/lib/atheme.rb ADDED
@@ -0,0 +1,29 @@
1
+ module Atheme
2
+ SERVICES = []
3
+ end
4
+
5
+ require 'xmlrpc/client'
6
+ require 'atheme/version'
7
+ require 'atheme/configuration'
8
+ require 'atheme/authenticate'
9
+ require 'atheme/service'
10
+ require 'atheme/objectified_hash'
11
+
12
+ Dir[File.expand_path('../atheme/services/*.rb', __FILE__)].each { |file| require file }
13
+
14
+ module Atheme
15
+ extend Configuration
16
+ extend Authenticate
17
+
18
+ def self.server
19
+ XMLRPC::Client.new2("#{Atheme.url}:#{Atheme.port}/xmlrpc")
20
+ end
21
+
22
+ def self.call(*args)
23
+ server.call(*args)
24
+ end
25
+
26
+ def self.set_user(cookie, username, ip)
27
+ self.user = Atheme::ObjectifiedHash.new({ cookie: cookie, username: username, ip: ip })
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ # Change this to your testing services xmlrpc information
2
+
3
+ url: http://example.com
4
+ port: 1234
5
+
6
+ nick: a_nick_that_exists
7
+ password: the_nicks_password
8
+ ip: 127.0.0.1
9
+
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Atheme::Authenticate do
4
+ it 'should get a cookie when logging in' do
5
+ expect(Atheme.login(atheme_config['nick'], atheme_config['password'])).to match(/([a-z]){20}/)
6
+ end
7
+
8
+ it 'should get a XMLRPC::FaultException when incorrect login information is provided' do
9
+ expect { Atheme.login(atheme_config['nick'], 'bad-password') }.to raise_error XMLRPC::FaultException
10
+ end
11
+
12
+ it 'should remember a user when set' do
13
+ cookie = Atheme.login(atheme_config['nick'], atheme_config['password'])
14
+
15
+ Atheme.set_user(cookie, atheme_config['nick'], atheme_config['ip'])
16
+
17
+ expect(Atheme.user.cookie).to eql cookie
18
+ expect(Atheme.user.username).to eql atheme_config['nick']
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Atheme::Configuration do
4
+ it 'should have a port' do
5
+ expect(Atheme.port).to eql atheme_config['port']
6
+ expect(Atheme.options[:port]).to eql atheme_config['port']
7
+ end
8
+
9
+ it 'should have a url' do
10
+ expect(Atheme.url).to eql atheme_config['url']
11
+ expect(Atheme.options[:url]).to eql atheme_config['url']
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Atheme::Service' do
4
+ it 'should have services' do
5
+ expect(Atheme::SERVICES.count).to be > 0
6
+ end
7
+
8
+ it 'should be able to query services' do
9
+ authenticate
10
+
11
+ expect(Atheme::ChanServ.help).to be_true
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ require 'rspec'
2
+ require 'pry'
3
+ require 'atheme'
4
+
5
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |file| require file }
6
+
7
+ def atheme_config
8
+ YAML.load_file(File.expand_path('../config.yml', __FILE__))
9
+ end
10
+
11
+ def configure_atheme
12
+ Atheme.configure do |config|
13
+ config.port = atheme_config['port']
14
+ config.url = atheme_config['url']
15
+ end
16
+ end
17
+
18
+ def authenticate
19
+ cookie = Atheme.login(atheme_config['nick'], atheme_config['password'])
20
+
21
+ Atheme.set_user(cookie, atheme_config['nick'], atheme_config['ip'])
22
+ end
23
+
24
+ RSpec.configure do |config|
25
+ config.before(:each) { configure_atheme }
26
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atheme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - James Newton
8
+ - Robert Babcock
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: guard-rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: pry
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rb-fsevent
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: A ruby wrapper around the Atheme IRC Services XMLRPC interface
99
+ email:
100
+ - james@Zaphyous.com
101
+ - robert@Zaphyous.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - .gitignore
107
+ - .rspec
108
+ - Gemfile
109
+ - Guardfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - atheme.gemspec
114
+ - lib/atheme.rb
115
+ - lib/atheme/authenticate.rb
116
+ - lib/atheme/configuration.rb
117
+ - lib/atheme/objectified_hash.rb
118
+ - lib/atheme/service.rb
119
+ - lib/atheme/services/alis.rb
120
+ - lib/atheme/services/chanserv.rb
121
+ - lib/atheme/services/gameserv.rb
122
+ - lib/atheme/services/global.rb
123
+ - lib/atheme/services/groupserv.rb
124
+ - lib/atheme/services/helpserv.rb
125
+ - lib/atheme/services/hostserv.rb
126
+ - lib/atheme/services/infoserv.rb
127
+ - lib/atheme/services/memoserv.rb
128
+ - lib/atheme/services/nickserv.rb
129
+ - lib/atheme/services/operserv.rb
130
+ - lib/atheme/services/rpgserv.rb
131
+ - lib/atheme/services/statserv.rb
132
+ - lib/atheme/version.rb
133
+ - spec/config.yml.example
134
+ - spec/lib/authenticate_spec.rb
135
+ - spec/lib/configuration_spec.rb
136
+ - spec/lib/service_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: https://github.com/zaphyous/atheme
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.0.3
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: atheme-ruby is an easy way to integrate your ruby application with the Atheme
162
+ IRC Services XMLRPC interface
163
+ test_files:
164
+ - spec/config.yml.example
165
+ - spec/lib/authenticate_spec.rb
166
+ - spec/lib/configuration_spec.rb
167
+ - spec/lib/service_spec.rb
168
+ - spec/spec_helper.rb