constantinopolis 0.0.1 → 0.1.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: 6239ddbd0930e8bff6be617d4f307220d58e0668
4
- data.tar.gz: 82e80460a44b89b893fe66eb4913f21c4f9c38bc
3
+ metadata.gz: 781136133d8fde12826b63e724d86fd5f9f1812d
4
+ data.tar.gz: c3ec8b8e2024ad25fcb394650daf0469ae578108
5
5
  SHA512:
6
- metadata.gz: 68c7e8d39bbdb11f77b14dfda21286c5a7eb462ab3ff945c29a37607ea16b1dc828239f5875b942030c4e3f1e28c6162f75422718afe99b274d38ed64f96c868
7
- data.tar.gz: 140bbf8fc10a101de88fb5bde9b9eff73f1fecd332c0db306cc17a8ff7a52c3629cdbbd8d642ed99e7f8e4e5fff94641bceace6e051a98b364b0f7f62cb3b38a
6
+ metadata.gz: 0d934a21aa6d7f85a603b4a3d3485b5b5c34d770dca71e2e533b284ec1c96198238b57917db5cdd3478a2cd1d03d252ccc4bb790fafbd3b759daffd78ca71a75
7
+ data.tar.gz: 71d9cd82274bf5941a213164f8532a93f4a7b99b63b5e7c883230379d91efc3e72a77d1895eece607b39d2ba21f014833db78323e677f61d27c8384ff1d2c582
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/README.md CHANGED
@@ -26,14 +26,30 @@ Or install it yourself as:
26
26
  You need to create a class in your application like below.
27
27
 
28
28
  ```ruby
29
- class Istanbul < Constantinopolis::Fort
29
+ class Istanbul < Constantinopolis::Fort # Any class name you like
30
30
  yml "#{Rails.root}/config/istanbul.yml" # Indicate your yaml file path.
31
31
  namespace Rails.env # Indicate top level namespace (If you want).
32
32
  end
33
33
  Istanbul.build! # Don't forget this line!
34
34
  ```
35
35
 
36
- If you are setting for rails application, you'd better to create this file in ```config/initializer```.
36
+ If you are setting for a rails application, it's better to put this file in ```config/initializer```
37
+
38
+ ### Reload
39
+ If Constantinopolis is used on rails `development` environment, it'll automatically be reloaded when its yaml file is updated.
40
+
41
+ To manually reload, just invoke the method `reload!`.
42
+
43
+ ```ruby
44
+ ex)
45
+ class Istanbul < Constantinopolis::Fort
46
+ ...
47
+ end
48
+ ...
49
+
50
+ # Anywhere you want to reload it
51
+ Istanbul.reload!
52
+ ```
37
53
 
38
54
  ### Define constants
39
55
 
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "rspec", "~> 2.14"
22
- spec.add_development_dependency "pry-byebug", "~> 1.3"
23
- spec.add_development_dependency "capybara", "~> 2.2"
21
+ spec.add_development_dependency "rspec", "~> 3.4"
22
+ spec.add_development_dependency "pry-byebug", "~> 3.4"
23
+ spec.add_development_dependency "capybara", "~> 2.7"
24
24
  spec.add_development_dependency "launchy", "~> 2.4"
25
- spec.add_development_dependency "poltergeist", "~> 1.5"
25
+ spec.add_development_dependency "poltergeist", "~> 1.10"
26
26
  spec.add_development_dependency "sinatra", "~> 1.4"
27
27
  end
@@ -0,0 +1,34 @@
1
+ module Constantinopolis
2
+ module RailsReloader
3
+ extend self
4
+
5
+ def register(klass, yml)
6
+ if Rails.env.development?
7
+ reloader = file_update_checker.new([yml]) do
8
+ klass.reload!
9
+ end
10
+ Rails.application.reloaders << reloader
11
+
12
+ active_reloader.to_prepare do
13
+ reloader.execute_if_updated
14
+ end
15
+ end
16
+ end
17
+
18
+ def file_update_checker
19
+ case Rails.version[0]
20
+ when '4' then ActiveSupport::FileUpdateChecker
21
+ when '5' then Rails.application.config.file_watcher || ActiveSupport::FileUpdateChecker
22
+ else raise 'Unsupported rails version!'
23
+ end
24
+ end
25
+
26
+ def active_reloader
27
+ case Rails.version[0]
28
+ when '4' then ActionDispatch::Reloader
29
+ when '5' then ActiveSupport::Reloader
30
+ else raise 'Unsupported rails version!'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module Constantinopolis
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,17 +1,19 @@
1
1
  require "constantinopolis/version"
2
+ require "constantinopolis/rails_reloader"
2
3
  require "yaml"
3
4
  require "erb"
4
5
  require "json"
5
6
 
6
7
  module Constantinopolis
7
-
8
8
  class Fort
9
9
  private_class_method :new
10
10
 
11
11
  class << self
12
12
 
13
13
  def yml(path = nil)
14
- @yml ||= path
14
+ return @yml unless path
15
+ Constantinopolis::RailsReloader.register(self, path) if defined? Rails
16
+ @yml = path
15
17
  end
16
18
 
17
19
  def namespace(namespace = nil)
@@ -23,6 +25,11 @@ module Constantinopolis
23
25
  instance.build_js!
24
26
  end
25
27
 
28
+ def reload!
29
+ @instance = nil
30
+ build!
31
+ end
32
+
26
33
  def js_code
27
34
  instance.js_code
28
35
  end
@@ -35,12 +42,11 @@ module Constantinopolis
35
42
  end
36
43
  end
37
44
 
45
+ # --- Instance methods
46
+
38
47
  def build_methods!
39
48
  @constants.each do |key, value|
40
- self.class.module_eval do
41
- sig = class << self; self; end
42
- sig.send :define_method, key, ->() { value }
43
- end
49
+ self.class.define_singleton_method key, ->() { value }
44
50
  end
45
51
  end
46
52
 
@@ -7,7 +7,7 @@ require 'sinatra'
7
7
 
8
8
  Capybara.default_driver = :poltergeist
9
9
  Capybara.javascript_driver = :poltergeist
10
- Capybara.save_and_open_page_path = File.dirname(__FILE__) + '/../tmp'
10
+ Capybara.save_path = File.dirname(__FILE__) + '/../tmp'
11
11
 
12
12
  class SettingRack < Constantinopolis::Fort
13
13
  yml File.expand_path('../setting_rack.yml', __FILE__)
@@ -28,9 +28,9 @@ describe 'the dummy app', js: true do
28
28
 
29
29
  it "renders javascript objects" do
30
30
  visit "/"
31
- page.should have_content "Fort of javascript"
32
- page.should have_content "Hello, world!"
33
- page.should have_content "20"
34
- page.should have_content "2014-04-23"
31
+ expect(page).to have_content "Fort of javascript"
32
+ expect(page).to have_content "Hello, world!"
33
+ expect(page).to have_content "20"
34
+ expect(page).to have_content "2014-04-23"
35
35
  end
36
- end
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constantinopolis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - itmammoth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-23 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.14'
19
+ version: '3.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.14'
26
+ version: '3.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry-byebug
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '3.4'
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: '1.3'
40
+ version: '3.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: capybara
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.2'
47
+ version: '2.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.2'
54
+ version: '2.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: launchy
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.5'
75
+ version: '1.10'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.5'
82
+ version: '1.10'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sinatra
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -104,12 +104,14 @@ extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
106
  - ".gitignore"
107
+ - ".rspec"
107
108
  - Gemfile
108
109
  - LICENSE.txt
109
110
  - README.md
110
111
  - Rakefile
111
112
  - constantinopolis.gemspec
112
113
  - lib/constantinopolis.rb
114
+ - lib/constantinopolis/rails_reloader.rb
113
115
  - lib/constantinopolis/version.rb
114
116
  - spec/js/constantinopolis_js_spec.rb
115
117
  - spec/js/setting_rack.yml
@@ -138,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
140
  version: '0'
139
141
  requirements: []
140
142
  rubyforge_project:
141
- rubygems_version: 2.2.2
143
+ rubygems_version: 2.6.4
142
144
  signing_key:
143
145
  specification_version: 4
144
146
  summary: Setting constants solution for ruby applications.