cinch-magic 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
data/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Cinch::Plugins::Magic
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/cinch-magic.png)](http://badge.fury.io/rb/cinch-magic)
4
+ [![Dependency Status](https://gemnasium.com/bhaberer/cinch-magic.png)](https://gemnasium.com/bhaberer/cinch-magic)
5
+ [![Build Status](https://travis-ci.org/bhaberer/cinch-magic.png?branch=master)](https://travis-ci.org/bhaberer/cinch-magic)
6
+ [![Coverage Status](https://coveralls.io/repos/bhaberer/cinch-magic/badge.png?branch=master)](https://coveralls.io/r/bhaberer/cinch-magic?branch=master)
7
+ [![Code Climate](https://codeclimate.com/github/bhaberer/cinch-magic.png)](https://codeclimate.com/github/bhaberer/cinch-magic)
8
+
3
9
  Just a simple plugin that looks up card info.
4
10
 
5
11
  ## Installation
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -17,6 +17,12 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency 'cinch-toolbox'
21
- gem.add_dependency 'cinch-cooldown'
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'coveralls'
23
+
24
+ gem.add_dependency 'cinch', '~> 2.0.5'
25
+ gem.add_dependency 'cinch-test', '~> 0.0.3'
26
+ gem.add_dependency 'cinch-toolbox', '~> 1.0.2'
27
+ gem.add_dependency 'cinch-cooldown', '~> 1.0.0'
22
28
  end
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- require 'cinch-toolbox'
2
+ require 'cinch'
3
+ require 'cinch/toolbox'
3
4
  require 'cinch-cooldown'
4
5
 
5
6
  module Cinch::Plugins
@@ -35,11 +36,11 @@ module Cinch::Plugins
35
36
  end
36
37
 
37
38
  def get_card_info(data)
38
- text = data.match(/<p[^>]*>([^<]+)<\/p>/)[1]
39
+ text = data[/<p[^>]*>([^<]+)<\/p>/, 1]
39
40
 
40
41
  # Replace Newlines, unicode lines, total mana, and large spaces.
41
42
  text = text.gsub(/\n/, '')
42
- text = text.gsub(/—/, '·')
43
+ text = text.gsub(/\s—/, ', ')
43
44
  text = text.gsub(/\s\(\d*\)/, '')
44
45
  text = text.gsub(/\s{2,}/, ' ')
45
46
 
@@ -52,7 +53,7 @@ module Cinch::Plugins
52
53
  end
53
54
 
54
55
  def get_card_name(data)
55
- return data.match(/<a href=[^>]*>([^<]+)<\/a>/)[1]
56
+ return data[/<a href=[^>]*>([^<]+)<\/a>/, 1]
56
57
  rescue
57
58
  debug "Error finding this card's name"
58
59
  end
@@ -70,7 +71,6 @@ module Cinch::Plugins
70
71
  end
71
72
 
72
73
  def get_card_data(term)
73
- debug "#{term}" if term.nil?
74
74
  # URI Encode the term and build the URL
75
75
  term = URI.escape("!#{term}", Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
76
76
  url = "http://magiccards.info/query?q=#{term}"
@@ -80,12 +80,11 @@ module Cinch::Plugins
80
80
 
81
81
  # Grab the html block because magiccards.info fucking loves tables
82
82
  # and hates helpful ids and classnames
83
- begin
84
- return Cinch::Toolbox.get_html_element(url, '//table[3]/tr/td[2]', 'xpath').to_html
85
- rescue
86
- debug "Error looking up card: #{term}"
87
- return nil
88
- end
83
+ return Cinch::Toolbox.get_html_element(url, '//table[3]/tr/td[2]', :xpath_full)
84
+
85
+ rescue
86
+ debug "Error looking up card: #{term}"
87
+ return nil
89
88
  end
90
89
  end
91
90
  end
@@ -1,7 +1,7 @@
1
1
  module Cinch
2
2
  module Plugins
3
3
  class Magic
4
- VERSION = "0.0.1"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cinch::Plugins::Magic do
4
+
5
+ include Cinch::Test
6
+
7
+ before(:each) do
8
+ @bot = make_bot(Cinch::Plugins::Magic)
9
+ end
10
+
11
+ it 'should allow users to lookup cards' do
12
+ get_replies(make_message(@bot, '!mtg forest')).first.
13
+ should include "[Magic] Forest [Basic Land, Forest] - ({T}: Add {G} to your mana pool.)"
14
+ end
15
+
16
+ it 'should return an error when a card is not found' do
17
+ get_replies(make_message(@bot, '!mtg random string that is probably not a real card')).first.
18
+ should == '[Magic] Card not found, or problem fetching page.'
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ require 'cinch-magic'
4
+ require 'cinch/test'
5
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,17 +9,17 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-03 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: cinch-toolbox
15
+ name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- type: :runtime
22
+ type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
@@ -28,14 +28,30 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: cinch-cooldown
31
+ name: rspec
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
- type: :runtime
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: coveralls
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
39
55
  prerelease: false
40
56
  version_requirements: !ruby/object:Gem::Requirement
41
57
  none: false
@@ -43,6 +59,70 @@ dependencies:
43
59
  - - ! '>='
44
60
  - !ruby/object:Gem::Version
45
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: cinch
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.5
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.0.5
78
+ - !ruby/object:Gem::Dependency
79
+ name: cinch-test
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.0.3
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.0.3
94
+ - !ruby/object:Gem::Dependency
95
+ name: cinch-toolbox
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.0.2
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.0.2
110
+ - !ruby/object:Gem::Dependency
111
+ name: cinch-cooldown
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.0.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.0.0
46
126
  description: Cinch Plugin that searches http://magiccards.info/ for card information.
47
127
  email:
48
128
  - bhaberer@gmail.com
@@ -51,6 +131,7 @@ extensions: []
51
131
  extra_rdoc_files: []
52
132
  files:
53
133
  - .gitignore
134
+ - .travis.yml
54
135
  - Gemfile
55
136
  - LICENSE.txt
56
137
  - README.md
@@ -59,6 +140,8 @@ files:
59
140
  - lib/cinch-magic.rb
60
141
  - lib/cinch/plugins/magic/magic.rb
61
142
  - lib/cinch/plugins/magic/version.rb
143
+ - spec/cinch-magic_spec.rb
144
+ - spec/spec_helper.rb
62
145
  homepage: https://github.com/bhaberer/cinch-magic
63
146
  licenses: []
64
147
  post_install_message:
@@ -79,8 +162,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
162
  version: '0'
80
163
  requirements: []
81
164
  rubyforge_project:
82
- rubygems_version: 1.8.24
165
+ rubygems_version: 1.8.25
83
166
  signing_key:
84
167
  specification_version: 3
85
168
  summary: Cinch Plugin for Magic Cards
86
- test_files: []
169
+ test_files:
170
+ - spec/cinch-magic_spec.rb
171
+ - spec/spec_helper.rb