blitline 1.4.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -7,9 +7,8 @@ source "http://rubygems.org"
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
9
  gem "shoulda", ">= 0"
10
- gem "bundler", "~> 1.0.0"
11
10
  gem "jeweler", "~> 1.6.4"
12
11
  gem "rcov", ">= 0"
13
12
  end
14
13
 
15
- gem 'yajl-ruby', :require => 'yajl'
14
+ gem 'multi_json'
data/Gemfile.lock CHANGED
@@ -6,17 +6,16 @@ GEM
6
6
  bundler (~> 1.0)
7
7
  git (>= 1.2.5)
8
8
  rake
9
+ multi_json (1.3.6)
9
10
  rake (0.9.2.2)
10
11
  rcov (0.9.11)
11
12
  shoulda (2.11.3)
12
- yajl-ruby (1.1.0)
13
13
 
14
14
  PLATFORMS
15
15
  ruby
16
16
 
17
17
  DEPENDENCIES
18
- bundler (~> 1.0.0)
19
18
  jeweler (~> 1.6.4)
19
+ multi_json
20
20
  rcov
21
21
  shoulda
22
- yajl-ruby
data/README.rdoc CHANGED
@@ -1,8 +1,8 @@
1
- Getting Started
1
+ # Getting Started
2
2
 
3
3
  You must first have a Blitline.com account to successfully use the gem. You can obtain one (free) by going to http://www.blitline.com
4
4
 
5
- Once you have your account, you will need to find you ACCOUNT_ID which you can get by logging in and clicking on the *Account* tab.
5
+ Once you have your account, you will need to find you APPLICATION_ID which you can get by logging in and clicking on the *Account* tab.
6
6
 
7
7
 
8
8
  In you application environment, install the Blitline gem or add the Blitline gem to your Gemfile
@@ -13,24 +13,57 @@ or...if you have a Gemfile
13
13
 
14
14
  gem 'blitline'
15
15
 
16
+ *Note: We have changed our recommended method of submitting Blitline jobs to just submitting job hashes instead of building
17
+ objects through an object model. This is because the Blitline API changes and evolves faster than people can/want to update their gems.
18
+ Old ways will still work, they will just not be used in documentation going forward. Since Blitline works via a JSON API, it is
19
+ easier to understand the hierarchy of the job when viewed as a hash. (You can find some old object based documentation [here](https://github.com/blitline-dev/blitline/wiki))*
20
+
21
+ Learn more about [job hashes](http://www.blitline.com/docs/api) and see some related JSON [examples](http://www.blitline.com/docs/examples)
22
+
23
+ ## The new preferred method is as follows:
24
+
16
25
  Once the gem is installed, you can start a Rails console and try the following:
17
26
 
18
- $ job = Blitline::Job.new("http://www.google.com/logos/2011/yokoyama11-hp.jpg") # My source file to manipulate
19
- $ job.application_id = "ACCOUNT_ID" # This ACCOUNT_ID needs to be your account ID from Blitline which you got from Blitline.com above
20
- $ blur_function = job.add_function("blur", {:radius => 1}) # Add a blur function
21
- $ blur_function.add_save("my_first_image") # Adds a save function (which takes a string parameter which is what the image is identified as on callback/polling)
22
27
  $ blitline_service = Blitline.new
23
- $ blitline_service.jobs << job # Push job into service
28
+ $ blitline_service.add_job_via_hash({
29
+ "application_id"=>"YOUR_APP_ID",
30
+ "src"=>"http://cdn.blitline.com/filters/boys.jpeg",
31
+ "functions"=>[
32
+ {
33
+ "name"=>"resize_to_fit",
34
+ "params"=>{
35
+ "width"=>100
36
+ },
37
+ "save"=>{
38
+ "image_identifier"=>"MY_CLIENT_ID"
39
+ }
40
+ }
41
+ ]
42
+ })
24
43
  $ blitline_service.post_jobs
25
44
 
26
- And you will get JSON back describing where the resulting image will be located
27
- There are many more things you can do with images (including pushing them to your own S3 buckets).
45
+ The resulting JSON will look something like:
46
+
47
+ ```js
48
+ {"results":{"images":[{"image_identifier":"MY_CLIENT_ID", "s3_url":"http://s3.amazonaws.com/blitline/9393939393/99/6CPGskk11mM-B8zaCYUJzqbw.jpg"}] ,"job_id":"4JVyFJBIhlpHNXLK-YClq5g"}}
49
+ ```
28
50
 
51
+ This JSON contains:
29
52
 
30
- You can find documentation about Blitline.com and it's services by following the links below
31
- Further reading:
53
+ - Any error information that may have happened with the submit
54
+ - A list of images
55
+ - Each image has an `image_indentifier`, which is the `image_identifier` you used in the `save` params.
56
+ - Each image also has an `s3_url` which is the final destination of the image (once it is done processing).
57
+
58
+ ### Important! ###
59
+ This result does not indicate that the job is done! The job has been put on a queue and will be done shortly. The best
60
+ way to identify when the job is completed is by adding a `postback_url` to the job hash and we will call back that url
61
+ when we have completed the image processing.
62
+
63
+
64
+ The example above is a trivial (and pretty uninteresting) demonstration of how to use the Blitline gem. You can find documentation about Blitline.com and it's services by following the links below
32
65
 
33
66
  * [Quickstart](http://www.blitline.com/docs/quickstart)
34
67
  * [Blitline Blog](http://blitline.tumblr.com)
35
-
68
+ * [See all the available functions](http://www.blitline.com/docs/functions)
36
69
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.0
1
+ 2.0.1
data/blitline.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "blitline"
8
- s.version = "1.4.0"
8
+ s.version = "2.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Blitline LLC"]
12
- s.date = "2012-10-12"
12
+ s.date = "2012-11-22"
13
13
  s.description = "The blitline gems provides a simple easy wrapper to the Blitline.com web api"
14
14
  s.email = "support@blitline.com"
15
15
  s.extra_rdoc_files = [
@@ -46,22 +46,19 @@ Gem::Specification.new do |s|
46
46
  s.specification_version = 3
47
47
 
48
48
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
- s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
49
+ s.add_runtime_dependency(%q<multi_json>, [">= 0"])
50
50
  s.add_development_dependency(%q<shoulda>, [">= 0"])
51
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
52
51
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
53
52
  s.add_development_dependency(%q<rcov>, [">= 0"])
54
53
  else
55
- s.add_dependency(%q<yajl-ruby>, [">= 0"])
54
+ s.add_dependency(%q<multi_json>, [">= 0"])
56
55
  s.add_dependency(%q<shoulda>, [">= 0"])
57
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
58
56
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
59
57
  s.add_dependency(%q<rcov>, [">= 0"])
60
58
  end
61
59
  else
62
- s.add_dependency(%q<yajl-ruby>, [">= 0"])
60
+ s.add_dependency(%q<multi_json>, [">= 0"])
63
61
  s.add_dependency(%q<shoulda>, [">= 0"])
64
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
65
62
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
66
63
  s.add_dependency(%q<rcov>, [">= 0"])
67
64
  end
data/lib/blitline.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Blitline
2
- require 'yajl'
2
+ require 'multi_json'
3
3
  require 'blitline/attribute_jsonizer'
4
4
  require 'blitline/function'
5
5
  require 'blitline/job'
@@ -33,15 +33,24 @@ class Blitline
33
33
  @jobs << job
34
34
  end
35
35
 
36
+ def add_job_via_hash(hash)
37
+ @jobs << hash
38
+ end
39
+
36
40
  def validate
37
41
  raise "At least 1 job must be present to run" if @jobs.length < 1
38
- @jobs.each { |j| j.validate }
42
+ @jobs.each do |j|
43
+ unless j.is_a?(Hash)
44
+ j.validate
45
+ end
46
+ end
39
47
  end
40
48
 
41
49
  def post_jobs
42
50
  validate
43
- result = Blitline::HttpPoster.post("http://api.blitline.com/job", { :json => Yajl::Encoder.encode(@jobs)})
44
- return Yajl::Parser.parse(result)
51
+ # puts MultiJson.dump(@jobs).inspect
52
+ result = Blitline::HttpPoster.post("http://api.blitline.com/job", { :json => MultiJson.dump(@jobs)})
53
+ return MultiJson.load(result)
45
54
  end
46
55
 
47
56
  end
@@ -1,18 +1,18 @@
1
1
  module AttributeJsonizer
2
- require 'yajl'
2
+ require 'multi_json'
3
3
 
4
4
  def add_jsonizable_attribute(json_name, jsonizeable_object)
5
5
  self.class.module_eval { attr_accessor json_name.to_sym}
6
6
  self.send("#{json_name.to_s}=", jsonizeable_object)
7
7
  end
8
8
 
9
- def to_json
9
+ def to_json(options)
10
10
  json_hash = {}
11
11
  self.instance_variables.each do |iv|
12
12
  key = iv
13
13
  value = self.instance_variable_get(iv)
14
14
  json_hash[key.to_s.gsub("@","")] = value unless value.kind_of?(Array) && value.length == 0 #Bail on empty arrays
15
15
  end
16
- Yajl::Encoder.encode(json_hash)
16
+ MultiJson.dump(json_hash)
17
17
  end
18
18
  end
@@ -1,4 +1,5 @@
1
1
  require 'helper'
2
+ require 'multi_json'
2
3
 
3
4
  class TestBlitline < Test::Unit::TestCase
4
5
 
@@ -58,7 +59,7 @@ class TestBlitline < Test::Unit::TestCase
58
59
  job.application_id = "foo"
59
60
  job.add_jsonizable_attribute("pre_process", { "move_original" => { "s3_destination" => Blitline::S3Destination.new("my_key","my_bucket")}})
60
61
 
61
- results = Yajl::Encoder.encode(job)
62
+ results = MultiJson.dump(job)
62
63
  assert_not_nil results["pre_process"]
63
64
  assert results == '{"src":"http://ww.foo.com","functions":[{"name":"blue","save":{"image_identifier":"my_image"}}],"application_id":"foo","pre_process":{"move_original":{"s3_destination":{"key":"my_key","bucket":"my_bucket","headers":{}}}}}'
64
65
  end
data/test/test_service.rb CHANGED
@@ -2,7 +2,7 @@ require 'helper'
2
2
 
3
3
  class TestService < Test::Unit::TestCase
4
4
  if ENV['BLITLINE_APPLICATION_ID']
5
- require 'yajl'
5
+ require 'multi_json'
6
6
  SAMPLE_IMAGE_SRC = "http://www.google.com/intl/en_com/images/srpr/logo3w.png"
7
7
 
8
8
  should "be able to commit a simple job to service" do
@@ -24,7 +24,30 @@ class TestService < Test::Unit::TestCase
24
24
  function.add_save("my_image", "grumpy_squirrel/frame2.jpg", "bltemp", { "x-amz-meta-foo" => "bar", "x-amz-meta-baz" => "qux"})
25
25
  blitline.jobs << job
26
26
  returned_values = blitline.post_jobs
27
- puts "----", returned_values.inspect
27
+ assert(returned_values.length > 0, "No results returned")
28
+ assert(returned_values['results'][0]['images'].length > 0, "No images returned")
29
+ end
30
+
31
+ should "be able to add job via hash" do
32
+ blitline = Blitline.new
33
+ blitline.add_job_via_hash({
34
+ "application_id"=>"#{ENV['BLITLINE_APPLICATION_ID']}",
35
+ "src"=>"http://cdn.blitline.com/filters/boys.jpeg",
36
+ "functions"=>[
37
+ {
38
+ "name"=>"resize_to_fit",
39
+ "params"=>{
40
+ "width"=>100
41
+ },
42
+ "save"=>{
43
+ "image_identifier"=>"MY_CLIENT_ID"
44
+ }
45
+ }
46
+ ]
47
+ })
48
+
49
+
50
+ returned_values = blitline.post_jobs
28
51
  assert(returned_values.length > 0, "No results returned")
29
52
  assert(returned_values['results'][0]['images'].length > 0, "No images returned")
30
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blitline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-12 00:00:00.000000000 Z
12
+ date: 2012-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: yajl-ruby
15
+ name: multi_json
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: bundler
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 1.0.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 1.0.0
62
46
  - !ruby/object:Gem::Dependency
63
47
  name: jeweler
64
48
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
117
  version: '0'
134
118
  segments:
135
119
  - 0
136
- hash: 334560143
120
+ hash: 71690003
137
121
  required_rubygems_version: !ruby/object:Gem::Requirement
138
122
  none: false
139
123
  requirements: