deadlinez 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 David Balatero
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,23 @@
1
+ = deadlinez
2
+
3
+ This gives you a simple interface to After the Deadline's grammar/spell checking service.
4
+
5
+ Current version supports:
6
+
7
+ * /stats
8
+ * /verify
9
+
10
+ == Note on Patches/Pull Requests
11
+
12
+ * Fork the project.
13
+ * Make your feature addition or bug fix.
14
+ * Add tests for it. This is important so I don't break it in a
15
+ future version unintentionally.
16
+ * Commit, do not mess with rakefile, version, or history.
17
+ (if you want to have your own version, that is fine but
18
+ bump version in a commit by itself I can ignore when I pull)
19
+ * Send me a pull request. Bonus points for topic branches.
20
+
21
+ == Copyright
22
+
23
+ Copyright (c) 2009 David Balatero. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "deadlinez"
8
+ gem.summary = %Q{Makes it easy to handle After the Deadline AJAX proxying and their API.}
9
+ gem.description = %Q{Makes it easy to handle After the Deadline AJAX proxying and their API.}
10
+ gem.email = "david@bitwax.cd"
11
+ gem.homepage = "http://github.com/dbalatero/deadlinez"
12
+ gem.authors = ["David Balatero"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "fakeweb"
15
+ gem.add_dependency 'httparty'
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "deadlinez #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,24 @@
1
+ module Deadlinez
2
+ class Api
3
+ include HTTParty
4
+ format :xml
5
+ base_uri 'service.afterthedeadline.com'
6
+
7
+ def self.stats(data)
8
+ response = get('/stats',
9
+ :query => {
10
+ :data => data,
11
+ :key => Deadlinez.api_key
12
+ })
13
+ response['scores']['metric']
14
+ end
15
+
16
+ def self.verify(key = Deadlinez.api_key)
17
+ response = get('/verify',
18
+ :query => {
19
+ :key => key
20
+ })
21
+ response.body.strip == 'valid'
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,4 @@
1
+ module Deadlinez
2
+ class Proxy
3
+ end
4
+ end
data/lib/deadlinez.rb ADDED
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+
3
+
4
+ require 'httparty'
5
+ require 'deadlinez/api'
6
+ require 'deadlinez/proxy'
7
+
8
+ module Deadlinez
9
+ class << self
10
+ attr_accessor :api_key
11
+ end
12
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe Deadlinez::Api do
4
+ Deadlinez.api_key = 'testkey'
5
+
6
+ describe "#stats" do
7
+ it "should return correct stats" do
8
+ FakeWeb.register_uri(:get,
9
+ "http://service.afterthedeadline.com/stats?key=testkey&data=Jacobs%20spent%20most%20of%20his%20childhood%20moving%20around%20the%20East%20Coast%20with%20his%20family%2C%20eventually%20settling%20in%20Tampa%2C%20Florida.%20As%20a%20drummer%20he%20won%20the%201978%20%22Most%20Talented%22%20trophy%20at%20Greco%20Junior%20High%20School%2C%20but%20after%20relocating%20to%20Queens%2C%20New%20York%20(as%20a%20result%20of%20his%20parents'%20divorce)%2C%20he%20traded%20his%20drums%20in%20for%20a%20set%20of%20turntables%20apon%20discovering%20and%20marveling%20over%20hip%20hop%20while%20the%20artform%20was%20still%20in%20an%20underground%20developmental%20stage.%20He%20was%20mentored%20in%20the%20craft%20by%20his%20cousin%20Rene%20Negron%20(a.k.a.%20DJ-Stretch)%2C%20and%20their%20close%20friend%20Shawn%20Trone%20(a.k.a.%20MC%20Shah-T%20of%20the%20parody-rap%20group%20No%20Face)%20who%20suggested%20Greg%20use%20the%20name%20%22Shah-G%22.%20Jacobs%20liked%20the%20idea%2C%20but%20mistakenly%20thought%20his%20friend%20said%20%22Shock-G%22%2C%20and%20began%20using%20that%20name%20instead.",
10
+ :response => fixture_for('stats.response'))
11
+
12
+ data = %Q{Jacobs spent most of his childhood moving around the East Coast with his family, eventually settling in Tampa, Florida. As a drummer he won the 1978 "Most Talented" trophy at Greco Junior High School, but after relocating to Queens, New York (as a result of his parents' divorce), he traded his drums in for a set of turntables apon discovering and marveling over hip hop while the artform was still in an underground developmental stage. He was mentored in the craft by his cousin Rene Negron (a.k.a. DJ-Stretch), and their close friend Shawn Trone (a.k.a. MC Shah-T of the parody-rap group No Face) who suggested Greg use the name "Shah-G". Jacobs liked the idea, but mistakenly thought his friend said "Shock-G", and began using that name instead.}
13
+ result = Deadlinez::Api.stats(data)
14
+ result.should have(4).things
15
+ end
16
+ end
17
+
18
+ describe "#verify" do
19
+ it "should return false if the key is bad" do
20
+ FakeWeb.register_uri(:get,
21
+ 'http://service.afterthedeadline.com/verify?key=badkey',
22
+ :body => "invalid\n")
23
+ result = Deadlinez::Api.verify('badkey')
24
+ result.should be_false
25
+ end
26
+
27
+ it "should return true if the key is good" do
28
+ FakeWeb.register_uri(:get,
29
+ 'http://service.afterthedeadline.com/verify?key=goodkey',
30
+ :body => "valid\n")
31
+ result = Deadlinez::Api.verify('goodkey')
32
+ result.should be_true
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe Deadlinez::Proxy do
4
+ describe "#fire_request" do
5
+ it "should remove action and controller"
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Tue, 24 Nov 2009 01:21:12 GMT
4
+ Content-Type: text/xml
5
+ Transfer-Encoding: chunked
6
+ Connection: close
7
+ Set-Cookie: session=testkey;EXPIRES=Wed, 24-Nov-2010 01:21:12 GMT; PATH=/
8
+
9
+ <scores>
10
+ <metric>
11
+ <type>spell</type>
12
+ <key>raw</key>
13
+ <value>4</value>
14
+ </metric> <metric>
15
+ <type>stats</type>
16
+ <key>sentences</key>
17
+ <value>6</value>
18
+ </metric> <metric>
19
+ <type>stats</type>
20
+ <key>words</key>
21
+ <value>141</value>
22
+ </metric> <metric>
23
+ <type>style</type>
24
+ <key>passive voice</key>
25
+ <value>1</value>
26
+ </metric></scores>
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'deadlinez'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ require 'fakeweb'
8
+ FakeWeb.allow_net_connect = false
9
+
10
+ def fixture_path(file)
11
+ File.dirname(__FILE__) + "/fixtures/#{file}"
12
+ end
13
+
14
+ def fixture_for(file)
15
+ File.read(fixture_path(file))
16
+ end
17
+
18
+ Spec::Runner.configure do |config|
19
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deadlinez
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - David Balatero
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-08 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.2.9
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: fakeweb
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: httparty
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ description: Makes it easy to handle After the Deadline AJAX proxying and their API.
46
+ email: david@bitwax.cd
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ files:
55
+ - .document
56
+ - .gitignore
57
+ - LICENSE
58
+ - README.rdoc
59
+ - Rakefile
60
+ - VERSION
61
+ - lib/deadlinez.rb
62
+ - lib/deadlinez/api.rb
63
+ - lib/deadlinez/proxy.rb
64
+ - spec/deadlinez/api_spec.rb
65
+ - spec/deadlinez/proxy_spec.rb
66
+ - spec/fixtures/stats.response
67
+ - spec/spec.opts
68
+ - spec/spec_helper.rb
69
+ has_rdoc: true
70
+ homepage: http://github.com/dbalatero/deadlinez
71
+ licenses: []
72
+
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --charset=UTF-8
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ version:
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: "0"
89
+ version:
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.3.5
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Makes it easy to handle After the Deadline AJAX proxying and their API.
97
+ test_files:
98
+ - spec/deadlinez/api_spec.rb
99
+ - spec/deadlinez/proxy_spec.rb
100
+ - spec/spec_helper.rb