codebadges 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +6 -0
- data/bin/codebadges +36 -7
- data/codebadges.gemspec +1 -2
- data/lib/codebadges/badges.rb +1 -1
- data/lib/codebadges/version.rb +1 -1
- data/spec/badges_test.rb +81 -2
- data/spec/testfiles/test.txt +2 -0
- metadata +6 -6
- data/spec/badges_test_000.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68955f2962ad30ae0a1383f20570db988bcfc0d5
|
4
|
+
data.tar.gz: e63d0319bae4948256dc1bede00cccafaa8ae5c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21bd415f2d143fc070da51a01ee641fe532d236159e24734adfb3a046adbe876cd6c61af0ddcff021201c31d20b01380e22e663d840158fbbb26946dfc1bd7f8
|
7
|
+
data.tar.gz: 909c44137fb280380f5b2ac9719de8ef2f6907aeb5cb4f175b120cdf679ce8d1f2d6e6d0ed997b250ef0e10ca471d719994d1f667d3ba6f77d99d5477e5d7343
|
data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
*.gem
|
1
|
+
*.gem
|
2
|
+
Gemfile.lock
|
data/.travis.yml
ADDED
data/bin/codebadges
CHANGED
@@ -1,14 +1,43 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'codebadges'
|
3
|
+
# require '../lib/codebadges/badges.rb' # for cmd line testing purposes
|
4
|
+
require 'codebadges' # for production
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
def get_users_array_from_file(file)
|
7
|
+
users_array = []
|
7
8
|
|
8
|
-
|
9
|
+
File.open(file, 'r') do |f|
|
10
|
+
f.each_line.map do |line|
|
11
|
+
next if line.chomp.empty?
|
12
|
+
users_array.push(line.gsub("\n", ''))
|
13
|
+
end
|
14
|
+
end
|
9
15
|
|
10
|
-
|
16
|
+
users_array
|
17
|
+
end
|
18
|
+
|
19
|
+
type = ['txt']
|
20
|
+
fail ArgumentError, "Usage: badges [username/file]\n" if ARGV.count == 0
|
21
|
+
if type.include? ARGV[0].split('.').last
|
22
|
+
users_array = get_users_array_from_file(ARGV[0])
|
23
|
+
|
24
|
+
badges_found_from_file = CodeBadges::Academy.get_cadets(users_array)
|
25
|
+
|
26
|
+
badges_found_from_file.each_with_index do |(k, v), _|
|
27
|
+
puts "#{k} has collected #{v.size} badges."
|
28
|
+
v.each do |title, date|
|
29
|
+
puts "Earned '#{title}' on #{date}."
|
30
|
+
end
|
31
|
+
puts "\n"
|
32
|
+
end
|
33
|
+
else
|
34
|
+
user_name = ARGV[0]
|
35
|
+
|
36
|
+
badges_found = CodeBadges::CodecademyBadges.get_badges(user_name)
|
37
|
+
|
38
|
+
puts "#{user_name} has collected #{badges_found.size} badges."
|
11
39
|
|
12
|
-
badges_found.each do |title, date|
|
13
|
-
|
40
|
+
badges_found.each do |title, date|
|
41
|
+
puts "Earned '#{title}' on #{date}."
|
42
|
+
end
|
14
43
|
end
|
data/codebadges.gemspec
CHANGED
@@ -5,8 +5,7 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'codebadges'
|
6
6
|
s.version = CodeBadges::VERSION
|
7
7
|
s.executables << 'codebadges'
|
8
|
-
|
9
|
-
s.date = '2014-09-03'
|
8
|
+
s.date = '2015-07-21'
|
10
9
|
s.summary = 'Grab the badges information from the Codecademy'
|
11
10
|
s.description = 'Use username as an input, automatically give you the badges the user has.'
|
12
11
|
s.authors = ['Lee Chen', 'Soumya Ray']
|
data/lib/codebadges/badges.rb
CHANGED
@@ -9,7 +9,7 @@ module CodeBadges
|
|
9
9
|
class CodecademyBadges
|
10
10
|
TITLE_XPATH = "//div[@class = 'grid-row']//h5[@class = 'margin-top--1']"
|
11
11
|
DATE_XPATH = "//small[@class = 'text--ellipsis']"
|
12
|
-
USERS_URL = '
|
12
|
+
USERS_URL = 'https://www.codecademy.com/users'
|
13
13
|
ACHIEVEMENTS_DIR = 'achievements'
|
14
14
|
|
15
15
|
def self.get_badges(username)
|
data/lib/codebadges/version.rb
CHANGED
data/spec/badges_test.rb
CHANGED
@@ -20,12 +20,91 @@ badge = {
|
|
20
20
|
'First Lesson' => 'Jun 20, 2012'
|
21
21
|
}
|
22
22
|
|
23
|
+
badges_from_file = {
|
24
|
+
'soumya.ray' => {
|
25
|
+
'Sorting Your Friends' => 'May 18, 2014',
|
26
|
+
'100 Exercises' => 'May 18, 2014',
|
27
|
+
'Max Streak Count of 3' => 'May 11, 2014',
|
28
|
+
'Design a Button for Your Website' => 'May 9, 2014',
|
29
|
+
'CSS: An Overview' => 'May 9, 2014',
|
30
|
+
'Build Your Own Webpage' => 'May 9, 2014',
|
31
|
+
'50 Exercises' => 'May 9, 2014',
|
32
|
+
'Clickable Photo Page' => 'May 9, 2014',
|
33
|
+
'HTML Basics III' => 'May 9, 2014',
|
34
|
+
'25 points earned in one day' => 'May 9, 2014',
|
35
|
+
'HTML Basics' => 'May 9, 2014',
|
36
|
+
'25 Exercises' => 'May 9, 2014',
|
37
|
+
'10 Exercises' => 'Dec 12, 2012',
|
38
|
+
'Max Streak Count of 1' => 'Dec 12, 2012',
|
39
|
+
'First Lesson' => 'Jun 20, 2012'
|
40
|
+
},
|
41
|
+
'chenlizhan' => {
|
42
|
+
'Animate Your Name' => 'Sep 26, 2014',
|
43
|
+
'Banking on Ruby' => 'Aug 25, 2014',
|
44
|
+
'Object-Oriented Programming II' => 'Aug 25, 2014',
|
45
|
+
'Virtual Computer' => 'Aug 25, 2014',
|
46
|
+
'500 Exercises' => 'Aug 25, 2014',
|
47
|
+
'Object-Oriented Programming I' => 'Aug 22, 2014',
|
48
|
+
'Blocks, Procs, and Lambdas' => 'Aug 22, 2014',
|
49
|
+
'The Refactor Factory' => 'Aug 21, 2014',
|
50
|
+
'The Zen of Ruby' => 'Aug 21, 2014',
|
51
|
+
'150 points earned in one day' => 'Aug 21, 2014',
|
52
|
+
'A Night at the Movies' => 'Aug 21, 2014',
|
53
|
+
'Hashes and Symbols' => 'Aug 21, 2014',
|
54
|
+
'125 points earned in one day' => 'Aug 21, 2014',
|
55
|
+
'Ordering Your Library' => 'Aug 21, 2014',
|
56
|
+
'Methods, Blocks, & Sorting' => 'Aug 21, 2014',
|
57
|
+
'100 points earned in one day' => 'Aug 21, 2014',
|
58
|
+
'Create a Histogram' => 'Aug 21, 2014',
|
59
|
+
'Data Structures' => 'Aug 21, 2014',
|
60
|
+
'Redacted!' => 'Aug 21, 2014',
|
61
|
+
'Loops & Iterators' => 'Aug 21, 2014',
|
62
|
+
'Thith Meanth War!' => 'Aug 21, 2014',
|
63
|
+
'Control Flow in Ruby' => 'Aug 21, 2014',
|
64
|
+
'Putting the Form in Formatter' => 'Aug 21, 2014',
|
65
|
+
'Introduction to Ruby' => 'Aug 21, 2014',
|
66
|
+
'File Input/Output' => 'Jul 24, 2014',
|
67
|
+
'Max Streak Count of 5' => 'Jul 24, 2014',
|
68
|
+
'Classes' => 'Jul 24, 2014',
|
69
|
+
'Introduction to Classes' => 'Jul 23, 2014',
|
70
|
+
'Introduction to Bitwise Operators' => 'Jul 22, 2014',
|
71
|
+
'Advanced Topics in Python' => 'Jul 22, 2014',
|
72
|
+
'Exam Statistics' => 'Jul 22, 2014',
|
73
|
+
'Max Streak Count of 3' => 'Jul 22, 2014',
|
74
|
+
'Practice Makes Perfect' => 'Jul 21, 2014',
|
75
|
+
'200 Exercises' => 'Jul 21, 2014',
|
76
|
+
'75 points earned in one day' => 'Jul 21, 2014',
|
77
|
+
'Loops' => 'Jul 21, 2014',
|
78
|
+
'Battleship!' => 'Jul 20, 2014',
|
79
|
+
'Lists and Functions' => 'Jul 20, 2014',
|
80
|
+
'Student Becomes the Teacher' => 'Jul 20, 2014',
|
81
|
+
'PygLatin' => 'Jul 20, 2014',
|
82
|
+
'A Day at the Supermarket' => 'Jul 19, 2014',
|
83
|
+
'Python Lists and Dictionaries' => 'Jul 19, 2014',
|
84
|
+
'100 Exercises' => 'Jul 19, 2014',
|
85
|
+
'Taking a Vacation' => 'Jul 19, 2014',
|
86
|
+
'Functions' => 'Jul 19, 2014',
|
87
|
+
'Conditionals & Control Flow' => 'Jul 18, 2014',
|
88
|
+
'50 points earned in one day' => 'Jul 18, 2014',
|
89
|
+
'50 Exercises' => 'Jul 18, 2014',
|
90
|
+
'Date and Time' => 'Jul 18, 2014',
|
91
|
+
'Strings & Console Output' => 'Jul 18, 2014',
|
92
|
+
'25 points earned in one day' => 'Jul 18, 2014',
|
93
|
+
'25 Exercises' => 'Jul 18, 2014',
|
94
|
+
'Tip Calculator' => 'Jul 18, 2014',
|
95
|
+
'Python Syntax' => 'Jul 18, 2014',
|
96
|
+
'First Lesson' => 'Jul 18, 2014',
|
97
|
+
'10 Exercises' => 'Jul 18, 2014',
|
98
|
+
'Max Streak Count of 1' => 'Mar 29, 2014'
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
23
102
|
badges_found = CodeBadges::CodecademyBadges.get_badges('soumya.ray')
|
24
103
|
|
25
|
-
describe 'Get
|
104
|
+
describe 'Get badges for one user' do
|
26
105
|
|
27
106
|
it 'has the right number of badges' do
|
28
|
-
badges_found.size.
|
107
|
+
badges_found.size.wont_be :<, badge.size
|
29
108
|
end
|
30
109
|
|
31
110
|
badge.map do |b_name, b_date|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebadges
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Chen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -62,6 +62,7 @@ extensions: []
|
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
64
|
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
65
66
|
- Gemfile
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
@@ -71,7 +72,7 @@ files:
|
|
71
72
|
- lib/codebadges/badges.rb
|
72
73
|
- lib/codebadges/version.rb
|
73
74
|
- spec/badges_test.rb
|
74
|
-
- spec/
|
75
|
+
- spec/testfiles/test.txt
|
75
76
|
homepage: https://github.com/ISS-SOA/Codecademy-Ruby
|
76
77
|
licenses:
|
77
78
|
- MIT
|
@@ -92,11 +93,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
version: '0'
|
93
94
|
requirements: []
|
94
95
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.4.6
|
96
97
|
signing_key:
|
97
98
|
specification_version: 4
|
98
99
|
summary: Grab the badges information from the Codecademy
|
99
100
|
test_files:
|
100
101
|
- spec/badges_test.rb
|
101
|
-
- spec/
|
102
|
-
has_rdoc:
|
102
|
+
- spec/testfiles/test.txt
|
data/spec/badges_test_000.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
# NOTE: incomplete -- This style of testing is too slow and takes too long!
|
2
|
-
# look at badges_test.rb for more optimzed version
|
3
|
-
|
4
|
-
require 'minitest/autorun'
|
5
|
-
require 'minitest/rg'
|
6
|
-
require './badges.rb'
|
7
|
-
|
8
|
-
badge = {
|
9
|
-
'Sorting Your Friends' => 'May 18, 2014',
|
10
|
-
'100 Exercises' => 'May 18, 2014',
|
11
|
-
'Max Streak Count of 3' => 'May 11, 2014',
|
12
|
-
'Design a Button for Your Website' => 'May 9, 2014',
|
13
|
-
'CSS: An Overview' => 'May 9, 2014',
|
14
|
-
'Build Your Own Webpage' => 'May 9, 2014',
|
15
|
-
'50 Exercises' => 'May 9, 2014',
|
16
|
-
'Clickable Photo Page' => 'May 9, 2014',
|
17
|
-
'HTML Basics III' => 'May 9, 2014',
|
18
|
-
'25 points earned in one day' => 'May 9, 2014',
|
19
|
-
'HTML Basics' => 'May 9, 2014',
|
20
|
-
'25 Exercises' => 'May 9, 2014',
|
21
|
-
'10 Exercises' => 'Dec 12, 2012',
|
22
|
-
'Max Streak Count of 1' => 'Dec 12, 2012',
|
23
|
-
'First Lesson' => 'Jun 20, 2012'
|
24
|
-
}
|
25
|
-
|
26
|
-
describe "Get all the badges" do
|
27
|
-
|
28
|
-
before do
|
29
|
-
@badges_found = CodecademyBadges.get_badges('soumya.ray')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'has the right number of badges' do
|
33
|
-
@badges_found.size.must_equal badge.size
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'finds "Sorting Your Friends" badge' do
|
37
|
-
@badges_found['Sorting Your Friends'].must_equal badge['Sorting Your Friends']
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'finds "100 Exercises" badge' do
|
41
|
-
@badges_found['100 Exercises'].must_equal badge['100 Exercises']
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'finds "Max Streak Count of 3" badge' do
|
45
|
-
@badges_found['Max Streak Count of 3'].must_equal badge['Max Streak Count of 3']
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'finds "Design a Button for Your Website" badge' do
|
49
|
-
@badges_found['Design a Button for Your Website'].must_equal badge['Design a Button for Your Website']
|
50
|
-
end
|
51
|
-
|
52
|
-
# TODO: make writing these tests easier and running these tests faster!
|
53
|
-
end
|