cinch-magic 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 376e98bc2aabf615ae71b5b283899bb4787c7bf1
4
+ data.tar.gz: bdd655ceed8614fb0346b741e6607cd74716c7ec
5
+ SHA512:
6
+ metadata.gz: f415955882480f34f1f73b1a414b4d46e2e0227683f9b16302d3e07c182ce872150af2629a73538bfab68da2473753197dbf7ac74f6002a3f4acf2dbed1f6fe2
7
+ data.tar.gz: a5f190e08e3ed39c91712597e7727f04f067006f889ffc21bdf0d20bdc02e283b4d5f48bd2263d66a1830fcc4f21906b4581fc45731c3c2f42592c564186778b
@@ -1,4 +1,23 @@
1
1
  language: ruby
2
+ env:
3
+ global:
4
+ - "JRUBY_OPTS=-Xcext.enabled=true"
2
5
  rvm:
3
- - 1.9.2
6
+ - 2.1.0
7
+ - 2.0.0
4
8
  - 1.9.3
9
+ - 1.9.2
10
+ - 1.8.7
11
+ - jruby-18mode
12
+ - jruby-19mode
13
+ - ruby-head
14
+ - jruby-head
15
+ - ree
16
+ matrix:
17
+ allow_failures:
18
+ - rvm: 1.8.7
19
+ - rvm: ree
20
+ - rvm: jruby-18mode
21
+ - rvm: jruby-19mode
22
+ - rvm: jruby-head
23
+ fast_finish: true
@@ -8,22 +8,19 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Cinch::Plugins::Magic::VERSION
9
9
  gem.authors = ['Brian Haberer']
10
10
  gem.email = ['bhaberer@gmail.com']
11
- gem.description = %q{Cinch Plugin that searches http://magiccards.info/ for card information.}
12
- gem.summary = %q{Cinch Plugin for Magic Cards}
11
+ gem.description = %q(Cinch Plugin that searches http://magiccards.info/ for card information.)
12
+ gem.summary = %q(Cinch Plugin for Magic Cards)
13
13
  gem.homepage = 'https://github.com/bhaberer/cinch-magic'
14
14
  gem.license = 'MIT'
15
-
16
15
  gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
+ gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(/^(test|spec|features)\//)
19
18
  gem.require_paths = ['lib']
20
-
21
- gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'rspec'
23
- gem.add_development_dependency 'coveralls'
24
- gem.add_development_dependency 'cinch-test'
25
-
26
- gem.add_dependency 'cinch', '~> 2.0.12'
27
- gem.add_dependency 'cinch-toolbox', '~> 1.1.0'
28
- gem.add_dependency 'cinch-cooldown', '~> 1.1.1'
19
+ gem.add_development_dependency 'rake', '~> 10'
20
+ gem.add_development_dependency 'rspec', '~> 3'
21
+ gem.add_development_dependency 'coveralls', '~> 0.7'
22
+ gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.1'
23
+ gem.add_dependency 'cinch', '~> 2'
24
+ gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.1'
25
+ gem.add_dependency 'cinch-toolbox', '~> 1.1'
29
26
  end
@@ -3,93 +3,95 @@ require 'cinch'
3
3
  require 'cinch/toolbox'
4
4
  require 'cinch/cooldown'
5
5
 
6
- module Cinch::Plugins
7
- # Cinch Plugin to looking MTG cards
8
- class Magic
9
- include Cinch::Plugin
10
-
11
- enforce_cooldown
12
-
13
- self.help = 'Use .mtg <card name> to see the info for that card.'
14
-
15
- match /mtg (.*)/
16
-
17
- def execute(m, term)
18
- m.reply get_card(term)
19
- end
20
-
21
- private
22
-
23
- def get_card(term)
24
- # Fetch the html for the search term
25
- data = card_data(term)
26
-
27
- # Catch nil responses.
28
- return '[Magic] Card not found, or problem fetching page.' if data.nil?
29
-
30
- # Build card string
31
- card = "#{card_name(data)} [#{card_info(data)}] - #{card_text(data)}"
32
-
33
- # Truncate if it's super long
34
- card = Cinch::Toolbox.truncate(card, 300)
35
-
36
- "[Magic] #{card} [#{card_link(data)}]"
37
- end
38
-
39
- def card_info(data)
40
- text = data[/<p[^>]*>([^<]+)<\/p>/, 1]
41
-
42
- # Replace Newlines, unicode lines, total mana, and large spaces.
43
- text = text.gsub(/\n/, '')
44
- text = text.gsub(/\s—/, ', ')
45
- text = text.gsub(/\s\(\d*\)/, '')
46
- text = text.gsub(/\s{2,}/, ' ')
47
-
48
- # Remove pesky whitespace that might have snuck in...
49
- text.strip!
50
-
51
- text
52
- rescue
53
- debug 'Error getting the card info'
54
- return ''
55
- end
56
-
57
- def card_name(data)
58
- data[/<a href=[^>]*>([^<]+)<\/a>/, 1]
59
- rescue
60
- debug 'Error finding the card name'
61
- return ''
62
- end
63
-
64
- def card_link(data)
65
- "http://magiccards.info#{data[/<a href="([^>]*)">[^<]+<\/a>/, 1]}"
66
- rescue
67
- debug 'Error finding the card url'
68
- return ''
69
- end
70
-
71
- def card_text(data)
72
- data[%r(<p class="ctext"><b[^>]*>(.+)</b></p>), 1].gsub(/<br><br>/, ' ')
73
- rescue
74
- debug 'Error finding the card description'
75
- return ''
76
- end
77
-
78
- def card_data(term)
79
- # URI Encode the term and build the URL
80
- term = URI.escape("!#{term}",
81
- Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
82
- url = "http://magiccards.info/query?q=#{term}"
83
-
84
- # Make sure the URL is legit
85
- url = URI.extract(url, %w(http https)).first
86
-
87
- # Grab the html block because magiccards.info fucking loves tables
88
- # and hates helpful ids and classnames
89
- Cinch::Toolbox.get_html_element(url, '//table[3]/tr/td[2]', :xpath_full)
90
- rescue
91
- debug "Error looking up card: #{term}"
92
- return
6
+ module Cinch
7
+ module Plugins
8
+ # Cinch Plugin to looking MTG cards
9
+ class Magic
10
+ include Cinch::Plugin
11
+
12
+ enforce_cooldown
13
+
14
+ self.help = 'Use .mtg <card name> to see the info for that card.'
15
+
16
+ match(/mtg (.*)/)
17
+
18
+ def execute(m, term)
19
+ m.reply get_card(term)
20
+ end
21
+
22
+ private
23
+
24
+ def get_card(term)
25
+ # Fetch the html for the search term
26
+ data = card_data(term)
27
+
28
+ # Catch nil responses.
29
+ return '[Magic] Card not found, or problem fetching page.' if data.nil?
30
+
31
+ # Build card string
32
+ card = "#{card_name(data)} [#{card_info(data)}] - #{card_text(data)}"
33
+
34
+ # Truncate if it's super long
35
+ card = Cinch::Toolbox.truncate(card, 300)
36
+
37
+ "[Magic] #{card} [#{card_link(data)}]"
38
+ end
39
+
40
+ def card_info(data)
41
+ text = data[/<p[^>]*>([^<]+)<\/p>/, 1]
42
+
43
+ # Replace Newlines, unicode lines, total mana, and large spaces.
44
+ text = text.gsub(/\n/, '')
45
+ text = text.gsub(/\s—/, ', ')
46
+ text = text.gsub(/\s\(\d*\)/, '')
47
+ text = text.gsub(/\s{2,}/, ' ')
48
+
49
+ # Remove pesky whitespace that might have snuck in...
50
+ text.strip!
51
+
52
+ text
53
+ rescue
54
+ debug 'Error getting the card info'
55
+ return ''
56
+ end
57
+
58
+ def card_name(data)
59
+ data[/<a href=[^>]*>([^<]+)<\/a>/, 1]
60
+ rescue
61
+ debug 'Error finding the card name'
62
+ return ''
63
+ end
64
+
65
+ def card_link(data)
66
+ "http://magiccards.info#{data[/<a href="([^>]*)">[^<]+<\/a>/, 1]}"
67
+ rescue
68
+ debug 'Error finding the card url'
69
+ return ''
70
+ end
71
+
72
+ def card_text(data)
73
+ data[%r{<p class="ctext"><b[^>]*>(.+)</b></p>}, 1].gsub(/<br><br>/, ' ')
74
+ rescue
75
+ debug 'Error finding the card description'
76
+ return ''
77
+ end
78
+
79
+ def card_data(term)
80
+ # URI Encode the term and build the URL
81
+ term = URI.escape("!#{term}",
82
+ Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
83
+ url = "http://magiccards.info/query?q=#{term}"
84
+
85
+ # Make sure the URL is legit
86
+ url = URI.extract(url, %w(http https)).first
87
+
88
+ # Grab the html block because magiccards.info fucking loves tables
89
+ # and hates helpful ids and classnames
90
+ Cinch::Toolbox.get_html_element(url, '//table[3]/tr/td[2]', :xpath_full)
91
+ rescue
92
+ debug "Error looking up card: #{term}"
93
+ return
94
+ end
93
95
  end
94
96
  end
95
97
  end
@@ -3,7 +3,7 @@ module Cinch
3
3
  module Plugins
4
4
  # Version info
5
5
  class Magic
6
- VERSION = '1.0.3'
6
+ VERSION = '1.0.4'
7
7
  end
8
8
  end
9
9
  end
@@ -9,12 +9,12 @@ describe Cinch::Plugins::Magic do
9
9
  end
10
10
 
11
11
  it 'should allow users to lookup cards' do
12
- get_replies(make_message(@bot, '!mtg forest')).first.text.
13
- should include "[Magic] Forest [Basic Land, Forest] - ({T}: Add {G} to your mana pool.)"
12
+ msg = get_replies(make_message(@bot, '!mtg forest')).first
13
+ expect(msg.text).to include('[Magic] Forest [Basic Land, Forest] - ({T}: Add {G} to your mana pool.)')
14
14
  end
15
15
 
16
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.text.
18
- should == '[Magic] Card not found, or problem fetching page.'
17
+ msg = get_replies(make_message(@bot, '!mtg random string that is probably not a real card')).first
18
+ expect(msg.text).to eq('[Magic] Card not found, or problem fetching page.')
19
19
  end
20
20
  end
metadata CHANGED
@@ -1,128 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
5
- prerelease:
4
+ version: 1.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Haberer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-20 00:00:00.000000000 Z
11
+ date: 2014-08-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '10'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '10'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: coveralls
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '0.7'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '0.7'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: cinch-test
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
67
62
  - - ! '>='
68
63
  - !ruby/object:Gem::Version
69
- version: '0'
64
+ version: 0.1.1
70
65
  type: :development
71
66
  prerelease: false
72
67
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
68
  requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '0.1'
75
72
  - - ! '>='
76
73
  - !ruby/object:Gem::Version
77
- version: '0'
74
+ version: 0.1.1
78
75
  - !ruby/object:Gem::Dependency
79
76
  name: cinch
80
77
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
78
  requirements:
83
79
  - - ~>
84
80
  - !ruby/object:Gem::Version
85
- version: 2.0.12
81
+ version: '2'
86
82
  type: :runtime
87
83
  prerelease: false
88
84
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
85
  requirements:
91
86
  - - ~>
92
87
  - !ruby/object:Gem::Version
93
- version: 2.0.12
88
+ version: '2'
94
89
  - !ruby/object:Gem::Dependency
95
- name: cinch-toolbox
90
+ name: cinch-cooldown
96
91
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
92
  requirements:
99
93
  - - ~>
100
94
  - !ruby/object:Gem::Version
101
- version: 1.1.0
95
+ version: '1.1'
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 1.1.1
102
99
  type: :runtime
103
100
  prerelease: false
104
101
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
102
  requirements:
107
103
  - - ~>
108
104
  - !ruby/object:Gem::Version
109
- version: 1.1.0
105
+ version: '1.1'
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: 1.1.1
110
109
  - !ruby/object:Gem::Dependency
111
- name: cinch-cooldown
110
+ name: cinch-toolbox
112
111
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
112
  requirements:
115
113
  - - ~>
116
114
  - !ruby/object:Gem::Version
117
- version: 1.1.1
115
+ version: '1.1'
118
116
  type: :runtime
119
117
  prerelease: false
120
118
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
119
  requirements:
123
120
  - - ~>
124
121
  - !ruby/object:Gem::Version
125
- version: 1.1.1
122
+ version: '1.1'
126
123
  description: Cinch Plugin that searches http://magiccards.info/ for card information.
127
124
  email:
128
125
  - bhaberer@gmail.com
@@ -145,29 +142,27 @@ files:
145
142
  homepage: https://github.com/bhaberer/cinch-magic
146
143
  licenses:
147
144
  - MIT
145
+ metadata: {}
148
146
  post_install_message:
149
147
  rdoc_options: []
150
148
  require_paths:
151
149
  - lib
152
150
  required_ruby_version: !ruby/object:Gem::Requirement
153
- none: false
154
151
  requirements:
155
152
  - - ! '>='
156
153
  - !ruby/object:Gem::Version
157
154
  version: '0'
158
155
  required_rubygems_version: !ruby/object:Gem::Requirement
159
- none: false
160
156
  requirements:
161
157
  - - ! '>='
162
158
  - !ruby/object:Gem::Version
163
159
  version: '0'
164
160
  requirements: []
165
161
  rubyforge_project:
166
- rubygems_version: 1.8.25
162
+ rubygems_version: 2.2.2
167
163
  signing_key:
168
- specification_version: 3
164
+ specification_version: 4
169
165
  summary: Cinch Plugin for Magic Cards
170
166
  test_files:
171
167
  - spec/cinch-magic_spec.rb
172
168
  - spec/spec_helper.rb
173
- has_rdoc: