img_cloud 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8024161d4e930ed2b1dd28ca5d1ec96550ce150d
4
- data.tar.gz: 9b143da54b615cfed60d13454656c79d55592806
3
+ metadata.gz: 775278098e694a47028a7c81bff7aebe52ed4f07
4
+ data.tar.gz: 459a135ceaa242c2c3540dbfe879d34aed10fb88
5
5
  SHA512:
6
- metadata.gz: 62781c95ab6bdf59cf69de497e3b088f32249eac1f80bc43831980236f14c04d519f90cc7e4cd801dcbbf23819f456d33e247488ba6bdbb43aa8097f156a6a48
7
- data.tar.gz: 49c90aac9d444cfe41343d7d2502d699f1abb03ad926631e93acf54a137eaca3e992844d188ee94f5b2895303f9fe9fefe587d2945d52f2377651b101a9b6a16
6
+ metadata.gz: 9029cbc0d074663d017bc92bf17ae62133a2d5835875ed8e7a9705b068d0d8713decb46c711139ee4696443e30a2af264ff5927f878d66c19953797d26dc2210
7
+ data.tar.gz: 5bd5d4bc8e2b37440e2ef5959a0d1b2d918c1c1e7c0d122ff079a48605edb78c27d0ec1d575a5cfd1e7c097674f35ab8e335588cc39a3fbd34244b9a8c76c32a
data/.gitignore CHANGED
@@ -28,8 +28,8 @@ build/
28
28
  # for a library or gem, you might want to ignore these files since the code is
29
29
  # intended to run in multiple environments; otherwise, check them in:
30
30
  # Gemfile.lock
31
- # .ruby-version
32
- # .ruby-gemset
31
+ .ruby-version
32
+ .ruby-gemset
33
33
 
34
34
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
35
  .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 2.1
6
+ - 2.2
7
+
8
+ script: 'bundle exec rake'
9
+
10
+ notifications:
11
+ email:
12
+ recipients:
13
+ - rahul@liftoffllc.com
14
+ on_failure: change
15
+ on_success: never
data/Gemfile.lock CHANGED
@@ -2,53 +2,71 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  img_cloud (0.1.0)
5
- multipart-post
5
+ multipart-post (~> 2.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionpack (4.2.4)
11
- actionview (= 4.2.4)
12
- activesupport (= 4.2.4)
13
- rack (~> 1.6)
14
- rack-test (~> 0.6.2)
15
- rails-dom-testing (~> 1.0, >= 1.0.5)
16
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
- actionview (4.2.4)
18
- activesupport (= 4.2.4)
19
- builder (~> 3.1)
10
+ actionpack (3.2.22)
11
+ activemodel (= 3.2.22)
12
+ activesupport (= 3.2.22)
13
+ builder (~> 3.0.0)
20
14
  erubis (~> 2.7.0)
21
- rails-dom-testing (~> 1.0, >= 1.0.5)
22
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
23
- activesupport (4.2.4)
24
- i18n (~> 0.7)
25
- json (~> 1.7, >= 1.7.7)
26
- minitest (~> 5.1)
27
- thread_safe (~> 0.3, >= 0.3.4)
28
- tzinfo (~> 1.1)
29
- builder (3.2.2)
15
+ journey (~> 1.0.4)
16
+ rack (~> 1.4.5)
17
+ rack-cache (~> 1.2)
18
+ rack-test (~> 0.6.1)
19
+ sprockets (~> 2.2.1)
20
+ activemodel (3.2.22)
21
+ activesupport (= 3.2.22)
22
+ builder (~> 3.0.0)
23
+ activesupport (3.2.22)
24
+ i18n (~> 0.6, >= 0.6.4)
25
+ multi_json (~> 1.0)
26
+ addressable (2.3.8)
27
+ backports (3.6.6)
28
+ builder (3.0.4)
29
+ coderay (1.1.0)
30
30
  diff-lcs (1.2.5)
31
31
  erubis (2.7.0)
32
+ ethon (0.7.4)
33
+ ffi (>= 1.3.0)
34
+ faraday (0.9.1)
35
+ multipart-post (>= 1.2, < 3)
36
+ faraday_middleware (0.10.0)
37
+ faraday (>= 0.7.4, < 0.10)
38
+ ffi (1.9.10)
39
+ gh (0.14.0)
40
+ addressable
41
+ backports
42
+ faraday (~> 0.8)
43
+ multi_json (~> 1.0)
44
+ net-http-persistent (>= 2.7)
45
+ net-http-pipeline
46
+ highline (1.7.3)
47
+ hike (1.2.3)
32
48
  i18n (0.7.0)
49
+ journey (1.0.4)
33
50
  json (1.8.3)
34
- loofah (2.0.3)
35
- nokogiri (>= 1.5.9)
36
- mini_portile (0.6.2)
37
- minitest (5.8.0)
51
+ launchy (2.4.3)
52
+ addressable (~> 2.3)
53
+ method_source (0.8.2)
54
+ multi_json (1.11.2)
38
55
  multipart-post (2.0.0)
39
- nokogiri (1.6.6.2)
40
- mini_portile (~> 0.6.0)
41
- rack (1.6.4)
56
+ net-http-persistent (2.9.4)
57
+ net-http-pipeline (1.0.1)
58
+ pry (0.9.12.6)
59
+ coderay (~> 1.0)
60
+ method_source (~> 0.8)
61
+ slop (~> 3.4)
62
+ pusher-client (0.6.2)
63
+ json
64
+ websocket (~> 1.0)
65
+ rack (1.4.7)
66
+ rack-cache (1.2)
67
+ rack (>= 0.4)
42
68
  rack-test (0.6.3)
43
69
  rack (>= 1.0)
44
- rails-deprecated_sanitizer (1.0.3)
45
- activesupport (>= 4.2.0.alpha)
46
- rails-dom-testing (1.0.7)
47
- activesupport (>= 4.2.0.beta, < 5.0)
48
- nokogiri (~> 1.6.0)
49
- rails-deprecated_sanitizer (>= 1.0.1)
50
- rails-html-sanitizer (1.0.2)
51
- loofah (~> 2.0)
52
70
  rake (10.4.2)
53
71
  rspec (3.3.0)
54
72
  rspec-core (~> 3.3.0)
@@ -63,16 +81,35 @@ GEM
63
81
  diff-lcs (>= 1.2.0, < 2.0)
64
82
  rspec-support (~> 3.3.0)
65
83
  rspec-support (3.3.0)
66
- thread_safe (0.3.5)
67
- tzinfo (1.2.2)
68
- thread_safe (~> 0.1)
84
+ slop (3.6.0)
85
+ sprockets (2.2.3)
86
+ hike (~> 1.2)
87
+ multi_json (~> 1.0)
88
+ rack (~> 1.0)
89
+ tilt (~> 1.1, != 1.3.0)
90
+ tilt (1.4.1)
91
+ travis (1.8.0)
92
+ addressable (~> 2.3)
93
+ backports
94
+ faraday (~> 0.9)
95
+ faraday_middleware (~> 0.9, >= 0.9.1)
96
+ gh (~> 0.13)
97
+ highline (~> 1.6)
98
+ launchy (~> 2.1)
99
+ pry (~> 0.9, < 0.10)
100
+ pusher-client (~> 0.4)
101
+ typhoeus (~> 0.6, >= 0.6.8)
102
+ typhoeus (0.7.3)
103
+ ethon (>= 0.7.4)
104
+ websocket (1.2.2)
69
105
 
70
106
  PLATFORMS
71
107
  ruby
72
108
 
73
109
  DEPENDENCIES
74
- actionpack
110
+ actionpack (~> 3.2.0)
75
111
  bundler (~> 1.8)
76
112
  img_cloud!
77
113
  rake (~> 10.0)
78
- rspec
114
+ rspec (>= 3.2)
115
+ travis (~> 1.8.0)
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Rahul Singh
3
+ Copyright (c) 2015 LiftOff LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # ImgCloud
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/img_cloud`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ ruby gem for img cloud. Uploading images will return image path that can be then used in a helper tag to transform images.
6
4
 
7
5
  ## Installation
8
6
 
@@ -23,18 +21,42 @@ Or install it yourself as:
23
21
  ## Usage
24
22
  you can configure api key and base uri for the gem like this in an initializer
25
23
 
24
+ ```ruby
26
25
  ImgCloud.configure do |config|
27
- config.base_uri = 'http://img-cloud.liftoffllc.in/' #optional
26
+ config.base_uri = 'http://www.imgcloud.io/' #optional
28
27
  config.apiKey = 'f837dje0-4c99-11e5-a2ca-27ben7f17568' #required
29
28
  end
29
+ ```
30
+
31
+ ### Uploading an Image
30
32
 
31
- The methods are as follows:
33
+ ```ruby
34
+ ImgCloud.upload(image_path, tags, folder) # parameters => path(required), tags (optional, comma separated string) & folder (optional)
35
+ ```
32
36
 
33
- ImgCloud.upload # parameters => path(required), tags (optional, comma separated string) & folder (optional )
37
+ ### Helper method for Image tag
34
38
 
35
- ImgCloud.transform #parameters image_path(required, from the upload response), options(hash, height & width)
39
+ ```ruby
40
+ img_cloud_tag image_path, options
41
+ ```
42
+
43
+ #### Options:
44
+
45
+ parameters | Type
46
+ ---------------------------------------|------
47
+ height, width, borderWidth, blur | Integer
48
+ borderColor, class, style, alt, title | String
49
+ sepia, grayscale, crop, scale | Boolean
50
+
51
+
52
+ #### Example:
53
+
54
+ ```ruby
55
+ img_cloud_tag "/ic_4e1756/1440667545769_1436524274_car1.jpg", :width => 100, :height => 100, :sepia => true, :borderWidth => 5, :borderColor => 'red', :class => 'img_class', :style => "margin:10px"
56
+ ```
57
+ displays a transformed image, accepts a relative image path and optional parameters.
58
+ If the parameters are incorrect, it is not applied to the image.
36
59
 
37
- helper method :
38
60
  ## Development
39
61
 
40
62
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
data/Rakefile CHANGED
@@ -1,4 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
2
3
 
3
4
  Dir.glob('tasks/**/*.rake').each(&method(:import))
4
5
 
6
+ # Default directory to look within is `/specs`
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
10
+
data/img_cloud.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  # end
15
15
 
16
16
  spec.summary = %q{ruby gem for img cloud, upload/transform images}
17
- #spec.description = %q{TODO: Write a longer description or delete this line.}
17
+ spec.description = %q{ruby gem for img cloud, upload/transform images}
18
18
  spec.homepage = "https://github.com/img-cloud/ruby_gem"
19
19
  spec.license = "MIT"
20
20
 
@@ -25,8 +25,9 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.8"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency 'rspec', '~> 0'
28
+ spec.add_development_dependency 'rspec', '>= 3.2'
29
29
 
30
- spec.add_runtime_dependency 'multipart-post', '~> 0'
31
- spec.add_development_dependency "actionpack", '~> 0'
30
+ spec.add_runtime_dependency 'multipart-post', '~> 2.0.0'
31
+ spec.add_development_dependency "actionpack", "~> 3.2.0"
32
+ spec.add_development_dependency 'travis', '~> 1.8.0'
32
33
  end
@@ -1,10 +1,10 @@
1
1
  module ImgCloud
2
- class Configuration
3
- attr_accessor :base_uri, :apiKey
2
+ class Configuration
3
+ attr_accessor :base_uri, :apiKey, :upload_endpoint
4
4
 
5
- def initialize
6
- @base_uri = 'http://img-cloud.liftoffllc.in/'
7
- #@apiKey = 'f8341be0-4c99-11e5-a2ca-27be34e17568'
8
- end
9
- end
5
+ def initialize
6
+ @base_uri = 'http://www.imgcloud.io'
7
+ @upload_endpoint = '/upload'
8
+ end
9
+ end
10
10
  end
@@ -1,8 +1,19 @@
1
1
  module ImgCloudHelper
2
-
3
- def img_cloud_tag(img_path, options = {})
4
- height = "height=\"#{options[:height]}\"" if (options[:height].to_i > 0)
5
- width = "width=\"#{options[:width]}\"" if (options[:width].to_i > 0)
6
- "<img src=\"#{ImgCloud.transform_url(img_path, options)}\" #{height} #{width}>"
7
- end
2
+ # displays a transformed image, accepts a relative image path and height width parameters. Additional parameters if any are ignored,
3
+ # and the original image is displayed if no or invalid height width parameters are provided.
4
+
5
+ # Example
6
+ #
7
+ # img_cloud_tag "/ic_4e1756/1440667545769_1436524274_car1.jpg", :width=>100, :height=>100
8
+
9
+ def img_cloud_tag(img_path, options = {})
10
+ height = "height=\"#{options[:height]}\"" if (options[:height].to_i > 0)
11
+ width = "width=\"#{options[:width]}\"" if (options[:width].to_i > 0)
12
+ dom_class = "class=\"#{options[:class]}\"" if options[:class]
13
+ alt = "alt=\"#{options[:alt]}\"" if options[:alt]
14
+ title = "title=\"#{options[:title]}\"" if options[:title]
15
+ style = "style=\"#{options[:style]}\"" if options[:style]
16
+
17
+ "<img src=\"#{ImgCloud.request_url(img_path, options)}\" #{height} #{width} #{dom_class} #{alt} #{title} #{style}>"
18
+ end
8
19
  end
@@ -1,3 +1,3 @@
1
1
  module ImgCloud
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/img_cloud.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require "img_cloud/version"
2
2
  require "img_cloud/configuration"
3
3
  require 'net/http/post/multipart'
4
- #require 'net/http'
5
4
  require 'json'
6
5
 
7
6
  module ImgCloud
@@ -17,38 +16,43 @@ module ImgCloud
17
16
  def self.reset
18
17
  @configuration = Configuration.new
19
18
  end
20
- # def self.sign_up(email, firstname, lastname, company, password)
21
- # params = {'email' => email, 'firstName' => firstname, 'lastName' => lastname, 'company' => company, 'password' => password}
22
- # json_headers = {"Content-Type" => "application/json",
23
- # "Accept" => "application/json"}
24
- # uri = URI.parse('http://img-cloud.herokuapp.com/users')
25
- # http = Net::HTTP.new(uri.host, uri.port)
26
- # res = http.post(uri.path, params.to_json, json_headers)
27
- # res.body
28
- # end
29
-
19
+
20
+ # Uploads the image, returns the image url and tags and folder in json format
21
+ # accepts image path as required parameter, and tags ( comma separated string ), folder ( string ) as optional parameters
30
22
  def self.upload(path, tags, folder)
31
- uri = URI.parse("#{ImgCloud.configuration.base_uri}/upload")
23
+ uri = URI.parse("#{ImgCloud.configuration.base_uri}#{ImgCloud.configuration.upload_endpoint}")
32
24
  req = Net::HTTP::Post::Multipart.new uri.path,
33
- "image" => UploadIO.new(File.new(path), "image/jpg", "image.jpg"),
25
+ "image" => UploadIO.new(File.new(path), "image/jpg", path.split('/').last),
34
26
  "tags" => tags, "apiKey" => ImgCloud.configuration.apiKey, "folder" => folder
35
27
 
36
28
  res = Net::HTTP.start(uri.host, uri.port) do |http|
37
29
  http.request(req)
38
30
  end
39
31
  end
40
-
32
+
33
+ # return the image as byte data,
34
+ # accepts a relative image path and height width parameters.
41
35
  def self.transform(image_path, options = {})
42
- uri = URI.parse(transform_url(image_path, options))
36
+ uri = URI.parse(request_url(image_path, options))
43
37
  http = Net::HTTP.new(uri.host, uri.port)
44
38
  http.get(uri.path)
45
39
  end
46
40
 
47
- def self.transform_url(image_path, options = {})
41
+ # returns image url for img_cloud_tag helper
42
+ # accepts a relative image path and height width parameters.
43
+ def self.request_url(image_path, options = {})
48
44
  transform_args = []
49
45
 
50
46
  transform_args << "h_#{options[:height]}" if (options[:height].to_i > 0)
51
47
  transform_args << "w_#{options[:width]}" if (options[:width].to_i > 0)
48
+ transform_args << "blur_#{options[:blur]}" if (options[:blur].to_i > 0)
49
+ transform_args << "sepia" if options[:sepia]
50
+ transform_args << "crop" if options[:crop]
51
+ transform_args << "scale" if options[:scale]
52
+ transform_args << "grayscale" if options[:grayscale]
53
+ if (options[:borderWidth].to_i > 0) or options[:borderColor]
54
+ transform_args << "bdr_#{options[:borderWidth]}-#{options[:borderColor]}"
55
+ end
52
56
 
53
57
  args = transform_args.join(',')
54
58
 
@@ -58,8 +62,7 @@ module ImgCloud
58
62
  parts.delete_at(1)
59
63
  else
60
64
  parts[1] = args
61
- end
62
-
65
+ end
63
66
  ImgCloud.configuration.base_uri + parts.join('/')
64
67
  end
65
68
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: img_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahul Singh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-31 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,45 +42,59 @@ dependencies:
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: multipart-post
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 2.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 2.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: actionpack
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 3.2.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.2.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: travis
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.8.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '0'
83
- description:
96
+ version: 1.8.0
97
+ description: ruby gem for img cloud, upload/transform images
84
98
  email:
85
99
  - flytorahul00@gmail.com
86
100
  executables: []
@@ -88,6 +102,7 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - ".gitignore"
105
+ - ".travis.yml"
91
106
  - CODE_OF_CONDUCT.md
92
107
  - Gemfile
93
108
  - Gemfile.lock