sc2ranks 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile CHANGED
@@ -1,10 +1,11 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
3
  gem 'httparty'
4
4
 
5
5
  group :development do
6
- gem "shoulda", ">= 0"
7
- gem "bundler", "~> 1.0.0"
8
- gem "jeweler", "~> 1.5.2"
9
- gem "rcov", ">= 0"
6
+ gem 'rspec', '~> 2.3.0'
7
+ gem 'cucumber', '>= 0'
8
+ gem 'bundler', '~> 1.0.0'
9
+ gem 'jeweler', '~> 1.5.2'
10
+ gem 'rcov', '>= 0'
10
11
  end
@@ -1,7 +1,17 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ builder (3.0.0)
4
5
  crack (0.1.8)
6
+ cucumber (0.10.0)
7
+ builder (>= 2.1.2)
8
+ diff-lcs (~> 1.1.2)
9
+ gherkin (~> 2.3.2)
10
+ json (~> 1.4.6)
11
+ term-ansicolor (~> 1.0.5)
12
+ diff-lcs (1.1.2)
13
+ gherkin (2.3.3)
14
+ json (~> 1.4.6)
5
15
  git (1.2.5)
6
16
  httparty (0.6.1)
7
17
  crack (= 0.1.8)
@@ -9,16 +19,26 @@ GEM
9
19
  bundler (~> 1.0.0)
10
20
  git (>= 1.2.5)
11
21
  rake
22
+ json (1.4.6)
12
23
  rake (0.8.7)
13
24
  rcov (0.9.9)
14
- shoulda (2.11.3)
25
+ rspec (2.3.0)
26
+ rspec-core (~> 2.3.0)
27
+ rspec-expectations (~> 2.3.0)
28
+ rspec-mocks (~> 2.3.0)
29
+ rspec-core (2.3.1)
30
+ rspec-expectations (2.3.0)
31
+ diff-lcs (~> 1.1.2)
32
+ rspec-mocks (2.3.0)
33
+ term-ansicolor (1.0.5)
15
34
 
16
35
  PLATFORMS
17
36
  ruby
18
37
 
19
38
  DEPENDENCIES
20
39
  bundler (~> 1.0.0)
40
+ cucumber
21
41
  httparty
22
42
  jeweler (~> 1.5.2)
23
43
  rcov
24
- shoulda
44
+ rspec (~> 2.3.0)
@@ -24,6 +24,7 @@ This will return an object with the following methods
24
24
 
25
25
  +name+:: Character name
26
26
  +bnet_id+:: Battle.net ID
27
+ +bnet_url+:: Passed in Battle.net profile url
27
28
  +region+:: Battle.net region
28
29
  +id+:: Sc2ranks id
29
30
  +updated_at+:: When the sc2ranks data was last updated
@@ -78,7 +79,7 @@ teams (or [] if there are none.)
78
79
  Once you get the team you can use the following methods to reach the data.
79
80
 
80
81
  +bracket+:: The number of the bracket (1, 2, 3 or 4)
81
- +is_random+:: Whether this is a random team (true or false)
82
+ +is_random+:: Whether this is a random team (true or false), also aliased as <tt>is_random?</tt>
82
83
  +fav_race+:: Race most played for this team (zerg, terran or protoss)
83
84
  +updated_at+:: Time that sc2ranks.com last updated this team's data
84
85
  +league+:: League that this team is currently in (bronze, silver, gold, platinum or diamond)
data/Rakefile CHANGED
@@ -26,21 +26,21 @@ Jeweler::Tasks.new do |gem|
26
26
  end
27
27
  Jeweler::RubygemsDotOrgTasks.new
28
28
 
29
- require 'rake/testtask'
30
- Rake::TestTask.new(:test) do |test|
31
- test.libs << 'lib' << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
34
33
  end
35
34
 
36
- require 'rcov/rcovtask'
37
- Rcov::RcovTask.new do |test|
38
- test.libs << 'test'
39
- test.pattern = 'test/**/test_*.rb'
40
- test.verbose = true
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
41
38
  end
42
39
 
43
- task :default => :test
40
+ require 'cucumber/rake/task'
41
+ Cucumber::Rake::Task.new(:features)
42
+
43
+ task :default => :spec
44
44
 
45
45
  require 'rake/rdoctask'
46
46
  Rake::RDocTask.new do |rdoc|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -0,0 +1,9 @@
1
+ Feature: something something
2
+ In order to something something
3
+ A user something something
4
+ something something something
5
+
6
+ Scenario: something something
7
+ Given inspiration
8
+ When I create a sweet new gem
9
+ Then everyone should see how awesome I am
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'bundler'
3
2
  begin
4
3
  Bundler.setup(:default, :development)
@@ -7,12 +6,8 @@ rescue Bundler::BundlerError => e
7
6
  $stderr.puts "Run `bundle install` to install missing gems"
8
7
  exit e.status_code
9
8
  end
10
- require 'test/unit'
11
- require 'shoulda'
12
9
 
13
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
- $LOAD_PATH.unshift(File.dirname(__FILE__))
10
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
15
11
  require 'sc2ranks'
16
12
 
17
- class Test::Unit::TestCase
18
- end
13
+ require 'rspec/expectations'
@@ -14,16 +14,15 @@ class Sc2ranks
14
14
  end
15
15
 
16
16
  def character(url)
17
- parse_bnet_url url
17
+ region, char = parse_bnet_url url
18
18
 
19
- data = self.class.get("/api/base/teams/#{@region}/#{@character}.xml")
20
- Character.new data['hash']
19
+ data = self.class.get("/api/base/teams/#{region}/#{char}.xml")
20
+
21
+ Character.new url, data['hash']
21
22
  end
22
23
 
23
24
  def parse_bnet_url(url)
24
25
  Sc2ranks::RE =~ url
25
-
26
- @region = $1
27
- @character = "#{$3}!#{$2}"
26
+ return $1, "#{$3}!#{$2}"
28
27
  end
29
28
  end
@@ -1,29 +1,24 @@
1
- class Sc2ranks
2
- class Character
3
- attr_reader :region
4
- attr_reader :name
5
- attr_reader :bnet_id
6
- attr_reader :id
7
- attr_reader :updated_at
8
- attr_reader :achievement_points
9
- attr_reader :character_code
10
- attr_reader :portrait
11
- attr_reader :teams
12
-
13
- def initialize(http)
14
- @region = http['region']
15
- @name = http['name']
16
- @bnet_id = http['bnet_id']
17
- @id = http['id']
18
- @updated_at = http['updated_at']
19
- @achievement_points = http['achievement_points']
20
- @character_code = http['character_code']
1
+ require 'sc2ranks/team'
2
+ require 'sc2ranks/portrait'
21
3
 
22
- @portrait = Portrait.new(http['portrait'])
23
-
24
- @teams = []
25
- http['teams'].each do |data|
26
- @teams << Team.new(data)
4
+ class Sc2ranks
5
+ class Character < Struct.new(:name, :bnet_url, :bnet_id, :id, :region, :updated_at, :achievement_points, :character_code, :portrait, :teams)
6
+ def initialize(url, data)
7
+ self.bnet_url = url
8
+
9
+ (members - ['bnet_url']).each do |member|
10
+ case member
11
+ when 'portrait'
12
+ self.portrait = Portrait.new(data[member])
13
+ when 'teams'
14
+ self.teams = []
15
+
16
+ data['teams'].each do |team|
17
+ self.teams << Team.new(team)
18
+ end
19
+ else
20
+ self[member] = data[member]
21
+ end
27
22
  end
28
23
  end
29
24
 
@@ -33,62 +28,14 @@ class Sc2ranks
33
28
  # array of teams (or an empty array if their are none).
34
29
  def team(bracket, is_random = false)
35
30
  if bracket == 1 or is_random
36
- @teams.detect do |team|
31
+ self.teams.detect do |team|
37
32
  team.bracket == bracket and team.is_random == is_random
38
33
  end
39
34
  else
40
- @teams.select do |team|
35
+ self.teams.select do |team|
41
36
  team.bracket == bracket and team.is_random == is_random
42
37
  end
43
38
  end
44
39
  end
45
-
46
- class Team
47
- attr_reader :bracket
48
- attr_reader :is_random
49
- attr_reader :fav_race
50
- attr_reader :updated_at
51
- attr_reader :league
52
- attr_reader :division
53
- attr_reader :division_rank
54
- attr_reader :world_rank
55
- attr_reader :region_rank
56
- attr_reader :wins
57
- attr_reader :losses
58
- attr_reader :points
59
- attr_reader :ratio
60
-
61
- def initialize(http)
62
- @bracket = http['bracket']
63
- @is_random = http['is_random']
64
- @fav_race = http['fav_race']
65
- @updated_at = http['updated_at']
66
- @league = http['league']
67
- @division = http['division']
68
- @division_rank = http['division_rank']
69
- @world_rank = http['world_rank']
70
- @region_rank = http['region_rank']
71
- @wins = http['wins']
72
- @losses = http['losses']
73
- @points = http['points']
74
- @ratio = http['ratio']
75
- end
76
-
77
- def is_random?
78
- @is_random
79
- end
80
- end
81
-
82
- class Portrait
83
- attr_reader :icon_id
84
- attr_reader :column
85
- attr_reader :row
86
-
87
- def initialize(http)
88
- @icon_id = http['icon_id']
89
- @column = http['column']
90
- @row = http['row']
91
- end
92
- end
93
40
  end
94
41
  end
@@ -0,0 +1,9 @@
1
+ class Sc2ranks
2
+ class Portrait < Struct.new(:icon_id,:column,:row)
3
+ def initialize(data)
4
+ members.each do |member|
5
+ self[member] = data[member]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class Sc2ranks
2
+ class Team < Struct.new(:bracket,:is_random,:fav_race,:updated_at,:league,:division,:division_rank,:world_rank,:region_rank,:wins,:losses,:points,:ratio)
3
+ def initialize(data)
4
+ members.each do |member|
5
+ self[member] = data[member]
6
+ end
7
+ end
8
+
9
+ alias :is_random? :is_random
10
+ end
11
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sc2ranks}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Christopher Giroir"]
12
- s.date = %q{2011-01-09}
12
+ s.date = %q{2011-01-10}
13
13
  s.description = %q{This gem allows you to access data from http://sc2ranks.com}
14
14
  s.email = %q{kelsin@valefor.com}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ ".rspec",
21
22
  ".rvmrc",
22
23
  "Gemfile",
23
24
  "Gemfile.lock",
@@ -25,11 +26,16 @@ Gem::Specification.new do |s|
25
26
  "README.rdoc",
26
27
  "Rakefile",
27
28
  "VERSION",
29
+ "features/sc2ranks.feature",
30
+ "features/step_definitions/sc2ranks_steps.rb",
31
+ "features/support/env.rb",
28
32
  "lib/sc2ranks.rb",
29
33
  "lib/sc2ranks/character.rb",
34
+ "lib/sc2ranks/portrait.rb",
35
+ "lib/sc2ranks/team.rb",
30
36
  "sc2ranks.gemspec",
31
- "test/helper.rb",
32
- "test/test_sc2ranks.rb"
37
+ "spec/sc2ranks_spec.rb",
38
+ "spec/spec_helper.rb"
33
39
  ]
34
40
  s.homepage = %q{http://github.com/Kelsin/sc2ranks}
35
41
  s.licenses = ["MIT"]
@@ -37,8 +43,8 @@ Gem::Specification.new do |s|
37
43
  s.rubygems_version = %q{1.3.7}
38
44
  s.summary = %q{A gem to access the api of sc2ranks.com}
39
45
  s.test_files = [
40
- "test/helper.rb",
41
- "test/test_sc2ranks.rb"
46
+ "spec/sc2ranks_spec.rb",
47
+ "spec/spec_helper.rb"
42
48
  ]
43
49
 
44
50
  if s.respond_to? :specification_version then
@@ -47,20 +53,23 @@ Gem::Specification.new do |s|
47
53
 
48
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
55
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
50
- s.add_development_dependency(%q<shoulda>, [">= 0"])
56
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
57
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
51
58
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
59
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
53
60
  s.add_development_dependency(%q<rcov>, [">= 0"])
54
61
  else
55
62
  s.add_dependency(%q<httparty>, [">= 0"])
56
- s.add_dependency(%q<shoulda>, [">= 0"])
63
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
+ s.add_dependency(%q<cucumber>, [">= 0"])
57
65
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
66
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
59
67
  s.add_dependency(%q<rcov>, [">= 0"])
60
68
  end
61
69
  else
62
70
  s.add_dependency(%q<httparty>, [">= 0"])
63
- s.add_dependency(%q<shoulda>, [">= 0"])
71
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
72
+ s.add_dependency(%q<cucumber>, [">= 0"])
64
73
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
74
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
66
75
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Sc2ranks" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'sc2ranks'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sc2ranks
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christopher Giroir
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-09 00:00:00 -05:00
18
+ date: 2011-01-10 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,8 +35,24 @@ dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  type: :development
37
37
  prerelease: false
38
- name: shoulda
38
+ name: rspec
39
39
  version_requirements: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 2
47
+ - 3
48
+ - 0
49
+ version: 2.3.0
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ prerelease: false
54
+ name: cucumber
55
+ version_requirements: &id003 !ruby/object:Gem::Requirement
40
56
  none: false
41
57
  requirements:
42
58
  - - ">="
@@ -45,12 +61,12 @@ dependencies:
45
61
  segments:
46
62
  - 0
47
63
  version: "0"
48
- requirement: *id002
64
+ requirement: *id003
49
65
  - !ruby/object:Gem::Dependency
50
66
  type: :development
51
67
  prerelease: false
52
68
  name: bundler
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
54
70
  none: false
55
71
  requirements:
56
72
  - - ~>
@@ -61,12 +77,12 @@ dependencies:
61
77
  - 0
62
78
  - 0
63
79
  version: 1.0.0
64
- requirement: *id003
80
+ requirement: *id004
65
81
  - !ruby/object:Gem::Dependency
66
82
  type: :development
67
83
  prerelease: false
68
84
  name: jeweler
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
85
+ version_requirements: &id005 !ruby/object:Gem::Requirement
70
86
  none: false
71
87
  requirements:
72
88
  - - ~>
@@ -77,12 +93,12 @@ dependencies:
77
93
  - 5
78
94
  - 2
79
95
  version: 1.5.2
80
- requirement: *id004
96
+ requirement: *id005
81
97
  - !ruby/object:Gem::Dependency
82
98
  type: :development
83
99
  prerelease: false
84
100
  name: rcov
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
101
+ version_requirements: &id006 !ruby/object:Gem::Requirement
86
102
  none: false
87
103
  requirements:
88
104
  - - ">="
@@ -91,7 +107,7 @@ dependencies:
91
107
  segments:
92
108
  - 0
93
109
  version: "0"
94
- requirement: *id005
110
+ requirement: *id006
95
111
  description: This gem allows you to access data from http://sc2ranks.com
96
112
  email: kelsin@valefor.com
97
113
  executables: []
@@ -103,6 +119,7 @@ extra_rdoc_files:
103
119
  - README.rdoc
104
120
  files:
105
121
  - .document
122
+ - .rspec
106
123
  - .rvmrc
107
124
  - Gemfile
108
125
  - Gemfile.lock
@@ -110,11 +127,16 @@ files:
110
127
  - README.rdoc
111
128
  - Rakefile
112
129
  - VERSION
130
+ - features/sc2ranks.feature
131
+ - features/step_definitions/sc2ranks_steps.rb
132
+ - features/support/env.rb
113
133
  - lib/sc2ranks.rb
114
134
  - lib/sc2ranks/character.rb
135
+ - lib/sc2ranks/portrait.rb
136
+ - lib/sc2ranks/team.rb
115
137
  - sc2ranks.gemspec
116
- - test/helper.rb
117
- - test/test_sc2ranks.rb
138
+ - spec/sc2ranks_spec.rb
139
+ - spec/spec_helper.rb
118
140
  has_rdoc: true
119
141
  homepage: http://github.com/Kelsin/sc2ranks
120
142
  licenses:
@@ -150,5 +172,5 @@ signing_key:
150
172
  specification_version: 3
151
173
  summary: A gem to access the api of sc2ranks.com
152
174
  test_files:
153
- - test/helper.rb
154
- - test/test_sc2ranks.rb
175
+ - spec/sc2ranks_spec.rb
176
+ - spec/spec_helper.rb
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSc2ranks < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end