owlproxy 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 46a769c21f77bb6f27123a317cf3555521664bdc
4
+ data.tar.gz: 5f93eb242c7fdb3a2d7e3a51257d834dadd3029c
5
+ SHA512:
6
+ metadata.gz: 58d24b73729053031d679ff1f75ec1439e73d7ad9eaa7e488fc21bab0cacd17875830087d6666fb6698498233baf954103a0905d93f61f8557e27d3169bb30de
7
+ data.tar.gz: e4c94e4d67a085b4a7608bbac0a9d5699e0db23cacb61980fdc11497dc03ed7ac7328eee608d316d5b704a500bd0efb16ba3f224eb1ce716ba78985d5b00bfb2
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in owlproxy.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Masayoshi Wada
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,46 @@
1
+ # Owlproxy
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'owlproxy'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install owlproxy
18
+
19
+ ## Usage
20
+
21
+ ### Start proxy server
22
+
23
+ If you installed with bundle, execute:
24
+
25
+ ```
26
+ $ bundle exec owlproxy
27
+ ```
28
+
29
+ Or if you executed `gem install owlproxy`, only have to do is:
30
+
31
+ ```
32
+ $ owlproxy
33
+ ```
34
+
35
+ ### Settings
36
+
37
+ Once you started the proxy server, `$HOME/.owlproxy.yml` is generated automatically. After edit the config file, you must restart the proxy server.
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/masawada/owlproxy.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
46
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "owlproxy"
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/owlproxy ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "owlproxy"
4
+
5
+ Process.daemon if OwlProxy::Settings.daemonize
6
+ OwlProxy::Server.run!
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/lib/owlproxy.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "owlproxy/version"
2
+ require "owlproxy/settings"
3
+ require "owlproxy/uploader"
4
+ require "owlproxy/server"
5
+
6
+ require "owlproxy/services/gyazo"
@@ -0,0 +1,9 @@
1
+ default_option: "gyazo"
2
+ daemonize: true
3
+ services:
4
+ gyazo:
5
+ default: &defaults
6
+ api_endpoint: "https://upload.gyazo.com/api/upload"
7
+ access_token: "ACCESS_TOKEN"
8
+ screen_name:
9
+ access_token: "OTHER_ACCESS_TOKEN"
@@ -0,0 +1,17 @@
1
+ require "sinatra/base"
2
+
3
+ module OwlProxy
4
+ class Server < Sinatra::Base
5
+ post '/upload' do
6
+ image_url = OwlProxy::Uploader.upload(
7
+ username: params[:username],
8
+ option_string: params[:message],
9
+ image: params[:media][:tempfile]
10
+ )
11
+
12
+ # generate response
13
+ content_type 'text/xml'
14
+ erb :result, locals: { image_url: image_url }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ require 'rest-client'
2
+ require 'json'
3
+
4
+ module OwlProxy
5
+ module Service
6
+ class Gyazo
7
+ def upload(config: nil, option: nil, image: nil, message: nil)
8
+ # generate request
9
+ request = RestClient::Request.new(
10
+ method: :post,
11
+ url: config['api_endpoint'],
12
+ payload: {
13
+ multipart: true,
14
+ access_token: config['access_token'],
15
+ imagedata: File.new(image)
16
+ }
17
+ )
18
+
19
+ response = request.execute
20
+ json = JSON.parse(response)
21
+
22
+ "#{json["permalink_url"]} #{json["url"]}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ OwlProxy::Uploader.register :gyazo, OwlProxy::Service::Gyazo
@@ -0,0 +1,18 @@
1
+ require "settingslogic"
2
+ require "fileutils"
3
+
4
+ CONFIG_FILE=".owlproxy.yml"
5
+ CONFIG_PATH="#{Dir.home}/#{CONFIG_FILE}"
6
+
7
+ module OwlProxy
8
+ # init config file
9
+ src = "#{File.dirname(__FILE__)}/config/owlproxy.yml.example"
10
+ dst = CONFIG_PATH
11
+ FileUtils.cp src, dst unless File.exist? dst
12
+
13
+ class Settings < Settingslogic
14
+ source CONFIG_PATH
15
+ load!
16
+ end
17
+ end
18
+
@@ -0,0 +1,29 @@
1
+ module OwlProxy
2
+ module Uploader
3
+ @uploaders = {}
4
+
5
+ def self.upload(username: '', option_string: '', image: path)
6
+ option_string = Settings.default_option if option_string.empty?
7
+ service_name, *option, message = option_string.split(':')
8
+
9
+ config = Settings.services[service_name][username]
10
+ config = Settings.services[service_name]['default'] if config.nil?
11
+
12
+ raise if @uploaders[service_name.to_sym].nil?
13
+ uploader = @uploaders[service_name.to_sym].new
14
+
15
+ uploader.upload(
16
+ config: config,
17
+ option: option,
18
+ image: image,
19
+ message: message
20
+ )
21
+ end
22
+
23
+ def self.register(name, service)
24
+ raise if name.nil?
25
+ raise if service.nil?
26
+ @uploaders[name.to_sym] = service
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Owlproxy
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <image>
3
+ <url><%= image_url %></url>
4
+ </image>
data/owlproxy.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'owlproxy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "owlproxy"
8
+ spec.version = Owlproxy::VERSION
9
+ spec.authors = ["Masayoshi Wada"]
10
+ spec.email = ["developer@andantesoftware.com"]
11
+
12
+ spec.summary = %q{image upload proxy for YoruFukurou}
13
+ spec.description = %q{image upload proxy for YoruFukurou. since non tested, it might have some problems.}
14
+ spec.homepage = "https://github.com/masawada/owlproxy"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = ["owlproxy"]
20
+ spec.default_executable = "owlproxy"
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "sinatra", "~> 1.4"
27
+ spec.add_development_dependency "settingslogic", "~> 2.0"
28
+ spec.add_development_dependency "rest-client", "~> 1.8"
29
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: owlproxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masayoshi Wada
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-25 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: sinatra
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: settingslogic
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '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: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rest-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.8'
97
+ description: image upload proxy for YoruFukurou. since non tested, it might have some
98
+ problems.
99
+ email:
100
+ - developer@andantesoftware.com
101
+ executables:
102
+ - owlproxy
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/owlproxy
115
+ - bin/setup
116
+ - lib/owlproxy.rb
117
+ - lib/owlproxy/config/owlproxy.yml.example
118
+ - lib/owlproxy/server.rb
119
+ - lib/owlproxy/services/gyazo.rb
120
+ - lib/owlproxy/settings.rb
121
+ - lib/owlproxy/uploader.rb
122
+ - lib/owlproxy/version.rb
123
+ - lib/owlproxy/views/result.erb
124
+ - owlproxy.gemspec
125
+ homepage: https://github.com/masawada/owlproxy
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.4.5
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: image upload proxy for YoruFukurou
149
+ test_files: []