img_cloud 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8024161d4e930ed2b1dd28ca5d1ec96550ce150d
4
+ data.tar.gz: 9b143da54b615cfed60d13454656c79d55592806
5
+ SHA512:
6
+ metadata.gz: 62781c95ab6bdf59cf69de497e3b088f32249eac1f80bc43831980236f14c04d519f90cc7e4cd801dcbbf23819f456d33e247488ba6bdbb43aa8097f156a6a48
7
+ data.tar.gz: 49c90aac9d444cfe41343d7d2502d699f1abb03ad926631e93acf54a137eaca3e992844d188ee94f5b2895303f9fe9fefe587d2945d52f2377651b101a9b6a16
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in img_cloud.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ img_cloud (0.1.0)
5
+ multipart-post
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
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)
20
+ 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)
30
+ diff-lcs (1.2.5)
31
+ erubis (2.7.0)
32
+ i18n (0.7.0)
33
+ 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)
38
+ multipart-post (2.0.0)
39
+ nokogiri (1.6.6.2)
40
+ mini_portile (~> 0.6.0)
41
+ rack (1.6.4)
42
+ rack-test (0.6.3)
43
+ 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
+ rake (10.4.2)
53
+ rspec (3.3.0)
54
+ rspec-core (~> 3.3.0)
55
+ rspec-expectations (~> 3.3.0)
56
+ rspec-mocks (~> 3.3.0)
57
+ rspec-core (3.3.2)
58
+ rspec-support (~> 3.3.0)
59
+ rspec-expectations (3.3.1)
60
+ diff-lcs (>= 1.2.0, < 2.0)
61
+ rspec-support (~> 3.3.0)
62
+ rspec-mocks (3.3.2)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.3.0)
65
+ rspec-support (3.3.0)
66
+ thread_safe (0.3.5)
67
+ tzinfo (1.2.2)
68
+ thread_safe (~> 0.1)
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ actionpack
75
+ bundler (~> 1.8)
76
+ img_cloud!
77
+ rake (~> 10.0)
78
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Rahul Singh
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # ImgCloud
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
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'img_cloud'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install img_cloud
22
+
23
+ ## Usage
24
+ you can configure api key and base uri for the gem like this in an initializer
25
+
26
+ ImgCloud.configure do |config|
27
+ config.base_uri = 'http://img-cloud.liftoffllc.in/' #optional
28
+ config.apiKey = 'f837dje0-4c99-11e5-a2ca-27ben7f17568' #required
29
+ end
30
+
31
+ The methods are as follows:
32
+
33
+ ImgCloud.upload # parameters => path(required), tags (optional, comma separated string) & folder (optional )
34
+
35
+ ImgCloud.transform #parameters image_path(required, from the upload response), options(hash, height & width)
36
+
37
+ helper method :
38
+ ## Development
39
+
40
+ 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.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/[my-github-username]/img_cloud/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
4
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "img_cloud"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/img_cloud.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'img_cloud/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "img_cloud"
8
+ spec.version = ImgCloud::VERSION
9
+ spec.authors = ["Rahul Singh"]
10
+ spec.email = ["flytorahul00@gmail.com"]
11
+
12
+ # if spec.respond_to?(:metadata)
13
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
+ # end
15
+
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.}
18
+ spec.homepage = "https://github.com/img-cloud/ruby_gem"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.8"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency 'rspec', '~> 0'
29
+
30
+ spec.add_runtime_dependency 'multipart-post', '~> 0'
31
+ spec.add_development_dependency "actionpack", '~> 0'
32
+ end
@@ -0,0 +1,10 @@
1
+ module ImgCloud
2
+ class Configuration
3
+ attr_accessor :base_uri, :apiKey
4
+
5
+ def initialize
6
+ @base_uri = 'http://img-cloud.liftoffllc.in/'
7
+ #@apiKey = 'f8341be0-4c99-11e5-a2ca-27be34e17568'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
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
8
+ end
@@ -0,0 +1,8 @@
1
+ class ImgCloud::Railtie < Rails::Railtie
2
+ rake_tasks do
3
+ Dir[File.join(File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f }
4
+ end
5
+ config.after_initialize do |app|
6
+ ActionView::Base.send :include, ImgCloudHelper
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module ImgCloud
2
+ VERSION = "0.1.0"
3
+ end
data/lib/img_cloud.rb ADDED
@@ -0,0 +1,72 @@
1
+ require "img_cloud/version"
2
+ require "img_cloud/configuration"
3
+ require 'net/http/post/multipart'
4
+ #require 'net/http'
5
+ require 'json'
6
+
7
+ module ImgCloud
8
+
9
+ class << self
10
+ attr_accessor :configuration
11
+ end
12
+
13
+ def self.configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ def self.reset
18
+ @configuration = Configuration.new
19
+ 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
+
30
+ def self.upload(path, tags, folder)
31
+ uri = URI.parse("#{ImgCloud.configuration.base_uri}/upload")
32
+ req = Net::HTTP::Post::Multipart.new uri.path,
33
+ "image" => UploadIO.new(File.new(path), "image/jpg", "image.jpg"),
34
+ "tags" => tags, "apiKey" => ImgCloud.configuration.apiKey, "folder" => folder
35
+
36
+ res = Net::HTTP.start(uri.host, uri.port) do |http|
37
+ http.request(req)
38
+ end
39
+ end
40
+
41
+ def self.transform(image_path, options = {})
42
+ uri = URI.parse(transform_url(image_path, options))
43
+ http = Net::HTTP.new(uri.host, uri.port)
44
+ http.get(uri.path)
45
+ end
46
+
47
+ def self.transform_url(image_path, options = {})
48
+ transform_args = []
49
+
50
+ transform_args << "h_#{options[:height]}" if (options[:height].to_i > 0)
51
+ transform_args << "w_#{options[:width]}" if (options[:width].to_i > 0)
52
+
53
+ args = transform_args.join(',')
54
+
55
+ parts = image_path.rpartition('/')
56
+
57
+ if args.empty?
58
+ parts.delete_at(1)
59
+ else
60
+ parts[1] = args
61
+ end
62
+
63
+ ImgCloud.configuration.base_uri + parts.join('/')
64
+ end
65
+
66
+ def self.configure
67
+ yield(configuration)
68
+ end
69
+ end
70
+
71
+ require "img_cloud/helper" if defined?(::ActionView::Base)
72
+ require "img_cloud/railtie" if defined?(Rails) && defined?(Rails::Railtie)
data/tasks/rspec.rake ADDED
@@ -0,0 +1,3 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: img_cloud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rahul Singh
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: multipart-post
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: actionpack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - flytorahul00@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - CODE_OF_CONDUCT.md
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - img_cloud.gemspec
100
+ - lib/img_cloud.rb
101
+ - lib/img_cloud/configuration.rb
102
+ - lib/img_cloud/helper.rb
103
+ - lib/img_cloud/railtie.rb
104
+ - lib/img_cloud/version.rb
105
+ - tasks/rspec.rake
106
+ homepage: https://github.com/img-cloud/ruby_gem
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.6
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: ruby gem for img cloud, upload/transform images
130
+ test_files: []