lolp 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddd514a63d0130483640e11923e7c87e4ea0a23d
4
- data.tar.gz: 947463479409853b25511fafd082f268f8cfe7e7
3
+ metadata.gz: bb1500ac42d14da38d81a8d5521cf0d580125bc4
4
+ data.tar.gz: 450ff321402cab445420574c1df406296b13f906
5
5
  SHA512:
6
- metadata.gz: 814e7aa6a5d634b3b3e078d10f271c337e299e5ab67a9d8fd5ae8234880e336528daa69c379380507937b577e4cbb6d0997d8efbd6b50af4486b2cd6da6e5690
7
- data.tar.gz: 26b59dc4d5957d36165b191ab5c5b8f093913921eb81b0726309d4cd52ac76737baa643cfb27a6576c31b77afe42067c4b2e50efac3ac7dff6c5c4a6e80dbe79
6
+ metadata.gz: fcd507fecf933954c0a97751958de93e16a8080ccc2eb81c11e1c8ba29dc0f1a1b8b6ac9968995d4041c585bb629ba8f706431cf7bd583785e7f3b6c050cdc09
7
+ data.tar.gz: 98d64a900dc4795bde7867d4a164afdd8432d92a1d17a662f16a622da8c49bd5a7ec82c42d9154f30ff5be04cac7127ca2d00a7eb73dfbe9fc8c0ef4cc9a98c3
@@ -0,0 +1,3 @@
1
+ LOLIPOP_MC_API_ENDPOINT=
2
+ LOLIPOP_MC_USERNAME=
3
+ LOLIPOP_MC_PASSWORD=
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /.env
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.3
5
+ - 2.4
6
+ - ruby-head
7
+
8
+ script: bundle exec rake test
9
+
10
+ notifications:
11
+ slack: pepabo:1cO6OMIn3eFpIeyMXSuxrYjC
12
+ email: false
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- # Lolp.rb
1
+ <p align="center"><img src="https://raw.githubusercontent.com/pepabo/lolp.rb/images/lolipop-logo-by-gmo-pepabo.png" width="300" alt="lolp" /></p><p align="center"><strong>lolp</strong>: Simple ruby wrapper for Lolipop! API.</p> <br /> <br />
2
2
 
3
- Simple ruby wrapper for Lolipop! API.
3
+ [![Gem Version](https://img.shields.io/gem/v/lolp.svg?style=flat-square)](https://rubygems.org/gems/lolp)
4
+ [![Build Status](https://img.shields.io/travis/pepabo/lolp.rb.svg?style=flat-square)](https://travis-ci.org/pepabo/lolp.rb)
4
5
 
5
6
  ## Installation
6
7
 
@@ -20,7 +21,23 @@ Or install it yourself as:
20
21
 
21
22
  ## Usage
22
23
 
23
- TODO: Write usage instructions here
24
+ ```ruby
25
+ Lolp.configure do |config|
26
+ config.api_endpoint = 'LOLIPOP MC API ENDPOINT'
27
+ config.username = 'LOLIPOP MC USERNAME'
28
+ config.password = 'LOLIPOP MC PASSWORD'
29
+ end
30
+ ```
31
+
32
+ ### Projects
33
+
34
+ ```ruby
35
+ Lolp.projects
36
+ Lolp.create_project(:rails) # :wordpress, :php, ...
37
+ Lolp.delete_project('jungly-naha-2778')
38
+ Lolp.create_custom_domain('jungly-naha-2778.lolipop.ohr','example.com')
39
+ Lolp.delete_custom_domain('jungly-naha-2778.lolipop.ohr','example.com')
40
+ ```
24
41
 
25
42
  ## Development
26
43
 
@@ -30,5 +47,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
30
47
 
31
48
  ## Contributing
32
49
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/linyows/lolp.
34
50
 
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pepabo/lolp.rb.
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -1,5 +1,18 @@
1
- require "lolp/version"
1
+ require 'lolp/version'
2
+ require 'lolp/client'
2
3
 
3
4
  module Lolp
4
- # Your code goes here...
5
+ class << self
6
+ def client
7
+ @client ||= Lolp::Client.new
8
+ end
9
+
10
+ def method_missing(method_name, *args, &block)
11
+ if client.respond_to?(method_name)
12
+ return client.send(method_name, *args, &block)
13
+ end
14
+
15
+ super
16
+ end
17
+ end
5
18
  end
@@ -0,0 +1,14 @@
1
+ require 'lolp/connection'
2
+ require 'lolp/project'
3
+ require 'lolp/configuration'
4
+
5
+ module Lolp
6
+ class Client
7
+ include Lolp::Project
8
+ include Lolp::Configuration
9
+
10
+ def connection
11
+ @connection ||= Lolp::Connection.new(config)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ module Lolp
2
+ module Configuration
3
+ def config
4
+ @config ||= Config.new
5
+ end
6
+
7
+ def configure
8
+ yield config
9
+ end
10
+
11
+ class Config
12
+ attr_accessor :api_endpoint, :username, :password
13
+
14
+ def initialize
15
+ @api_endpoint = ENV['LOLIPOP_MC_API_ENDPOINT'] || 'https://mc.lolipop.jp/api'
16
+ @username = ENV['LOLIPOP_MC_USERNAME']
17
+ @password = ENV['LOLIPOP_MC_PASSWORD']
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,38 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module Lolp
5
+ class Connection
6
+ def initialize(config)
7
+ @config = config
8
+ authenticate
9
+ @connection = connection
10
+ end
11
+
12
+ def get(path)
13
+ @connection.get(path)
14
+ end
15
+
16
+ def post(path, params = {})
17
+ @connection.post(path, params)
18
+ end
19
+
20
+ def delete(path, params = {})
21
+ @connection.delete(path, params)
22
+ end
23
+
24
+ private
25
+
26
+ def connection
27
+ Faraday.new(url: @config.api_endpoint, headers: { Authorization: "Bearer #{@token}" }) do |faraday|
28
+ faraday.request :json
29
+ faraday.response :json, content_type: /\bjson$/
30
+ faraday.adapter Faraday.default_adapter
31
+ end
32
+ end
33
+
34
+ def authenticate
35
+ @token ||= connection.post('login', username: @config.username, password: @config.password).body
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,23 @@
1
+ module Lolp
2
+ module Project
3
+ def projects
4
+ connection.get('projects')
5
+ end
6
+
7
+ def create_project(template, params = {})
8
+ connection.post('projects', params.merge(haco_type: template))
9
+ end
10
+
11
+ def delete_project(name)
12
+ connection.delete("projects/#{name}")
13
+ end
14
+
15
+ def create_custom_domain(domain, custom_domain)
16
+ connection.post("projects/#{domain}/custom-domains", domain: custom_domain)
17
+ end
18
+
19
+ def delete_custom_domain(domain, custom_domain)
20
+ connection.delete("projects/#{domain}/custom-domains/#{custom_domain}")
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Lolp
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -31,4 +31,11 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_development_dependency "bundler", "~> 1.14"
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_dependency "faraday"
35
+ spec.add_dependency "faraday_middleware"
36
+
37
+ spec.add_development_dependency "minitest"
38
+ spec.add_development_dependency "vcr"
39
+ spec.add_development_dependency "pry"
40
+ spec.add_development_dependency "dotenv"
34
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolp
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
  - linyows
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,90 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: faraday_middleware
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: minitest
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
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: dotenv
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
41
125
  description: Simple ruby wrapper for Lolipop! API.
42
126
  email:
43
127
  - linyows@gmail.com
@@ -45,11 +129,17 @@ executables: []
45
129
  extensions: []
46
130
  extra_rdoc_files: []
47
131
  files:
132
+ - ".env.sample"
48
133
  - ".gitignore"
134
+ - ".travis.yml"
49
135
  - Gemfile
50
136
  - README.md
51
137
  - Rakefile
52
138
  - lib/lolp.rb
139
+ - lib/lolp/client.rb
140
+ - lib/lolp/configuration.rb
141
+ - lib/lolp/connection.rb
142
+ - lib/lolp/project.rb
53
143
  - lib/lolp/version.rb
54
144
  - lolp.gemspec
55
145
  homepage: https://lolipop.jp
@@ -71,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
161
  version: '0'
72
162
  requirements: []
73
163
  rubyforge_project:
74
- rubygems_version: 2.5.1
164
+ rubygems_version: 2.6.13
75
165
  signing_key:
76
166
  specification_version: 4
77
167
  summary: The lolipop! client