flight-router 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2967c636a1f9d9bc68dbc4aafd39e256ae569d30
4
- data.tar.gz: 4ce606e0571159e32efd4743b960bac094f9d575
3
+ metadata.gz: c4ed599d578f6115fcf38ff43bcd5a8d4c189217
4
+ data.tar.gz: 3f4239e5c3892121cd1809c16d77ad07110086bd
5
5
  SHA512:
6
- metadata.gz: 494a9afd4c9a3f1e4a8925ba8eb0a5851f10afb5765703fe0ea3fe6e055b063cc8cb9a27a611ec38c0a1966b4a419ed785517b4e40c6b497d7fba8092c739985
7
- data.tar.gz: 3de38526cbcf3b221eaf4df5917070bddbeea06436b57ae3e0ba8f3d46e797fd4b1fbd3692fcdb21cd5fe40b34d93da3adccbe1da00782f6002ed0e71bf4beb0
6
+ metadata.gz: fbda631c772456afe2161ba8a2b1a7da9cbdf2f88846c6c7846802d26936ba6b27b7264a58e36657923b0e36a01eb297d4c1204100679d655f34ea22f170ef12
7
+ data.tar.gz: 241eb9d8f232da9e5302e0c1092f8d3469a8d64d57e9eb157263446747efdf791d57b7c94c5a249fc288194c065328c508034221bb3c5474c3133db7e3b0a269
@@ -0,0 +1,6 @@
1
+ # Changelog : 0.1.3
2
+
3
+ ## commits
4
+
5
+ * fix instance variable #drawer
6
+ * feature load_yaml
@@ -2,10 +2,10 @@ require "json"
2
2
 
3
3
  module Flight::Router
4
4
  class Drawer
5
- def initialize(opts)
6
- @output_dir = opts[:output_dir]
7
- @output_file = opts[:output_file]
8
- @map = Map.new(opts[:env])
5
+ def initialize(project:,output_dir:,input_dir:,env:)
6
+ @project = project
7
+ @output_dir = output_dir
8
+ @map = Map.new(env: env.to_sym, input_dir: File.join(input_dir,project))
9
9
  @app = App.new(@map)
10
10
  end
11
11
 
@@ -16,15 +16,13 @@ module Flight::Router
16
16
  @app.instance_exec(&block)
17
17
  end
18
18
 
19
- def draw(path,&block)
19
+ def draw(&block)
20
20
  dir = File.join(@output_dir,path)
21
21
  FileUtils.mkdir_p(dir)
22
22
  File.write File.join(dir,"routes.json"), JSON.generate(build(path,&block))
23
23
  end
24
- def build(path,&block)
25
- if path == "/"
26
- path == ""
27
- end
24
+ def build(&block)
25
+ path = File.join("/", @project)
28
26
  container = Container.new([path], app: @app.config, map: @map.map, output_dir: @output_dir)
29
27
  container.instance_exec(&block)
30
28
  container.config
@@ -1,3 +1,5 @@
1
+ require "yaml"
2
+
1
3
  module Flight::Router
2
4
  class Map < MapBase
3
5
  module Builder
@@ -22,16 +24,25 @@ module Flight::Router
22
24
  end
23
25
  end
24
26
 
25
- def initialize(env)
26
- @env = env.to_sym
27
+ def initialize(env:,input_dir:)
28
+ @env = env
29
+ @input_dir = input_dir
27
30
  @builder = Builder.builder
28
31
  end
29
32
 
30
33
  def env(**opts)
31
- unless opts.has_key?(@env)
32
- raise "env not defined: [#{@env}]"
34
+ if opts.empty?
35
+ @env
36
+ else
37
+ unless opts.has_key?(@env)
38
+ raise "env not defined: [#{@env}]"
39
+ end
40
+ opts[@env]
33
41
  end
34
- opts[@env]
42
+ end
43
+
44
+ def load_yaml(file)
45
+ YAML.load_file File.join(@input_dir,file)
35
46
  end
36
47
 
37
48
  private
@@ -1,5 +1,5 @@
1
1
  module Flight
2
2
  module Router
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flight-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - shun@getto.systems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -78,6 +78,7 @@ files:
78
78
  - ".travis.yml"
79
79
  - CHANGELOG/0.1.1.md
80
80
  - CHANGELOG/0.1.2.md
81
+ - CHANGELOG/0.1.3.md
81
82
  - Gemfile
82
83
  - LICENSE
83
84
  - README.md