furikake 0.1.6 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,6 +43,12 @@ export AWS_PROFILE=your-profile
43
43
  export AWS_REGION=ap-northeast-1
44
44
  ```
45
45
 
46
+ BACKLOG_API キーについても環境変数に指定することも可能です.
47
+
48
+ ```sh
49
+ export BACKLOG_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
50
+ ```
51
+
46
52
  ### Step 3: Generate && Modify .frikake.yml
47
53
 
48
54
  If you're starting on a fresh furikake project, you can use furikake to generate your .furikake.yml:
@@ -98,6 +104,18 @@ bundle exec furikake show
98
104
  bundle exec furikake publish
99
105
  ```
100
106
 
107
+ ### Step x: Monitor
108
+
109
+ `monitor` コマンドを利用することで, `publish` コマンドを常駐化することが可能です.
110
+
111
+ ```sh
112
+ # 1 時間毎に対象をチェックして wiki に登録する
113
+ bundle exec furikake monitor
114
+
115
+ # 10 分毎に対象をチェックして wiki に登録する
116
+ bundle exec furikake monitor --interval=600
117
+ ```
118
+
101
119
  ## Tips
102
120
 
103
121
  ### 検索対象リソース追加 (addons ディレクトリ)
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.16"
25
- spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rake", "~> 13.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  spec.add_development_dependency "octorelease"
28
28
 
@@ -9,13 +9,13 @@ module Furikake
9
9
 
10
10
  desc 'show', 'resouces print.'
11
11
  def show
12
- report = Furikake::Report.new
12
+ report = Furikake::Report.new(true)
13
13
  report.show
14
14
  end
15
15
 
16
16
  desc 'publish', 'resouces publish to something. (Default: Backlog)'
17
17
  def publish
18
- report = Furikake::Report.new
18
+ report = Furikake::Report.new(true)
19
19
  report.publish
20
20
  end
21
21
 
@@ -3,6 +3,7 @@
3
3
  module Furikake
4
4
  class Monitor < Report
5
5
  def initialize(options)
6
+ super(true)
6
7
  $stdout.sync = true
7
8
  @logger = Logger.new($stdout)
8
9
  @flag_int = false
@@ -4,14 +4,16 @@ module Furikake
4
4
  class Report
5
5
  include Furikake::Config
6
6
 
7
- def initialize
7
+ def initialize(cli, params = nil)
8
8
  $stdout.sync = true
9
9
  @logger = Logger.new($stdout)
10
+ @cli = cli
11
+ @params = @cli ? read_furikake_yaml : params
12
+ raise ArgumentError, 'パラメータが設定されていません.' if @params.nil?
10
13
  end
11
14
 
12
15
  def show
13
- params = read_furikake_yaml
14
- params['backlog']['projects'].each do |p|
16
+ @params['backlog']['projects'].each do |p|
15
17
  header = insert_published_by(p['header'])
16
18
  footer = p['footer']
17
19
  puts generate(header, footer)
@@ -19,8 +21,7 @@ module Furikake
19
21
  end
20
22
 
21
23
  def publish
22
- params = read_furikake_yaml
23
- params['backlog']['projects'].each do |p|
24
+ @params['backlog']['projects'].each do |p|
24
25
  header = insert_published_by(p['header'])
25
26
  footer = p['footer']
26
27
  document = generate(header, footer)
@@ -31,14 +32,10 @@ module Furikake
31
32
  end
32
33
  end
33
34
 
34
- # def monitor_test
35
- # show
36
- # end
37
-
38
35
  private
39
36
 
40
37
  def generate(header, footer)
41
- resource = Furikake::Resource.generate
38
+ resource = Furikake::Resource.generate(@cli, @params['resources'])
42
39
  documents = <<"EOS"
43
40
  #{header}
44
41
  #{resource}
@@ -1,8 +1,8 @@
1
1
  module Furikake
2
2
  class Resource
3
- def self.generate
3
+ def self.generate(cli, resources)
4
4
  documents = ''
5
- load_resource_type.each do |type|
5
+ load_resource_type(cli, resources).each do |type|
6
6
  if type.include?('addon')
7
7
  $LOAD_PATH.push(Dir.pwd + '/addons')
8
8
  require "#{type}"
@@ -26,9 +26,9 @@ module Furikake
26
26
  documents
27
27
  end
28
28
 
29
- def self.load_resource_type
29
+ def self.load_resource_type(cli, resources)
30
30
  type = []
31
- config_defined_resources = load_config_resource_type
31
+ config_defined_resources = cli ? load_config_resource_type : resources['aws'].sort
32
32
  default_resources = load_default_resource_type
33
33
  if default_resources == config_defined_resources
34
34
  type.push(default_resources)
@@ -29,7 +29,7 @@ module Furikake
29
29
  rds_infos = []
30
30
  rds.describe_db_instances.db_instances.map(&:to_h).each do |i|
31
31
  instance = []
32
- instance << i[:db_cluster_identifier]
32
+ instance << (!i[:db_cluster_identifier].nil? ? i[:db_cluster_identifier] : 'N/A')
33
33
  instance << i[:db_instance_identifier]
34
34
  instance << i[:db_instance_class]
35
35
  instance << i[:engine]
@@ -0,0 +1,52 @@
1
+ Aws.config[:rds] = {
2
+ stub_responses: {
3
+ describe_db_instances: {
4
+ db_instances: [
5
+ {
6
+ db_instance_identifier: 'my-rds',
7
+ db_instance_arn: 'arn:aws:rds:ap-northeast-1a:123456789012:db:my-rds',
8
+ db_instance_status: 'available',
9
+ db_instance_class: 'db.t2.medium',
10
+ availability_zone: 'ap-northeast-1a',
11
+ multi_az: false,
12
+ endpoint: {
13
+ address: 'my-rds-instance-endpoint'
14
+ },
15
+ engine: 'mysql'
16
+ },
17
+ {
18
+ db_cluster_identifier: 'my-cluster',
19
+ db_instance_identifier: 'my-cluster-instnace',
20
+ db_instance_arn: 'arn:aws:rds:ap-northeast-1a:123456789012:db:my-cluster-instance',
21
+ db_instance_status: 'available',
22
+ db_instance_class: 'db.t2.medium',
23
+ availability_zone: 'ap-northeast-1a',
24
+ multi_az: false,
25
+ endpoint: {
26
+ address: 'my-cluster-endpoint'
27
+ },
28
+ engine: 'aurora'
29
+ }
30
+ ]
31
+ },
32
+ describe_db_clusters: {
33
+ db_clusters: [
34
+ {
35
+ db_cluster_identifier: 'my-cluster',
36
+ endpoint: 'my-cluster-endpoint',
37
+ reader_endpoint: 'my-cluster-reader-endpoint',
38
+ db_cluster_members: [
39
+ {
40
+ db_instance_identifier: 'my-cluster-writer-instance',
41
+ is_cluster_writer: true
42
+ },
43
+ {
44
+ db_instance_identifier: 'my-cluster-reader-instance',
45
+ is_cluster_writer: false
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+ }
52
+ }
@@ -1,3 +1,3 @@
1
1
  module Furikake
2
- VERSION = '0.1.6'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: furikake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - inokappa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-25 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +166,7 @@ files:
166
166
  - lib/furikake/resources/security_group.rb
167
167
  - lib/furikake/resources/stub.rb
168
168
  - lib/furikake/resources/stub/ec2.rb
169
+ - lib/furikake/resources/stub/rds.rb
169
170
  - lib/furikake/resources/vpc.rb
170
171
  - lib/furikake/resources/vpc_endpoint.rb
171
172
  - lib/furikake/setup.rb
@@ -174,7 +175,7 @@ homepage: https://github.com/inokappa/furikake
174
175
  licenses:
175
176
  - MIT
176
177
  metadata: {}
177
- post_install_message:
178
+ post_install_message:
178
179
  rdoc_options: []
179
180
  require_paths:
180
181
  - lib
@@ -189,9 +190,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
190
  - !ruby/object:Gem::Version
190
191
  version: '0'
191
192
  requirements: []
192
- rubyforge_project:
193
- rubygems_version: 2.7.6
194
- signing_key:
193
+ rubygems_version: 3.0.3
194
+ signing_key:
195
195
  specification_version: 4
196
196
  summary: It is a command line tool to register your resources in Wiki page (Markdown
197
197
  format).