stackflame-client 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: 8a45c207e1f8d0acd8d9953dd15cbe1cf69d5b3e
4
+ data.tar.gz: 361099f22367f7c50d0de6b2805071ebf2c2dbff
5
+ SHA512:
6
+ metadata.gz: c4cac963a5a8d81f206acaab144575a1e2cfb064a6e6e86d487c0ce9ce09d968e614a9d9dcfbea00c2f1fc69cf0f7010588f97b326e2354e0c2e145a9d6d9b06
7
+ data.tar.gz: b36298b3e4ff80f3b3259cde6f1dfce7aba7600fd0bfdf09346ad6dfff36eacf10b6a9e77685a71007fd8604532e0dc79d9cee7fef14e309c852dcd963526c43
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/.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.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stackflame-client.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Stackflame::Client
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/stackflame/client`. 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 'stackflame-client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install stackflame-client
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/stackflame-client.
36
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "stackflame/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,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
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path('../lib', __FILE__)
4
+ require 'stackflame/client'
5
+
6
+ Stackflame::Client::CLI.start(ARGV)
@@ -0,0 +1,56 @@
1
+ require "stackflame/client/cli"
2
+ require "stackflame/client/version"
3
+
4
+ module Stackflame
5
+ class Client
6
+ DEFAULT_HOST = 'https://stackflame.herokuapp.com'
7
+
8
+ def self.post(url)
9
+ self.new.post(url)
10
+ end
11
+
12
+ def post(url)
13
+ data = parse_url(url)
14
+ response = post_stackflame_web(
15
+ endpoint: File.join(load_host, 'graphs'),
16
+ request: data['request'],
17
+ js_path: data['data'],
18
+ )
19
+ puts response.body
20
+ end
21
+
22
+ private
23
+
24
+ def parse_url(url)
25
+ data = {}
26
+ url.split(/[\?&]/).each do |part|
27
+ next unless part.include?('=')
28
+
29
+ key, value = part.split('=')
30
+ data[key] = value
31
+ end
32
+
33
+ abort "No request=* in '#{url}'" unless data['request']
34
+ abort "No data=* in '#{url}'" unless data['data']
35
+
36
+ data
37
+ end
38
+
39
+ def load_host
40
+ host_path = File.expand_path('~/.stackflame-client')
41
+ return DEFAULT_HOST unless File.exist?(host_path)
42
+
43
+ File.read(host_path)
44
+ end
45
+
46
+ def post_stackflame_web(endpoint:, request:, js_path:)
47
+ Net::HTTP.post_form(
48
+ URI.parse(endpoint),
49
+ {
50
+ 'graph[request]' => request,
51
+ 'graph[js]' => File.read(js_path),
52
+ },
53
+ )
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,23 @@
1
+ require 'thor'
2
+ require 'net/http'
3
+ require 'uri'
4
+
5
+ module Stackflame
6
+ class Client
7
+ class CLI < Thor
8
+ DEFAULT_TASK = :request
9
+
10
+ desc 'request URL', 'Parse and send request to stackflame-web'
11
+ def request(url)
12
+ Client.post(url)
13
+ end
14
+
15
+ private
16
+
17
+ def method_missing(*args)
18
+ return super(*args) if args.length > 1
19
+ send(DEFAULT_TASK, args.first.to_s)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module Stackflame
2
+ class Client
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stackflame/client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stackflame-client"
8
+ spec.version = Stackflame::Client::VERSION
9
+ spec.authors = ["Takashi Kokubun"]
10
+ spec.email = ["takashikkbn@gmail.com"]
11
+
12
+ spec.summary = %q{Client for stackflame-web}
13
+ spec.description = %q{Client for stackflame-web}
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "thor"
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stackflame-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Takashi Kokubun
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Client for stackflame-web
56
+ email:
57
+ - takashikkbn@gmail.com
58
+ executables:
59
+ - stackflame-client
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - exe/stackflame-client
71
+ - lib/stackflame/client.rb
72
+ - lib/stackflame/client/cli.rb
73
+ - lib/stackflame/client/version.rb
74
+ - stackflame-client.gemspec
75
+ homepage:
76
+ licenses: []
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.5
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Client for stackflame-web
98
+ test_files: []