bonsai_client 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: 0436aa3576974561c877f20e7ed166c0481329b9
4
+ data.tar.gz: 516009c69e91c5c26abc5ca827f85308a79a42eb
5
+ SHA512:
6
+ metadata.gz: 8e98178eafc87223eeef24fe87b86f1140741372510f6f4b2dee0d9821a3175f5e77455b8bf7027806a58586dd4e68f78579b6761314f4eb9cdbdc256dac2b89
7
+ data.tar.gz: df4534e6eafb5a2900a72b568161291d01a902982893b728544a402a248635d0500cf518ec63d9f6a0566137b09d7e504932f48f7af1debb40e4c09e277b651e
data/.gitignore ADDED
@@ -0,0 +1,57 @@
1
+
2
+ # Specific environment configuration
3
+ /config/environments/*
4
+ !/config/environments/.keep
5
+
6
+ # Custom
7
+ *.gem
8
+
9
+ # Ensure empty folders
10
+ /doc/*
11
+ !/doc/.keep
12
+
13
+ /pkg/*
14
+ !/pkg/.keep
15
+
16
+ /tmp/*
17
+ !/tmp/.keep
18
+
19
+ # Generated by gem bundle
20
+ /.bundle/
21
+ /.yardoc
22
+ /Gemfile.lock
23
+ /_yardoc/
24
+ /coverage/
25
+ # /doc
26
+ # /pkg
27
+ # /tmp
28
+ /spec/reports/
29
+
30
+ # Assets generators
31
+ .sass-cache
32
+
33
+ # Mac finder artifacts
34
+ .com.apple.timemachine.supported
35
+ .DS_Store
36
+ .DS_Store?
37
+ ._*
38
+ .Spotlight-V100
39
+ .Trashes
40
+ ehthumbs.db
41
+ Thumbs.db
42
+
43
+ # Linux artifacts
44
+ *~
45
+
46
+ # Netbeans project directory
47
+ /nbproject/
48
+
49
+ # Intellij files
50
+ .idea
51
+
52
+ # Textmate project files
53
+ /*.tmproj
54
+
55
+ # vim artifacts
56
+ **.swp
57
+
@@ -0,0 +1,10 @@
1
+ image: "ruby:2.4"
2
+
3
+ before_script:
4
+ - ruby -v
5
+ - gem install bundler --no-ri --no-rdoc
6
+ - bundle install
7
+
8
+ tests:
9
+ script:
10
+ - rake test
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5
5
+ - 2.4
6
+ - 2.3
7
+ - 2.2
8
+ - 2.1
9
+ - 2.0
10
+ branches:
11
+ only: master
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased]
4
+ * ...
5
+
6
+ ## [0.1.0] - 2019-03-01
7
+ * First version.
8
+
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gtemplate.gemspec
4
+ gemspec
5
+
6
+ group :test, :development do
7
+ gem 'minitest-reporters'
8
+ end
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ [![Gem Version](https://badge.fury.io/rb/bonsai_client.svg)](https://badge.fury.io/rb/bonsai_client)
2
+ [![Build Status](https://travis-ci.org/galfus/bonsai-client.svg?branch=master)](https://travis-ci.org/galfus/bonsai-client)
3
+
4
+ # Bonsai Client
5
+
6
+ ### NOTE
7
+
8
+ This gem is at an early stage of development. Please do not use it already.
9
+
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ gem install bonsai_client
15
+ ```
16
+
17
+ ## Usage in shell
18
+
19
+ ```bash
20
+ bonsai_client upload --url="http://bonsai-server.com" --path="/path/to/file"
21
+ ```
22
+
23
+ ## Usage in ruby code
24
+
25
+ ```ruby
26
+ # Require Bonsai Client gem.
27
+ require 'bonsai-client'
28
+
29
+ # Creata a new instance of Bonsai client:
30
+ bonsai = BonsaiClient.new(url: 'http://bonsai-server.com')
31
+
32
+ # Upload a file to a Bonsai server:
33
+ result = bonsai.upload(path: '/path/to/file')
34
+
35
+ # URL for a specific file in Bonsai sever:
36
+ src1 = bonsai.thumbnail_url(checksum: 'AF1...') # http://bonsai-server.com/thumbnails/AF1...
37
+ src2 = bonsai.thumbnail_url(name: 'myfile') # http://bonsai-server.com/...
38
+ src3 = bonsai.thumbnail_url(checksum: 'AF1...', size: :medium) # http://bonsai-server.com/thumbnails/AF1.../size/medium
39
+ ```
40
+
41
+ ## Development
42
+
43
+ ### Test
44
+
45
+ ```bash
46
+ bundle exec rake test
47
+ ```
48
+
49
+ ### Rake tasks
50
+
51
+ Crea una nueva versión de la gema (sin subirla a ruby gems pero sí a GitLab y GitHub):
52
+
53
+ ```bash
54
+ rake release
55
+ ```
56
+
57
+ Sube commits a los repositorios git:
58
+
59
+ ```bash
60
+ rake push
61
+ ```
62
+
63
+ Publica la última versión de la gema en Rubygems:
64
+
65
+ ```bash
66
+ rake push
67
+ ```
68
+
69
+ Muestar la versión actual de la gema:
70
+
71
+ ```bash
72
+ rake version
73
+ ```
74
+
75
+
76
+ ## License
77
+
78
+ The MIT License
79
+
80
+ Permission is hereby granted, free of charge, to any person obtaining a copy
81
+ of this software and associated documentation files (the "Software"), to deal
82
+ in the Software without restriction, including without limitation the rights
83
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
84
+ copies of the Software, and to permit persons to whom the Software is
85
+ furnished to do so, subject to the following conditions:
86
+
87
+ The above copyright notice and this permission notice shall be included in
88
+ all copies or substantial portions of the Software.
89
+
90
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
91
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
92
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
93
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
95
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
96
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,135 @@
1
+ require "rake/testtask"
2
+ require_relative "lib/bonsai_client/version"
3
+
4
+ def name
5
+ BonsaiClient::NAME
6
+ end
7
+
8
+ def version
9
+ BonsaiClient::VERSION
10
+ end
11
+
12
+ def gemspec_file
13
+ "#{name}.gemspec"
14
+ end
15
+
16
+ def gem_file
17
+ "#{name}-#{version}.gem"
18
+ end
19
+
20
+ def show_text(text)
21
+ puts ''
22
+ puts '================================================='
23
+ puts text
24
+ puts '================================================='
25
+ puts ''
26
+ end
27
+
28
+ def show_error_and_exit!(text)
29
+ show_text("ERROR: #{text}.")
30
+ exit!
31
+ end
32
+
33
+ def show_release
34
+ show_text("#{gem_file} released.")
35
+ end
36
+
37
+ def read_changelog
38
+ `head -20 CHANGELOG.md`.to_s
39
+ end
40
+
41
+ def current_branch
42
+ r = `git branch`.to_s.strip
43
+ if r.include? "master"
44
+ 'master'
45
+ else
46
+ 'other'
47
+ end
48
+ end
49
+
50
+ def git_status
51
+ r = `git status`.to_s
52
+ if r.include? "nothing to commit"
53
+ 'clean'
54
+ else
55
+ 'not_clean'
56
+ end
57
+ end
58
+
59
+ def ask_for_confirmation
60
+ puts "Are you sure you want to release version #{version}? [yN]"
61
+ STDIN.gets.chomp.upcase
62
+ end
63
+
64
+ Rake::TestTask.new do |t|
65
+ t.libs << 'test'
66
+ t.pattern = 'test/**/*_test.rb'
67
+ t.warning = false
68
+ t.verbose = false
69
+ end
70
+
71
+ task :default => :test
72
+
73
+ desc "Release #{gem_file} (only repository, not RubyGems)"
74
+ task :release => :build do
75
+ show_text ">> Releasing #{gem_file}"
76
+ if current_branch != 'master'
77
+ msg = "You must be on the master branch to release!"
78
+ show_error_and_exit! msg
79
+ end
80
+ if git_status != 'clean'
81
+ msg = "There are still files left to commit"
82
+ show_error_and_exit! msg
83
+ end
84
+ show_text ">> Changelog file"
85
+ puts read_changelog
86
+ show_text ">> Confirmation"
87
+ if ask_for_confirmation != 'Y'
88
+ show_error_and_exit! "Aborting release"
89
+ end
90
+ puts ""
91
+ sh "git commit --allow-empty -m 'Release #{version}'"
92
+ sh "git tag v#{version}"
93
+ puts ""
94
+ sh "git push origin master"
95
+ puts ""
96
+ sh "git push github master"
97
+ show_release
98
+ end
99
+
100
+ desc "Push code to the remote respositories"
101
+ task :push do
102
+ show_text ">> Pushing code to GitLab y GitHub"
103
+ puts ""
104
+ sh "git push origin master"
105
+ puts ""
106
+ sh "git push github master"
107
+ puts ""
108
+ end
109
+
110
+ desc "Build #{gem_file} into pkg folder"
111
+ task :build do
112
+ show_text ">> Creating #{gem_file}"
113
+ mkdir_p "pkg"
114
+ sh "gem build #{gemspec_file}"
115
+ sh "mv #{gem_file} pkg"
116
+ puts ""
117
+ end
118
+
119
+ desc "Publish #{gem_file} in RubyGems"
120
+ task :publish do
121
+ show_text ">> Publishing #{gem_file}"
122
+ puts ""
123
+ sh "gem push pkg/#{gem_file}"
124
+ puts ""
125
+ end
126
+
127
+ desc "Show current #{name} version"
128
+ task :version do
129
+ show_text("Version #{version}")
130
+ end
131
+
132
+
133
+
134
+
135
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bonsai_client"
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bonsai_client/version'
5
+
6
+ Gem::Specification.new do |s|
7
+
8
+ s.name = BonsaiClient::NAME
9
+ s.version = BonsaiClient::VERSION
10
+ s.authors = ["Manu"]
11
+ s.email = ["galfus@gmail.com"]
12
+ s.date = Time.now.strftime('%Y-%m-%d')
13
+ s.summary = %q{Client for a Bonsai server.}
14
+ s.description = %q{This gem is at an early stage of development. Please do not use it already.}
15
+ s.licenses = ['MIT']
16
+ s.homepage = "https://gitlab.com/galfuslab/bonsai-client"
17
+ all_files = `git ls-files -z`.split("\x0")
18
+ s.files = all_files
19
+ .reject { |f| f.match(%r{^(test|spec|features|doc|tmp|pkg)/}) }
20
+ s.executables = all_files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ s.bindir = "exe"
22
+ s.require_paths = ["lib"]
23
+ s.add_development_dependency "bundler", "~> 1.12"
24
+ s.add_development_dependency "rake", "~> 10.0"
25
+ s.add_development_dependency 'minitest', '~> 5.0'
26
+ end
@@ -0,0 +1,22 @@
1
+ def require_all(path)
2
+ glob = File.join(__dir__, path, "*.rb")
3
+ Dir[glob].sort.each do |f|
4
+ require f
5
+ end
6
+ end
7
+
8
+ # stdlib
9
+ require "fileutils"
10
+ require "ostruct"
11
+ require_all "bonsai_client"
12
+
13
+ module BonsaiClient
14
+
15
+ # Client for a Bonsai server.
16
+ #
17
+ # @return [Client]
18
+ def self.create(opts = {})
19
+ Client.new(opts)
20
+ end
21
+
22
+ end
@@ -0,0 +1,10 @@
1
+ module BonsaiClient
2
+ # Client for a Bonsai server.
3
+ class Client
4
+
5
+ def initialize(opts = {})
6
+ end
7
+
8
+ end
9
+ end
10
+
@@ -0,0 +1,4 @@
1
+ module BonsaiClient
2
+ VERSION = '0.1.0'.freeze
3
+ NAME = 'bonsai_client'.freeze
4
+ end
data/test-data/.keep ADDED
File without changes
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bonsai_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Manu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-03-01 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: This gem is at an early stage of development. Please do not use it already.
56
+ email:
57
+ - galfus@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".gitlab-ci-tempalte.yml"
64
+ - ".travis-template.yml"
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - bonsai_client.gemspec
72
+ - lib/bonsai_client.rb
73
+ - lib/bonsai_client/client.rb
74
+ - lib/bonsai_client/version.rb
75
+ - test-data/.keep
76
+ homepage: https://gitlab.com/galfuslab/bonsai-client
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.6.11
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Client for a Bonsai server.
100
+ test_files: []