wordy-ruby 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +4 -1
- data/VERSION +1 -1
- data/lib/wordy/account.rb +2 -2
- data/lib/wordy/job.rb +9 -9
- data/lib/wordy.rb +8 -5
- data/spec/wordy/job_spec.rb +2 -2
- data/wordy-ruby.gemspec +1 -1
- metadata +18 -18
data/README.markdown
CHANGED
@@ -16,6 +16,7 @@ require 'wordy'
|
|
16
16
|
Wordy.configure do |c|
|
17
17
|
c.api_key = ENV['WORDY_API_KEY']
|
18
18
|
c.username = ENV['WORDY_USERNAME']
|
19
|
+
c.env = 'production'
|
19
20
|
end
|
20
21
|
|
21
22
|
if Wordy::Account.balance > 0
|
@@ -25,4 +26,6 @@ if Wordy::Account.balance > 0
|
|
25
26
|
puts "Your text will be ready at: #{job.delivery_date}"
|
26
27
|
end
|
27
28
|
|
28
|
-
```
|
29
|
+
```
|
30
|
+
|
31
|
+
By default the Wordy environment is production, if you want to use the staging environment, set the 'env' attribute to 'staging'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/wordy/account.rb
CHANGED
@@ -2,13 +2,13 @@ module Wordy
|
|
2
2
|
class Account
|
3
3
|
class << self
|
4
4
|
def balance
|
5
|
-
response = Cli.http_get(Wordy
|
5
|
+
response = Cli.http_get(Wordy.wordy_url+'account/', {})
|
6
6
|
return nil if response.empty?
|
7
7
|
response['balance'].to_s.match(/[^0-9]?([0-9]+\.{0,1}[0-9]+)/)[1].to_f
|
8
8
|
end
|
9
9
|
|
10
10
|
def languages
|
11
|
-
Cli.http_get(Wordy
|
11
|
+
Cli.http_get(Wordy.wordy_url+'languages/', {})
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/wordy/job.rb
CHANGED
@@ -53,12 +53,12 @@ module Wordy
|
|
53
53
|
parameters[:content] = content
|
54
54
|
end
|
55
55
|
parameters = parameters.delete_if{|key, value| value.nil? }
|
56
|
-
response = Cli.http_post(Wordy
|
56
|
+
response = Cli.http_post(Wordy.wordy_url+'job/create/', parameters)
|
57
57
|
return new(response)
|
58
58
|
end
|
59
59
|
|
60
60
|
def all
|
61
|
-
response = Cli.http_get(Wordy
|
61
|
+
response = Cli.http_get(Wordy.wordy_url+"job/", {})
|
62
62
|
response.map do |job_id|
|
63
63
|
new({'id' => job_id})
|
64
64
|
end
|
@@ -78,34 +78,34 @@ module Wordy
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def info
|
81
|
-
response = Cli.http_get(Wordy
|
81
|
+
response = Cli.http_get(Wordy.wordy_url+"job/#{self.id}/", {})
|
82
82
|
set_attributes(response)
|
83
83
|
end
|
84
84
|
|
85
85
|
def edited_document
|
86
|
-
response = Cli.http_get(Wordy
|
86
|
+
response = Cli.http_get(Wordy.wordy_url+"job/#{self.id}/target/", {})
|
87
87
|
edited_content = response.values[0]
|
88
88
|
set_attributes({:edited_content => edited_content})
|
89
89
|
end
|
90
90
|
|
91
91
|
def conversation
|
92
|
-
Cli.http_get(Wordy
|
92
|
+
Cli.http_get(Wordy.wordy_url+"job/#{self.id}/conversation/", {})
|
93
93
|
end
|
94
94
|
|
95
95
|
def update_conversation(message)
|
96
|
-
Cli.http_post(Wordy
|
96
|
+
Cli.http_post(Wordy.wordy_url+"job/#{self.id}/conversation/", {'message' => message})
|
97
97
|
end
|
98
98
|
|
99
99
|
def pay!
|
100
|
-
Cli.http_post(Wordy
|
100
|
+
Cli.http_post(Wordy.wordy_url+"job/#{self.id}/pay/", {})
|
101
101
|
end
|
102
102
|
|
103
103
|
def confirm!
|
104
|
-
Cli.http_post(Wordy
|
104
|
+
Cli.http_post(Wordy.wordy_url+"job/#{self.id}/confirm/", {})
|
105
105
|
end
|
106
106
|
|
107
107
|
def reject!
|
108
|
-
Cli.http_post(Wordy
|
108
|
+
Cli.http_post(Wordy.wordy_url+"job/#{self.id}/reject/", {})
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
data/lib/wordy.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
require "net/http"
|
2
|
-
# require 'net/http/post/multipart'
|
3
|
-
# require 'digest/md5'
|
4
2
|
require 'uri'
|
5
3
|
require 'cgi'
|
6
4
|
require 'active_support'
|
7
|
-
# require 'active_support/hash_with_indifferent_access'
|
8
5
|
|
9
6
|
module Wordy
|
10
|
-
WORDY_URL
|
7
|
+
WORDY_URL = URI.parse('https://wordy.com/api/1.0/')
|
8
|
+
WORDY_STAGING_URL = URI.parse('https://staging.wordy.com/api/1.0/')
|
11
9
|
|
12
10
|
class << self
|
13
|
-
attr_accessor :api_key, :username
|
11
|
+
attr_accessor :api_key, :username, :env
|
14
12
|
|
15
13
|
# In your initializer:
|
16
14
|
# Wordy.configure do |c|
|
@@ -19,8 +17,13 @@ module Wordy
|
|
19
17
|
# end
|
20
18
|
#
|
21
19
|
def configure
|
20
|
+
self.env = 'production'
|
22
21
|
yield self
|
23
22
|
end
|
23
|
+
|
24
|
+
def wordy_url
|
25
|
+
self.env == 'production' ? WORDY_URL : WORDY_STAGING_URL
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
29
|
end
|
data/spec/wordy/job_spec.rb
CHANGED
@@ -34,7 +34,7 @@ describe Wordy::Job do
|
|
34
34
|
describe "Creating a new job" do
|
35
35
|
it "should create a new job with a title" do
|
36
36
|
Wordy::Cli.stub!(:http_post).and_return(wordy_job)
|
37
|
-
Wordy::Cli.should_receive(:http_post).with(Wordy
|
37
|
+
Wordy::Cli.should_receive(:http_post).with(Wordy.wordy_url+'job/create/', {
|
38
38
|
:language_id => 'en',
|
39
39
|
:intrusive_editing=>false,
|
40
40
|
:json => '{"My title":"My great content"}'
|
@@ -46,7 +46,7 @@ describe Wordy::Job do
|
|
46
46
|
|
47
47
|
it "should create a new job without a title" do
|
48
48
|
Wordy::Cli.stub!(:http_post).and_return(wordy_job)
|
49
|
-
Wordy::Cli.should_receive(:http_post).with(Wordy
|
49
|
+
Wordy::Cli.should_receive(:http_post).with(Wordy.wordy_url+'job/create/', {
|
50
50
|
:language_id => 'en',
|
51
51
|
:intrusive_editing=>false,
|
52
52
|
:content => 'My great content'
|
data/wordy-ruby.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wordy-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-18 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70168323893840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70168323893840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70168323893240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.2.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70168323893240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70168323892660 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.1.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70168323892660
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70168323892060 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70168323892060
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70168323891520 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.9.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70168323891520
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: shoulda
|
71
|
-
requirement: &
|
71
|
+
requirement: &70168323891000 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 3.0.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70168323891000
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70168323890480 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 2.9.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70168323890480
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: activesupport
|
93
|
-
requirement: &
|
93
|
+
requirement: &70168323889880 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: 3.2.2
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70168323889880
|
102
102
|
description: Ruby library to access the Wordy API
|
103
103
|
email: bastien.vaucher@gmail.com
|
104
104
|
executables: []
|
@@ -137,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
segments:
|
139
139
|
- 0
|
140
|
-
hash:
|
140
|
+
hash: 3462829428795377299
|
141
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
142
|
none: false
|
143
143
|
requirements:
|