motion_flux 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +62 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Guardfile +36 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +7 -0
- data/lib/motion_flux.rb +8 -0
- data/lib/motion_flux/action.rb +18 -0
- data/lib/motion_flux/dispatcher.rb +46 -0
- data/lib/motion_flux/store.rb +31 -0
- data/lib/motion_flux/version.rb +3 -0
- data/motion_flux.gemspec +32 -0
- data/spec/motion_flux/action_spec.rb +26 -0
- data/spec/motion_flux/dispatcher_spec.rb +55 -0
- data/spec/motion_flux/store_spec.rb +45 -0
- data/spec/motion_flux_spec.rb +7 -0
- data/spec/spec_helper.rb +8 -0
- metadata +224 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 2ac26dc3f0f0f81dc3ee75045ca5d95eeb7d5779
         | 
| 4 | 
            +
              data.tar.gz: 3f0c9d78481414b1aa0b3d7dc1a7adad515bb3fa
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 8439fed636945962ef61abf288102709e7b8ee07de1a7a57d2e125c9e10002116638d05737cb5cef60c1bfa5182dbcab404833fa81cc9eca5c3fa02663695f81
         | 
| 7 | 
            +
              data.tar.gz: ee552a2600d1628093c8b8ee03886fa51b5bedae6e97a49776d7df9ea3a1dba2ff4e112c61a5dd932dc0f60babecf64f257d9c66c80117ec7acd55ed4f9cf6f1
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.rubocop.yml
    ADDED
    
    | @@ -0,0 +1,62 @@ | |
| 1 | 
            +
            AllCops:
         | 
| 2 | 
            +
              Exclude:
         | 
| 3 | 
            +
                - 'Rakefile'
         | 
| 4 | 
            +
                - 'Guardfile'
         | 
| 5 | 
            +
                - '*.gemspec'
         | 
| 6 | 
            +
                - 'bin/**/*'
         | 
| 7 | 
            +
                - 'db/**/*'
         | 
| 8 | 
            +
                - 'config/**/*'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Configuration parameters: CountComments.
         | 
| 11 | 
            +
            Metrics/MethodLength:
         | 
| 12 | 
            +
              Max: 20
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
         | 
| 15 | 
            +
            Style/BlockDelimiters:
         | 
| 16 | 
            +
              Exclude:
         | 
| 17 | 
            +
                - 'spec/**/*'
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            # Cop supports --auto-correct.
         | 
| 20 | 
            +
            Style/BlockEndNewline:
         | 
| 21 | 
            +
              Exclude:
         | 
| 22 | 
            +
                - 'spec/**/*'
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            # Cop supports --auto-correct.
         | 
| 25 | 
            +
            # Configuration parameters: EnforcedStyle, SupportedStyles.
         | 
| 26 | 
            +
            Style/BracesAroundHashParameters:
         | 
| 27 | 
            +
              Enabled: false
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            # Configuration parameters: EnforcedStyle, SupportedStyles.
         | 
| 30 | 
            +
            Style/ClassAndModuleChildren:
         | 
| 31 | 
            +
              Enabled: false
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            # Offense count: 102
         | 
| 34 | 
            +
            Style/Documentation:
         | 
| 35 | 
            +
              Enabled: false
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            # Configuration parameters: MinBodyLength.
         | 
| 38 | 
            +
            Style/GuardClause:
         | 
| 39 | 
            +
              Enabled: false
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            # Cop supports --auto-correct.
         | 
| 42 | 
            +
            # Configuration parameters: MaxLineLength.
         | 
| 43 | 
            +
            Style/IfUnlessModifier:
         | 
| 44 | 
            +
              Enabled: false
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            # Cop supports --auto-correct.
         | 
| 47 | 
            +
            Style/Lambda:
         | 
| 48 | 
            +
              Enabled: false
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            # Cop supports --auto-correct.
         | 
| 51 | 
            +
            # Configuration parameters: EnforcedStyle, SupportedStyles.
         | 
| 52 | 
            +
            Style/MethodDefParentheses:
         | 
| 53 | 
            +
              EnforcedStyle: require_no_parentheses
         | 
| 54 | 
            +
             | 
| 55 | 
            +
            # Cop supports --auto-correct.
         | 
| 56 | 
            +
            Style/MultilineBlockLayout:
         | 
| 57 | 
            +
              Exclude:
         | 
| 58 | 
            +
                - 'spec/**/*'
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            # Cop supports --auto-correct.
         | 
| 61 | 
            +
            Style/SingleSpaceBeforeFirstArg:
         | 
| 62 | 
            +
              Enabled: false
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Guardfile
    ADDED
    
    | @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            group :red_green_refactor, halt_on_fail: true do
         | 
| 2 | 
            +
              guard :rspec, cmd: "bundle exec rspec" do
         | 
| 3 | 
            +
                require "guard/rspec/dsl"
         | 
| 4 | 
            +
                dsl = Guard::RSpec::Dsl.new(self)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                # Feel free to open issues for suggestions and improvements
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                # RSpec files
         | 
| 9 | 
            +
                rspec = dsl.rspec
         | 
| 10 | 
            +
                watch(rspec.spec_helper) { rspec.spec_dir }
         | 
| 11 | 
            +
                watch(rspec.spec_support) { rspec.spec_dir }
         | 
| 12 | 
            +
                watch(rspec.spec_files)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                # Ruby files
         | 
| 15 | 
            +
                ruby = dsl.ruby
         | 
| 16 | 
            +
                dsl.watch_spec_files_for(ruby.lib_files)
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                # Rails files
         | 
| 19 | 
            +
                rails = dsl.rails(view_extensions: %w(erb haml slim))
         | 
| 20 | 
            +
                dsl.watch_spec_files_for(rails.app_files)
         | 
| 21 | 
            +
                dsl.watch_spec_files_for(rails.views)
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                watch(rails.controllers) do |m|
         | 
| 24 | 
            +
                  [
         | 
| 25 | 
            +
                    rspec.spec.("routing/#{m[1]}_routing"),
         | 
| 26 | 
            +
                    rspec.spec.("controllers/#{m[1]}_controller"),
         | 
| 27 | 
            +
                    rspec.spec.("acceptance/#{m[1]}")
         | 
| 28 | 
            +
                  ]
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              guard :rubocop, all_on_start: false do
         | 
| 33 | 
            +
                watch(%r{.+\.rb$})
         | 
| 34 | 
            +
                watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 kayhide
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            # MotionFlux [](https://travis-ci.org/kayhide/motion_flux) [](https://gemnasium.com/kayhide/motion_flux)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MotionFlux is a RubyMotion gem to build apps based on Flux architecture.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            https://facebook.github.io/flux/docs/overview.html
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## Installation
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Add this line to your application's Gemfile:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ```ruby
         | 
| 12 | 
            +
            gem 'motion_flux'
         | 
| 13 | 
            +
            ```
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            And then execute:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                $ bundle
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            Or install it yourself as:
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                $ gem install motion_flux
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ## Usage
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            TODO: Write usage instructions here
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ## Contributing
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            1. Fork it ( https://github.com/kayhide/motion_flux/fork )
         | 
| 30 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 31 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 32 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 33 | 
            +
            5. Create a new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/lib/motion_flux.rb
    ADDED
    
    
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            module MotionFlux
         | 
| 2 | 
            +
              class Action
         | 
| 3 | 
            +
                attr_reader :message, :args
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def initialize message, *args
         | 
| 6 | 
            +
                  @message = message
         | 
| 7 | 
            +
                  @args = args
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def to_s
         | 
| 11 | 
            +
                  "#{self.class}:#{message}"
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def dispatch
         | 
| 15 | 
            +
                  MotionFlux::Dispatcher.dispatch self
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            module MotionFlux
         | 
| 2 | 
            +
              class Dispatcher
         | 
| 3 | 
            +
                module ClassMethods
         | 
| 4 | 
            +
                  def subscribers
         | 
| 5 | 
            +
                    @subscribers ||= Hash.new { |hash, key| hash[key] = [] }
         | 
| 6 | 
            +
                  end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def register store, action
         | 
| 9 | 
            +
                    puts "#{store} is registered on #{action}"
         | 
| 10 | 
            +
                    subscribers[action] << store
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def clear
         | 
| 14 | 
            +
                    subscribers.clear
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def dispatch action
         | 
| 18 | 
            +
                    exclusive_run action do
         | 
| 19 | 
            +
                      subscribers[action.class].each do |store|
         | 
| 20 | 
            +
                        if store.respond_to? action.message
         | 
| 21 | 
            +
                          store.send action.message, action
         | 
| 22 | 
            +
                        else
         | 
| 23 | 
            +
                          puts "#{store}##{action.message} is not defined."
         | 
| 24 | 
            +
                        end
         | 
| 25 | 
            +
                      end
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def exclusive_run action, &proc
         | 
| 30 | 
            +
                    if @current_action
         | 
| 31 | 
            +
                      puts 'cascading action dispatch is not allowed.'
         | 
| 32 | 
            +
                      puts "#{@current_action} is on process."
         | 
| 33 | 
            +
                    else
         | 
| 34 | 
            +
                      @current_action = action
         | 
| 35 | 
            +
                      begin
         | 
| 36 | 
            +
                        proc.call
         | 
| 37 | 
            +
                      ensure
         | 
| 38 | 
            +
                        @current_action = nil
         | 
| 39 | 
            +
                      end
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                extend ClassMethods
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            module MotionFlux
         | 
| 2 | 
            +
              class Store
         | 
| 3 | 
            +
                def emit event
         | 
| 4 | 
            +
                  self.class.emit event
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                module ClassMethods
         | 
| 8 | 
            +
                  def subscribe action
         | 
| 9 | 
            +
                    MotionFlux::Dispatcher.register instance, action
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def instance
         | 
| 13 | 
            +
                    @instance ||= new
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def handlers
         | 
| 17 | 
            +
                    @handlers ||= Hash.new { |hash, key| hash[key] = [] }
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def on event, &proc
         | 
| 21 | 
            +
                    handlers[event] << proc
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def emit event
         | 
| 25 | 
            +
                    handlers[event].each(&:call)
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                extend ClassMethods
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
    
        data/motion_flux.gemspec
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'motion_flux/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = 'motion_flux'
         | 
| 8 | 
            +
              spec.version       = MotionFlux::VERSION
         | 
| 9 | 
            +
              spec.authors       = ['kayhide']
         | 
| 10 | 
            +
              spec.email         = ['kayhide@gmail.com']
         | 
| 11 | 
            +
              spec.summary       = 'MotionFlux supports to build Flux-based RubyMotion apps.'
         | 
| 12 | 
            +
              spec.description   = 'MotionFlux supports to build Flux-based RubyMotion apps.'
         | 
| 13 | 
            +
              spec.homepage      = 'https://github.com/kayhide/motion_flux'
         | 
| 14 | 
            +
              spec.license       = 'MIT'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ['lib']
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.add_development_dependency 'bundler', '~> 1.7'
         | 
| 22 | 
            +
              spec.add_development_dependency 'rake', '~> 10.0'
         | 
| 23 | 
            +
              spec.add_development_dependency 'rspec'
         | 
| 24 | 
            +
              spec.add_development_dependency 'fuubar'
         | 
| 25 | 
            +
              spec.add_development_dependency 'pry'
         | 
| 26 | 
            +
              spec.add_development_dependency 'rubocop'
         | 
| 27 | 
            +
              spec.add_development_dependency 'guard'
         | 
| 28 | 
            +
              spec.add_development_dependency 'guard-rspec'
         | 
| 29 | 
            +
              spec.add_development_dependency 'guard-rubocop'
         | 
| 30 | 
            +
              spec.add_development_dependency 'simplecov'
         | 
| 31 | 
            +
              spec.add_development_dependency 'simplecov-gem-profile'
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe MotionFlux::Action do
         | 
| 4 | 
            +
              class SomeAction < MotionFlux::Action; end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              describe '#to_s' do
         | 
| 7 | 
            +
                before do
         | 
| 8 | 
            +
                  @action = SomeAction.new(:sometiong, 'arg')
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it 'returns string' do
         | 
| 12 | 
            +
                  expect(@action.to_s).to eq 'SomeAction:sometiong'
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              describe '#dispatch' do
         | 
| 17 | 
            +
                before do
         | 
| 18 | 
            +
                  @action = SomeAction.new(:sometiong, 'arg')
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                it 'calls MotionFlex::Dispatcher.dispatch' do
         | 
| 22 | 
            +
                  expect(MotionFlux::Dispatcher).to receive(:dispatch).with(@action)
         | 
| 23 | 
            +
                  @action.dispatch
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,55 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe MotionFlux::Dispatcher do
         | 
| 4 | 
            +
              class SomeAction < MotionFlux::Action; end
         | 
| 5 | 
            +
              class AnotherAction < MotionFlux::Action; end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              describe '.dispatch' do
         | 
| 8 | 
            +
                before do
         | 
| 9 | 
            +
                  @store = double
         | 
| 10 | 
            +
                  MotionFlux::Dispatcher.register @store, SomeAction
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                after do
         | 
| 14 | 
            +
                  MotionFlux::Dispatcher.clear
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                it 'calls store method' do
         | 
| 18 | 
            +
                  expect(@store).to receive(:something)
         | 
| 19 | 
            +
                  MotionFlux::Dispatcher.dispatch SomeAction.new(:something)
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                it 'skips if store does not respond' do
         | 
| 23 | 
            +
                  expect {
         | 
| 24 | 
            +
                    MotionFlux::Dispatcher.dispatch SomeAction.new(:something)
         | 
| 25 | 
            +
                  }.not_to raise_error
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                it 'skips if action is not registered' do
         | 
| 29 | 
            +
                  expect(@store).not_to receive(:something)
         | 
| 30 | 
            +
                  MotionFlux::Dispatcher.dispatch AnotherAction.new(:something)
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              describe '.exclusive_run' do
         | 
| 35 | 
            +
                it 'calls given block' do
         | 
| 36 | 
            +
                  obj = double
         | 
| 37 | 
            +
                  expect(obj).to receive(:something)
         | 
| 38 | 
            +
                  MotionFlux::Dispatcher.exclusive_run 'first' do
         | 
| 39 | 
            +
                    obj.something
         | 
| 40 | 
            +
                  end
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                it 'skips second block' do
         | 
| 44 | 
            +
                  obj = double
         | 
| 45 | 
            +
                  expect(obj).to receive(:something)
         | 
| 46 | 
            +
                  expect(obj).not_to receive(:other_thing)
         | 
| 47 | 
            +
                  MotionFlux::Dispatcher.exclusive_run 'first' do
         | 
| 48 | 
            +
                    obj.something
         | 
| 49 | 
            +
                    MotionFlux::Dispatcher.exclusive_run 'second' do
         | 
| 50 | 
            +
                      obj.other_thing
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
            end
         | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe MotionFlux::Store do
         | 
| 4 | 
            +
              class SomeAction < MotionFlux::Action; end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              class SomeStore < MotionFlux::Store; end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              describe '.subscribe' do
         | 
| 9 | 
            +
                it 'calls MotionFlex::Dispatcher.register' do
         | 
| 10 | 
            +
                  expect(MotionFlux::Dispatcher)
         | 
| 11 | 
            +
                    .to receive(:register).with(SomeStore.instance, SomeAction)
         | 
| 12 | 
            +
                  SomeStore.subscribe SomeAction
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              describe '.on' do
         | 
| 17 | 
            +
                it 'appends handler' do
         | 
| 18 | 
            +
                  expect {
         | 
| 19 | 
            +
                    SomeStore.on :event do
         | 
| 20 | 
            +
                      true
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  }.to change(SomeStore.handlers, :count).by(1)
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              describe '.emit' do
         | 
| 27 | 
            +
                it 'calls handler' do
         | 
| 28 | 
            +
                  handler = double
         | 
| 29 | 
            +
                  expect(handler).to receive(:call)
         | 
| 30 | 
            +
                  SomeStore.handlers[:event] << handler
         | 
| 31 | 
            +
                  SomeStore.emit :event
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              describe '#emit' do
         | 
| 36 | 
            +
                before do
         | 
| 37 | 
            +
                  @store = SomeStore.instance
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                it 'calls MotionFlex::Store.emit' do
         | 
| 41 | 
            +
                  expect(SomeStore).to receive(:emit).with(:event)
         | 
| 42 | 
            +
                  @store.emit :event
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,224 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: motion_flux
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - kayhide
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-07-24 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.7'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.7'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '10.0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '10.0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 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: fuubar
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 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: pry
         | 
| 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: rubocop
         | 
| 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: guard
         | 
| 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: guard-rspec
         | 
| 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'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: guard-rubocop
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - ">="
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '0'
         | 
| 132 | 
            +
              type: :development
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - ">="
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '0'
         | 
| 139 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            +
              name: simplecov
         | 
| 141 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - ">="
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '0'
         | 
| 146 | 
            +
              type: :development
         | 
| 147 | 
            +
              prerelease: false
         | 
| 148 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - ">="
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '0'
         | 
| 153 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            +
              name: simplecov-gem-profile
         | 
| 155 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - ">="
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '0'
         | 
| 160 | 
            +
              type: :development
         | 
| 161 | 
            +
              prerelease: false
         | 
| 162 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            +
                requirements:
         | 
| 164 | 
            +
                - - ">="
         | 
| 165 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            +
                    version: '0'
         | 
| 167 | 
            +
            description: MotionFlux supports to build Flux-based RubyMotion apps.
         | 
| 168 | 
            +
            email:
         | 
| 169 | 
            +
            - kayhide@gmail.com
         | 
| 170 | 
            +
            executables: []
         | 
| 171 | 
            +
            extensions: []
         | 
| 172 | 
            +
            extra_rdoc_files: []
         | 
| 173 | 
            +
            files:
         | 
| 174 | 
            +
            - ".gitignore"
         | 
| 175 | 
            +
            - ".rspec"
         | 
| 176 | 
            +
            - ".rubocop.yml"
         | 
| 177 | 
            +
            - ".travis.yml"
         | 
| 178 | 
            +
            - Gemfile
         | 
| 179 | 
            +
            - Guardfile
         | 
| 180 | 
            +
            - LICENSE.txt
         | 
| 181 | 
            +
            - README.md
         | 
| 182 | 
            +
            - Rakefile
         | 
| 183 | 
            +
            - lib/motion_flux.rb
         | 
| 184 | 
            +
            - lib/motion_flux/action.rb
         | 
| 185 | 
            +
            - lib/motion_flux/dispatcher.rb
         | 
| 186 | 
            +
            - lib/motion_flux/store.rb
         | 
| 187 | 
            +
            - lib/motion_flux/version.rb
         | 
| 188 | 
            +
            - motion_flux.gemspec
         | 
| 189 | 
            +
            - spec/motion_flux/action_spec.rb
         | 
| 190 | 
            +
            - spec/motion_flux/dispatcher_spec.rb
         | 
| 191 | 
            +
            - spec/motion_flux/store_spec.rb
         | 
| 192 | 
            +
            - spec/motion_flux_spec.rb
         | 
| 193 | 
            +
            - spec/spec_helper.rb
         | 
| 194 | 
            +
            homepage: https://github.com/kayhide/motion_flux
         | 
| 195 | 
            +
            licenses:
         | 
| 196 | 
            +
            - MIT
         | 
| 197 | 
            +
            metadata: {}
         | 
| 198 | 
            +
            post_install_message: 
         | 
| 199 | 
            +
            rdoc_options: []
         | 
| 200 | 
            +
            require_paths:
         | 
| 201 | 
            +
            - lib
         | 
| 202 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 203 | 
            +
              requirements:
         | 
| 204 | 
            +
              - - ">="
         | 
| 205 | 
            +
                - !ruby/object:Gem::Version
         | 
| 206 | 
            +
                  version: '0'
         | 
| 207 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 208 | 
            +
              requirements:
         | 
| 209 | 
            +
              - - ">="
         | 
| 210 | 
            +
                - !ruby/object:Gem::Version
         | 
| 211 | 
            +
                  version: '0'
         | 
| 212 | 
            +
            requirements: []
         | 
| 213 | 
            +
            rubyforge_project: 
         | 
| 214 | 
            +
            rubygems_version: 2.2.2
         | 
| 215 | 
            +
            signing_key: 
         | 
| 216 | 
            +
            specification_version: 4
         | 
| 217 | 
            +
            summary: MotionFlux supports to build Flux-based RubyMotion apps.
         | 
| 218 | 
            +
            test_files:
         | 
| 219 | 
            +
            - spec/motion_flux/action_spec.rb
         | 
| 220 | 
            +
            - spec/motion_flux/dispatcher_spec.rb
         | 
| 221 | 
            +
            - spec/motion_flux/store_spec.rb
         | 
| 222 | 
            +
            - spec/motion_flux_spec.rb
         | 
| 223 | 
            +
            - spec/spec_helper.rb
         | 
| 224 | 
            +
            has_rdoc: 
         |